exclude tests folders from template version linting (#44721)

Co-authored-by: Ron Rennick <ronald.rennick@automattic.com>
This commit is contained in:
Ron Rennick 2024-02-22 15:05:28 -04:00 committed by GitHub
parent 1327310a01
commit 6524f639b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 13 deletions

View File

@ -22,8 +22,9 @@ jobs:
working-directory: 'tools/code-analyzer'
run: |
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)
pnpm analyzer "$HEAD_REF" $version -o "github"
pnpm analyzer "$HEAD_REF" $version -o "github" -e $exclude
- uses: 'actions/github-script@v6'
name: 'Validate'
with:

View File

@ -35,6 +35,11 @@ const program = new Command()
'Git repo url or local path to a git repo.',
join( process.cwd(), '../../' )
)
.option(
'-e, --exclude <exclude...>',
'List of folders / files to exclude.',
[]
)
.addOption(
new Option( '-o, --outputStyle <outputStyle>' ).choices( [
'github',
@ -42,14 +47,16 @@ const program = new Command()
] as const )
)
.action( async ( compare, sinceVersion, options ) => {
const { source, base, outputStyle = 'cli' } = options;
const { source, base, outputStyle = 'cli', exclude = [] } = options;
const changes = await scanForChanges(
compare,
sinceVersion,
source,
base,
outputStyle
outputStyle,
undefined,
exclude
);
if ( changes.templates.size ) {

View File

@ -36,10 +36,6 @@ const generateVersionDiff = async (
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
);
Logger.notice(
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
);
const diff = await generateDiff(
tmpRepoPath,
base,
@ -119,7 +115,8 @@ export const scanForChanges = async (
source: string,
base: string,
outputStyle: 'cli' | 'github',
clonedPath?: string
clonedPath?: string,
exclude?: string[]
) => {
Logger.startTask( `Making temporary clone of ${ source }...` );
@ -134,16 +131,12 @@ export const scanForChanges = async (
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
);
Logger.notice(
`Temporary clone of ${ source } created at ${ tmpRepoPath }`
);
const diff = await generateDiff(
tmpRepoPath,
base,
compareVersion,
Logger.error,
[ 'tools' ]
[ 'tools', ...exclude ]
);
// Only checkout the compare version if we're in CLI mode.