`setup-woocommerce-monorepo` Action in Highlight Changes Workflow (#42740)

This commit is contained in:
Christopher Allford 2023-12-12 21:33:52 -08:00 committed by GitHub
parent ec9b7852f9
commit be290984b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 58 deletions

View File

@ -24,12 +24,12 @@ jobs:
with:
fetch-depth: 0
- uses: './.github/actions/setup-woocommerce-monorepo'
name: 'Setup Monorepo'
with:
php-version: false # We don't want to waste time installing PHP since we aren't using it in this job.
name: 'Setup Monorepo'
- uses: actions/github-script@v6
id: 'project-matrix'
name: 'Build Matrix'
id: 'project-matrix'
with:
script: |
let baseRef = ${{ toJson( github.base_ref ) }};
@ -56,8 +56,8 @@ jobs:
with:
fetch-depth: 0
- uses: './.github/actions/setup-woocommerce-monorepo'
id: 'setup-monorepo'
name: 'Setup Monorepo'
id: 'setup-monorepo'
with:
install: '${{ matrix.projectName }}...'
build: '${{ matrix.projectName }}'

View File

@ -1,64 +1,58 @@
name: Highlight templates changes
name: 'Highlight Template Changes'
on:
pull_request:
paths-ignore:
- '**/changelog/**'
permissions: {}
pull_request:
paths:
- 'plugins/woocommerce/**'
jobs:
analyze:
if: ${{ github.event.pull_request.user.login != 'github-actions[bot]' }}
name: Check pull request changes to highlight
runs-on: ubuntu-20.04
permissions:
contents: read
outputs:
results: ${{ steps.results.outputs.results }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install prerequisites
run: |
npm install -g pnpm
npm -g i @wordpress/env@8.0.0
pnpm install --filter code-analyzer --filter monorepo-utils
- name: Run analyzer
id: run
working-directory: tools/code-analyzer
run: |
HEAD_REF=$(git rev-parse HEAD)
version=$(pnpm analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
pnpm analyzer "$HEAD_REF" $version -o "github"
- name: Check results
uses: actions/github-script@v6
with:
script: |
const template = '${{ steps.run.outputs.templates }}';
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'
- name: 'Analyze'
id: 'analyze'
working-directory: 'tools/code-analyzer'
run: |
HEAD_REF=$(git rev-parse HEAD)
version=$(pnpm analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
pnpm analyzer "$HEAD_REF" $version -o "github"
- uses: 'actions/github-script@v6'
name: 'Validate'
with:
script: |
const template = '${{ steps.analyze.outputs.templates }}';
if ( template === '' ) {
return;
}
if ( template === '' ) {
return;
}
const templateArr = template.split( '\n' );
const modTemplateArr = [];
let needsVersionBump = false;
const templateArr = template.split( '\n' );
const modTemplateArr = [];
let needsVersionBump = false;
templateArr.forEach( ( el ) => {
if ( el.match( /NOTICE/ ) ) {
modTemplateArr.pop();
return;
}
templateArr.forEach( ( el ) => {
if ( el.match( /NOTICE/ ) ) {
modTemplateArr.pop();
return;
}
if ( el.match( /WARNING/ ) ) {
needsVersionBump = true;
}
if ( el.match( /WARNING/ ) ) {
needsVersionBump = true;
}
modTemplateArr.push( el );
} );
modTemplateArr.push( el );
} );
const templateResult = modTemplateArr.join( '\n' );
const templateResult = modTemplateArr.join( '\n' );
if ( needsVersionBump ) {
core.setFailed( `Templates have changed but template versions were not bumped:\n${ templateResult }` );
}
if ( needsVersionBump ) {
core.setFailed( `Templates have changed but template versions were not bumped:\n${ templateResult }` );
}

View File

@ -24,6 +24,8 @@ if ( ! defined( 'WC_BLOCKS_IS_FEATURE_PLUGIN' ) ) {
define( 'WC_BLOCKS_IS_FEATURE_PLUGIN', true );
}
// Test Change
// Load core packages and the autoloader.
require __DIR__ . '/src/Autoloader.php';
require __DIR__ . '/src/Packages.php';