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

View File

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