Skip to content

Commit

Permalink
Cache phet-io-api-comparison results on a repo-by-repo basis, see #1325
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Oct 17, 2022
1 parent 9b032cb commit 6f70287
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions js/scripts/hook-pre-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,39 +166,35 @@ const puppeteerQUnit = require( '../../../aqua/js/local/puppeteerQUnit' );
//
const phetioAPIOK = await phetTimingLog.startAsync( 'phet-io-api-compare', async () => {

const getCacheKey = repo => `phet-io-api-compare#${repo}`;

// Test this repo and all phet-io sims that have it as a dependency. For instance, changing sun would test
// every phet-io stable sim.
const phetioAPIStable = getRepoList( 'phet-io-api-stable' );
const reposToTest = phetioAPIStable.filter( phetioSimRepo => getPhetLibs( phetioSimRepo ).includes( repo ) );
const reposToTest = phetioAPIStable
.filter( phetioSimRepo => getPhetLibs( phetioSimRepo ).includes( repo ) )

// Only worry about the ones that are not cached
.filter( repo => !CacheLayer.isCacheSafe( getCacheKey( repo ) ) );

if ( reposToTest.length > 0 ) {
console.log( 'PhET-iO API testing: ' + reposToTest );

const cacheKey = 'phet-io-api-testing_' + reposToTest.join( '_' );

if ( !CacheLayer.isCacheSafe( cacheKey ) ) {

const proposedAPIs = await generatePhetioMacroAPI( reposToTest, {
showProgressBar: reposToTest.length > 1,
showMessagesFromSim: false
} );
const proposedAPIs = await generatePhetioMacroAPI( reposToTest, {
showProgressBar: reposToTest.length > 1,
showMessagesFromSim: false
} );

const phetioAPIComparisonSuccessful = await phetioCompareAPISets( reposToTest, proposedAPIs, {} );
const phetioAPIComparisonSuccessful = await phetioCompareAPISets( reposToTest, proposedAPIs, {} );

if ( phetioAPIComparisonSuccessful ) {
CacheLayer.onSuccess( cacheKey );
}

return phetioAPIComparisonSuccessful;
if ( phetioAPIComparisonSuccessful ) {
reposToTest.forEach( repo => CacheLayer.onSuccess( getCacheKey( repo ) ) );
}
else {

// Cached and cache is good
return true;
}
return phetioAPIComparisonSuccessful;
}
else {
console.log( 'PhET-iO API testing: no repos detected' );
console.log( 'PhET-iO API testing: no repos to test' );
return true;
}
} );
Expand Down

0 comments on commit 6f70287

Please sign in to comment.