exclude tests folders from template version linting (#44721)
Co-authored-by: Ron Rennick <ronald.rennick@automattic.com>
This commit is contained in:
parent
1327310a01
commit
6524f639b4
|
@ -22,8 +22,9 @@ jobs:
|
||||||
working-directory: 'tools/code-analyzer'
|
working-directory: 'tools/code-analyzer'
|
||||||
run: |
|
run: |
|
||||||
HEAD_REF=$(git rev-parse HEAD)
|
HEAD_REF=$(git rev-parse HEAD)
|
||||||
|
exclude="plugins/woocommerce/tests plugins/woocommerce-admin/tests plugins/woocommerce-blocks/tests"
|
||||||
version=$(pnpm analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
|
version=$(pnpm analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
|
||||||
pnpm analyzer "$HEAD_REF" $version -o "github"
|
pnpm analyzer "$HEAD_REF" $version -o "github" -e $exclude
|
||||||
- uses: 'actions/github-script@v6'
|
- uses: 'actions/github-script@v6'
|
||||||
name: 'Validate'
|
name: 'Validate'
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -35,6 +35,11 @@ const program = new Command()
|
||||||
'Git repo url or local path to a git repo.',
|
'Git repo url or local path to a git repo.',
|
||||||
join( process.cwd(), '../../' )
|
join( process.cwd(), '../../' )
|
||||||
)
|
)
|
||||||
|
.option(
|
||||||
|
'-e, --exclude <exclude...>',
|
||||||
|
'List of folders / files to exclude.',
|
||||||
|
[]
|
||||||
|
)
|
||||||
.addOption(
|
.addOption(
|
||||||
new Option( '-o, --outputStyle <outputStyle>' ).choices( [
|
new Option( '-o, --outputStyle <outputStyle>' ).choices( [
|
||||||
'github',
|
'github',
|
||||||
|
@ -42,14 +47,16 @@ const program = new Command()
|
||||||
] as const )
|
] as const )
|
||||||
)
|
)
|
||||||
.action( async ( compare, sinceVersion, options ) => {
|
.action( async ( compare, sinceVersion, options ) => {
|
||||||
const { source, base, outputStyle = 'cli' } = options;
|
const { source, base, outputStyle = 'cli', exclude = [] } = options;
|
||||||
|
|
||||||
const changes = await scanForChanges(
|
const changes = await scanForChanges(
|
||||||
compare,
|
compare,
|
||||||
sinceVersion,
|
sinceVersion,
|
||||||
source,
|
source,
|
||||||
base,
|
base,
|
||||||
outputStyle
|
outputStyle,
|
||||||
|
undefined,
|
||||||
|
exclude
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( changes.templates.size ) {
|
if ( changes.templates.size ) {
|
||||||
|
|
|
@ -36,10 +36,6 @@ const generateVersionDiff = async (
|
||||||
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
|
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
|
||||||
);
|
);
|
||||||
|
|
||||||
Logger.notice(
|
|
||||||
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
|
|
||||||
);
|
|
||||||
|
|
||||||
const diff = await generateDiff(
|
const diff = await generateDiff(
|
||||||
tmpRepoPath,
|
tmpRepoPath,
|
||||||
base,
|
base,
|
||||||
|
@ -119,7 +115,8 @@ export const scanForChanges = async (
|
||||||
source: string,
|
source: string,
|
||||||
base: string,
|
base: string,
|
||||||
outputStyle: 'cli' | 'github',
|
outputStyle: 'cli' | 'github',
|
||||||
clonedPath?: string
|
clonedPath?: string,
|
||||||
|
exclude?: string[]
|
||||||
) => {
|
) => {
|
||||||
Logger.startTask( `Making temporary clone of ${ source }...` );
|
Logger.startTask( `Making temporary clone of ${ source }...` );
|
||||||
|
|
||||||
|
@ -134,16 +131,12 @@ export const scanForChanges = async (
|
||||||
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
|
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
|
||||||
);
|
);
|
||||||
|
|
||||||
Logger.notice(
|
|
||||||
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
|
|
||||||
);
|
|
||||||
|
|
||||||
const diff = await generateDiff(
|
const diff = await generateDiff(
|
||||||
tmpRepoPath,
|
tmpRepoPath,
|
||||||
base,
|
base,
|
||||||
compareVersion,
|
compareVersion,
|
||||||
Logger.error,
|
Logger.error,
|
||||||
[ 'tools' ]
|
[ 'tools', ...exclude ]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Only checkout the compare version if we're in CLI mode.
|
// Only checkout the compare version if we're in CLI mode.
|
||||||
|
|
Loading…
Reference in New Issue