Skip to content

Commit

Permalink
Improve CT loading from uncertain state, see #88
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Apr 16, 2020
1 parent 77f38e4 commit 787515f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions js/server/continuous-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const cloneMissingRepos = require( '../../../perennial/js/common/cloneMissingRep
const execute = require( '../../../perennial/js/common/execute' );
const getRepoList = require( '../../../perennial/js/common/getRepoList' );
const gitPull = require( '../../../perennial/js/common/gitPull' );
const gitRevParse = require( '../../../perennial/js/common/gitRevParse' );
const gruntCommand = require( '../../../perennial/js/common/gruntCommand' );
const isStale = require( '../../../perennial/js/common/isStale' );
const npmUpdate = require( '../../../perennial/js/common/npmUpdate' );
Expand Down Expand Up @@ -220,6 +221,29 @@ const cycleSnapshots = async () => {
// {boolean} Whether our last scan of SHAs found anything stale.
let wasStale = true;

// when loading from a file
if ( snapshots.length ) {
setSnapshotStatus( 'Scanning checked out state to determine whether the server is stale' );

wasStale = false;
for ( const repo of Object.keys( snapshots[ 0 ].shas ) ) {
if ( await gitRevParse( repo, 'master' ) !== snapshots[ 0 ].shas[ repo ] ) {
wasStale = true;
break;
}
}

winston.info( `Initial wasStale: ${wasStale}` );
}

// initial NPM checks, so that all repos will have node_modules that need them
for ( const repo of getRepoList( 'active-repos' ) ) {
setSnapshotStatus( `Running initial node_modules checks: ${repo}` );
if ( repo !== 'aqua' && fs.existsSync( `../${repo}/package.json` ) && !fs.existsSync( `../${repo}/node_modules` ) ) {
await npmUpdate( repo );
}
}

while ( true ) { // eslint-disable-line
try {
const staleMessage = wasStale ? 'Changes detected, waiting for stable SHAs' : 'No changes';
Expand Down

0 comments on commit 787515f

Please sign in to comment.