CI: update linting jobs to skip build step (#49193)

In this PR, we introduce changes to linting and PHPUnit jobs in order to speed them up: skip or minimize the build step.
This commit is contained in:
Vladimir Reznichenko 2024-07-08 08:39:39 +02:00 committed by GitHub
parent 6d17019827
commit 68532ce433
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 224 additions and 16 deletions

View File

@ -10,6 +10,9 @@ inputs:
build: build:
description: 'Given a boolean or PNPM filter, runs the build command for monorepo project(s).' description: 'Given a boolean or PNPM filter, runs the build command for monorepo project(s).'
default: false default: false
build-type:
description: 'Given "full" or "backend" will perform optimized build steps.'
default: 'full'
pull-playwright-cache: pull-playwright-cache:
description: 'Given a boolean value, invokes Playwright dependencies caching.' description: 'Given a boolean value, invokes Playwright dependencies caching.'
default: false default: false
@ -73,4 +76,10 @@ runs:
# Boolean inputs aren't parsed into filters so it'll either be "true" or there will be a filter. # Boolean inputs aren't parsed into filters so it'll either be "true" or there will be a filter.
if: ${{ inputs.build == 'true' || steps.project-filters.outputs.build != '' }} if: ${{ inputs.build == 'true' || steps.project-filters.outputs.build != '' }}
shell: 'bash' shell: 'bash'
run: 'pnpm ${{ steps.project-filters.outputs.build }} build' run: |
if [[ '${{ inputs.build-type }}' == 'backend' ]]; then
pnpm --filter="@woocommerce/admin-library" build:project:feature-config
fi
if [[ '${{ inputs.build-type }}' == 'full' ]]; then
pnpm ${{ steps.project-filters.outputs.build }} build
fi

View File

@ -94,7 +94,6 @@ jobs:
id: 'setup-monorepo' id: 'setup-monorepo'
with: with:
install: '${{ matrix.projectName }}...' install: '${{ matrix.projectName }}...'
build: '${{ matrix.projectName }}'
- name: 'Lint' - name: 'Lint'
run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}' run: 'pnpm --filter="${{ matrix.projectName }}" ${{ matrix.command }}'
@ -118,17 +117,10 @@ jobs:
id: 'install-monorepo' id: 'install-monorepo'
with: with:
install: '${{ matrix.projectName }}...' install: '${{ matrix.projectName }}...'
build: 'false' build: ${{ ( github.ref_type == 'tag' && 'false' ) || matrix.projectName }}
build-type: ${{ ( matrix.testType == 'unit:php' && 'backend' ) || 'full' }}
pull-playwright-cache: ${{ matrix.testEnv.shouldCreate && matrix.testType == 'e2e' }} pull-playwright-cache: ${{ matrix.testEnv.shouldCreate && matrix.testType == 'e2e' }}
- uses: './.github/actions/setup-woocommerce-monorepo'
if: ${{ github.ref_type != 'tag' }}
name: 'Build project'
id: 'build-project'
with:
install: 'false'
build: ${{ matrix.projectName }}
- name: 'Update wp-env config' - name: 'Update wp-env config'
if: ${{ github.ref_type == 'tag' }} if: ${{ github.ref_type == 'tag' }}
env: env:
@ -159,7 +151,7 @@ jobs:
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> "$GITHUB_OUTPUT" echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> "$GITHUB_OUTPUT"
shell: bash shell: bash
- name: 'Run tests' - name: 'Run tests (${{ matrix.testType }})'
env: env:
E2E_ENV_KEY: ${{ secrets.E2E_ENV_KEY }} E2E_ENV_KEY: ${{ secrets.E2E_ENV_KEY }}
BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_CORE_E2E_TOKEN }} BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_CORE_E2E_TOKEN }}

View File

@ -4,4 +4,11 @@ module.exports = {
'plugin:@woocommerce/eslint-plugin/recommended', 'plugin:@woocommerce/eslint-plugin/recommended',
], ],
root: true, root: true,
settings: {
'import/core-modules': [ '@woocommerce/e2e-utils' ],
'import/resolver': {
node: {},
typescript: {},
},
},
}; };

View File

@ -0,0 +1,12 @@
module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true,
settings: {
'import/core-modules': [ '@woocommerce/components' ],
'import/resolver': {
node: {},
webpack: {},
typescript: {},
},
},
};

View File

@ -9,4 +9,16 @@ module.exports = {
}, },
}, },
], ],
settings: {
'import/core-modules': [
'@wordpress/core-data',
'@wordpress/blocks',
'@woocommerce/expression-evaluation',
],
'import/resolver': {
node: {},
webpack: {},
typescript: {},
},
},
}; };

View File

