2023-12-13 05:33:52 +00:00
|
|
|
name: 'Highlight Template Changes'
|
2023-01-12 01:09:36 +00:00
|
|
|
on:
|
2023-12-13 05:33:52 +00:00
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- 'plugins/woocommerce/**'
|
2024-08-07 11:59:25 +00:00
|
|
|
- '!plugins/woocommerce/templates/templates/**'
|
2022-05-17 01:47:17 +00:00
|
|
|
jobs:
|
2023-12-13 05:33:52 +00:00
|
|
|
analyze:
|
|
|
|
name: 'Analyze Branch Changes'
|
|
|
|
runs-on: 'ubuntu-20.04'
|
|
|
|
outputs:
|
|
|
|
results: ${{ steps.results.outputs.results }}
|
|
|
|
steps:
|
|
|
|
- uses: 'actions/checkout@v3'
|
|
|
|
name: 'Checkout'
|
|
|
|
- uses: './.github/actions/setup-woocommerce-monorepo'
|
|
|
|
name: 'Setup WooCommerce Monorepo'
|
|
|
|
with:
|
|
|
|
install: 'code-analyzer...'
|
|
|
|
build: 'code-analyzer'
|
2024-07-10 12:39:49 +00:00
|
|
|
pull-package-deps: 'code-analyzer'
|
|
|
|
|
2023-12-13 05:33:52 +00:00
|
|
|
- name: 'Analyze'
|
|
|
|
id: 'analyze'
|
|
|
|
working-directory: 'tools/code-analyzer'
|
2024-05-17 13:01:19 +00:00
|
|
|
env:
|
|
|
|
GIT_CLONE_PROTECTION_ACTIVE: false
|
2023-12-13 05:33:52 +00:00
|
|
|
run: |
|
|
|
|
HEAD_REF=$(git rev-parse HEAD)
|
2024-08-07 11:59:25 +00:00
|
|
|
exclude="plugins/woocommerce/tests plugins/woocommerce/templates/templates plugins/woocommerce-admin/tests plugins/woocommerce-blocks/tests"
|
2023-12-13 05:33:52 +00:00
|
|
|
version=$(pnpm analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
|
2024-02-22 19:05:28 +00:00
|
|
|
pnpm analyzer "$HEAD_REF" $version -o "github" -e $exclude
|
2023-12-13 05:33:52 +00:00
|
|
|
- uses: 'actions/github-script@v6'
|
|
|
|
name: 'Validate'
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const template = '${{ steps.analyze.outputs.templates }}';
|
|
|
|
|
|
|
|
if ( template === '' ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const templateArr = template.split( '\n' );
|
|
|
|
const modTemplateArr = [];
|
|
|
|
let needsVersionBump = false;
|
|
|
|
|
|
|
|
templateArr.forEach( ( el ) => {
|
|
|
|
if ( el.match( /NOTICE/ ) ) {
|
|
|
|
modTemplateArr.pop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( el.match( /WARNING/ ) ) {
|
|
|
|
needsVersionBump = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
modTemplateArr.push( el );
|
|
|
|
} );
|
|
|
|
|
|
|
|
const templateResult = modTemplateArr.join( '\n' );
|
|
|
|
|
|
|
|
if ( needsVersionBump ) {
|
|
|
|
core.setFailed( `Templates have changed but template versions were not bumped:\n${ templateResult }` );
|
|
|
|
}
|