Skip to content

Commit

Permalink
check clean status of all dependencies before dev test, #310
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Mar 15, 2023
1 parent 7e0049f commit 1250823
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion js/common/getDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const winston = require( 'winston' );
* @param {string} repo - The repository name
* @returns {Promise} - Resolves to the dependencies.json content
*/
module.exports = function( repo ) {
module.exports = function getDependencies( repo ) {
winston.info( `getting dependencies.json for ${repo}` );

return loadJSON( `../${repo}/dependencies.json` );
Expand Down
24 changes: 24 additions & 0 deletions js/common/getDependencyRepos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2017-2023, University of Colorado Boulder

/**
* The repos (keys) from dependencies.json of a repository
*
* @author Jonathan Olson <jonathan.olson@colorado.edu>
* @author Michael Kauzmann (PhET Interactive Simulations)
*/

const loadJSON = require( './loadJSON' );
const winston = require( 'winston' );

/**
* @public
*
* @param {string} repo - The repository name
* @returns {Promise} - Resolves to the list of repos in the dependencies.json of the provided repo
*/
module.exports = async function getDependencyRepos( repo ) {
winston.info( `getting dependencies.json for ${repo}` );

const json = await loadJSON( `../${repo}/dependencies.json` );
return Object.keys( json ).filter( key => key !== 'comment' );
};
11 changes: 8 additions & 3 deletions js/grunt/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const getBranch = require( '../common/getBranch' );
const getRemoteBranchSHAs = require( '../common/getRemoteBranchSHAs' );
const getRepoVersion = require( '../common/getRepoVersion' );
const gitIsClean = require( '../common/gitIsClean' );
const getDependencyRepos = require( '../common/getDependencyRepos' );
const gitPush = require( '../common/gitPush' );
const gitRevParse = require( '../common/gitRevParse' );
const lintAllRunnable = require( '../common/lintAllRunnable' );
Expand Down Expand Up @@ -68,9 +69,13 @@ module.exports = async function( repo, brands, noninteractive, branch, message )
}
}

const isClean = await gitIsClean( repo );
if ( !isClean ) {
throw new Error( `Unclean status in ${repo}, cannot deploy` );
const dependencies = await getDependencyRepos( repo );
for ( let i = 0; i < dependencies.length; i++ ) {
const dependency = dependencies[ i ];
const isClean = await gitIsClean( dependency );
if ( !isClean ) {
throw new Error( `Unclean status in ${dependency}, cannot deploy` );
}
}

const currentSHA = await gitRevParse( repo, 'HEAD' );
Expand Down

0 comments on commit 1250823

Please sign in to comment.