Code-analyzer: Perform build between checkouts to avoid failures (#34438)

Fixes #34196
This commit is contained in:
Sam Seay 2022-08-25 11:50:31 +12:00 committed by GitHub
parent b2c3ef8f29
commit 7f5f47247c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -126,11 +126,16 @@ export default class Analyzer extends Command {
const pluginPath = join( tmpRepoPath, 'plugins/woocommerce' ); const pluginPath = join( tmpRepoPath, 'plugins/woocommerce' );
// Note doing the minimal work to get a DB scan to work, avoiding full build for speed. const build = () => {
execSync( 'composer install', { cwd: pluginPath, stdio: [] } ); // Note doing the minimal work to get a DB scan to work, avoiding full build for speed.
execSync( 'pnpm run build:feature-config --filter=woocommerce', { execSync( 'composer install', { cwd: pluginPath, stdio: [] } );
cwd: pluginPath, execSync(
} ); 'pnpm run build:feature-config --filter=woocommerce',
{
cwd: pluginPath,
}
);
};
CliUx.ux.action.stop(); CliUx.ux.action.stop();
CliUx.ux.action.start( CliUx.ux.action.start(
@ -141,6 +146,7 @@ export default class Analyzer extends Command {
tmpRepoPath, tmpRepoPath,
compare, compare,
base, base,
build,
( e: string ): void => this.error( e ) ( e: string ): void => this.error( e )
); );

View File

@ -215,6 +215,7 @@ export const getSchema = async (
* @param {string} tmpRepoPath Path to repository used to generate schema diff. * @param {string} tmpRepoPath Path to repository used to generate schema diff.
* @param {string} compare Branch/commit hash to compare against the base. * @param {string} compare Branch/commit hash to compare against the base.
* @param {string} base Base branch/commit hash. * @param {string} base Base branch/commit hash.
* @param build Build to perform between checkouts.
* @param {Function} error error print method. * @param {Function} error error print method.
* @return {Object|void} diff object. * @return {Object|void} diff object.
*/ */
@ -222,6 +223,7 @@ export const generateSchemaDiff = async (
tmpRepoPath: string, tmpRepoPath: string,
compare: string, compare: string,
base: string, base: string,
build: () => void,
error: ( s: string ) => void error: ( s: string ) => void
): Promise< { ): Promise< {
[ key: string ]: { [ key: string ]: {
@ -241,6 +243,7 @@ export const generateSchemaDiff = async (
// Force checkout because sometimes a build will generate a lockfile change. // Force checkout because sometimes a build will generate a lockfile change.
await git.checkout( base, [ '--force' ] ); await git.checkout( base, [ '--force' ] );
build();
const baseSchema = await getSchema( const baseSchema = await getSchema(
tmpRepoPath, tmpRepoPath,
( errorMessage: string ) => { ( errorMessage: string ) => {
@ -255,6 +258,7 @@ export const generateSchemaDiff = async (
// Force checkout because sometimes a build will generate a lockfile change. // Force checkout because sometimes a build will generate a lockfile change.
await git.checkout( compare, [ '--force' ] ); await git.checkout( compare, [ '--force' ] );
build();
const compareSchema = await getSchema( const compareSchema = await getSchema(
tmpRepoPath, tmpRepoPath,
( errorMessage: string ) => { ( errorMessage: string ) => {