@ -17,4 +17,27 @@ module.exports = {
}, },
}, },
], ],
settings: {
'import/core-modules': [
'@woocommerce/components',
'@woocommerce/currency',
'@woocommerce/data',
'@woocommerce/date',
'@woocommerce/navigation',
'@storybook/react',
'@automattic/tour-kit',
'@wordpress/blocks',
'@wordpress/components',
'@wordpress/element',
'@wordpress/media-utils',
'dompurify',
'downshift',
'moment',
],
'import/resolver': {
node: {},
webpack: {},
typescript: {},
},
},
}; };

View File

@ -1,4 +1,14 @@
module.exports = { module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true, root: true,
settings: {
'import/core-modules': [
'@woocommerce/number',
'@woocommerce/settings',
],
'import/resolver': {
node: {},
typescript: {},
},
},
}; };

View File

@ -1,4 +1,18 @@
module.exports = { module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true, root: true,
settings: {
'import/core-modules': [
'@woocommerce/data',
'@woocommerce/experimental',
'@woocommerce/navigation',
'@woocommerce/tracks',
'@testing-library/react',
],
'import/resolver': {
node: {},
webpack: {},
typescript: {},
},
},
}; };

View File

@ -1,4 +1,20 @@
module.exports = { module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true, root: true,
settings: {
'import/core-modules': [
'@woocommerce/date',
'@woocommerce/navigation',
'@woocommerce/tracks',
'@wordpress/api-fetch',
'@wordpress/core-data',
'@wordpress/data',
'@automattic/data-stores',
'redux',
],
'import/resolver': {
node: {},
typescript: {},
},
},
}; };

View File

@ -1,4 +1,18 @@
module.exports = { module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true, root: true,
settings: {
'import/core-modules': [
'@woocommerce/components',
'@wordpress/components',
'@storybook/react',
'react-transition-group/CSSTransition',
'dompurify',
],
'import/resolver': {
node: {},
webpack: {},
typescript: {},
},
},
}; };

View File

@ -1,4 +1,16 @@
module.exports = { module.exports = {
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ], extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
root: true, root: true,
settings: {
'import/core-modules': [
'@woocommerce/experimental',
'@woocommerce/components',
'@woocommerce/tracks',
],
'import/resolver': {
node: {},
webpack: {},
typescript: {},
},
},
}; };

View File

@ -9,4 +9,36 @@ module.exports = {
}, },
}, },
], ],
settings: {
'import/core-modules': [
'@woocommerce/admin-layout',
'@woocommerce/block-templates',
'@woocommerce/components',
'@woocommerce/customer-effort-score',
'@woocommerce/currency',
'@woocommerce/data',
'@woocommerce/experimental',
'@woocommerce/expression-evaluation',
'@woocommerce/navigation',
'@woocommerce/number',
'@woocommerce/settings',
'@woocommerce/tracks',
'@wordpress/blocks',
'@wordpress/block-editor',
'@wordpress/components',
'@wordpress/core-data',
'@wordpress/date',
'@wordpress/element',
'@wordpress/keycodes',
'@wordpress/media-utils',
'@testing-library/react',
'dompurify',
'react-router-dom',
],
'import/resolver': {
node: {},
webpack: {},
typescript: {},
},
},
}; };

View File

@ -11,7 +11,41 @@ module.exports = {
}, },
], ],
settings: { settings: {
'import/core-modules': [
'@woocommerce/ai',
'@woocommerce/admin-layout',
'@woocommerce/components',
'@woocommerce/customer-effort-score',
'@woocommerce/currency',
'@woocommerce/csv-export',
'@woocommerce/data',
'@woocommerce/date',
'@woocommerce/explat',
'@woocommerce/internal-js-tests',
'@woocommerce/navigation',
'@woocommerce/number',
'@woocommerce/onboarding',
'@woocommerce/product-editor',
'@woocommerce/settings',
'@woocommerce/tracks',
'@woocommerce/experimental',
'@wordpress/components',
'@wordpress/core-data',
'@wordpress/element',
'@wordpress/blocks',
'@wordpress/block-editor',
'@wordpress/block-library',
'@wordpress/notices',
'dompurify',
'@react-spring/web',
'react-router-dom',
'redux',
'xstate',
'xstate5',
],
'import/resolver': { 'import/resolver': {
node: {},
webpack: {},
typescript: { typescript: {
project: [ 'plugins/woocommerce-admin/tsconfig.json' ], project: [ 'plugins/woocommerce-admin/tsconfig.json' ],
}, },

View File

@ -17,7 +17,7 @@
"build:project": "pnpm --if-present '/^build:project:.*$/'", "build:project": "pnpm --if-present '/^build:project:.*$/'",
"build:project:bundle": "wireit", "build:project:bundle": "wireit",
"build:project:feature-config": "php ../woocommerce/bin/generate-feature-config.php", "build:project:feature-config": "php ../woocommerce/bin/generate-feature-config.php",
"changelog": "composer install && composer exec -- changelogger", "changelog": "XDEBUG_MODE=off composer install --quiet && composer exec -- changelogger",
"example": "webpack --config docs/examples/extensions/examples.config.js", "example": "webpack --config docs/examples/extensions/examples.config.js",
"lint": "pnpm --if-present '/^lint:lang:.*$/'", "lint": "pnpm --if-present '/^lint:lang:.*$/'",
"lint:fix": "pnpm --if-present '/^lint:fix:lang:.*$/'", "lint:fix": "pnpm --if-present '/^lint:fix:lang:.*$/'",

View File

@ -159,6 +159,7 @@ module.exports = {
'@woocommerce/settings', '@woocommerce/settings',
'@woocommerce/shared-context', '@woocommerce/shared-context',
'@woocommerce/shared-hocs', '@woocommerce/shared-hocs',
'@woocommerce/tracks',
'@woocommerce/data', '@woocommerce/data',
'@wordpress/a11y', '@wordpress/a11y',
'@wordpress/api-fetch', '@wordpress/api-fetch',

View File

@ -45,7 +45,7 @@
"license": "GPL-3.0+", "license": "GPL-3.0+",
"scripts": { "scripts": {
"analyze-bundles": "cross-env WP_BUNDLE_ANALYZER=1 pnpm run build", "analyze-bundles": "cross-env WP_BUNDLE_ANALYZER=1 pnpm run build",
"changelog": "composer install && composer exec -- changelogger", "changelog": "XDEBUG_MODE=off composer install --quiet && composer exec -- changelogger",
"build": "pnpm --if-present --workspace-concurrency=Infinity --stream --filter=\"$npm_package_name...\" '/^build:project:.*$/'", "build": "pnpm --if-present --workspace-concurrency=Infinity --stream --filter=\"$npm_package_name...\" '/^build:project:.*$/'",
"build:project": "pnpm --if-present '/^build:project:.*$/'", "build:project": "pnpm --if-present '/^build:project:.*$/'",
"build:project:bundle": "wireit", "build:project:bundle": "wireit",

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
CI: reduce running time for PHPUnit related jobs.

View File

@ -105,6 +105,7 @@
"tests": [ "tests": [
{ {
"name": "PHP", "name": "PHP",
"testType": "unit:php",
"command": "test:php:env", "command": "test:php:env",
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
@ -128,6 +129,7 @@
}, },
{ {
"name": "PHP 8.0", "name": "PHP 8.0",
"testType": "unit:php",
"command": "test:php:env", "command": "test:php:env",
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
@ -154,6 +156,7 @@
}, },
{ {
"name": "PHP WP: latest - 1", "name": "PHP WP: latest - 1",
"testType": "unit:php",
"command": "test:php:env", "command": "test:php:env",
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
@ -180,6 +183,7 @@
}, },
{ {
"name": "PHP WP: latest - 2", "name": "PHP WP: latest - 2",
"testType": "unit:php",
"command": "test:php:env", "command": "test:php:env",
"changes": [ "changes": [
"client/admin/config/*.json", "client/admin/config/*.json",
@ -206,6 +210,7 @@
}, },
{ {
"name": "PHP WP: nightly", "name": "PHP WP: nightly",
"testType": "unit:php",
"command": "test:php:env", "command": "test:php:env",
"optional": true, "optional": true,
"changes": [ "changes": [

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,13 @@ export const enum JobType {
/** /**
* The type of the test job. * The type of the test job.
*/ */
export const testTypes = [ 'unit', 'e2e', 'api', 'performance' ] as const; export const testTypes = [
'unit:php',
'unit',
'e2e',
'api',
'performance',
] as const;
/** /**
* The variables that can be used in tokens on command strings * The variables that can be used in tokens on command strings

View File

@ -193,6 +193,11 @@ while ( ( $line = fgets( $pipes[1] ) ) ) {
} }
continue; continue;
} }
// Ignore dot-files: those are development related, and it makes no sense to create a changelog entry for them.
if ( '.' === basename( $line )[0] ) {
debug( 'Ignoring changes dot-file %s.', $line );
continue;
}
debug( 'PR touches file %s, marking %s as touched.', $line, $project_match ); debug( 'PR touches file %s, marking %s as touched.', $line, $project_match );
if ( ! isset( $touched_projects[ $project_match ] ) ) { if ( ! isset( $touched_projects[ $project_match ] ) ) {