From be290984b9e0d7228b2985022ceb7e7362094493 Mon Sep 17 00:00:00 2001 From: Christopher Allford <6451942+ObliviousHarmony@users.noreply.github.com> Date: Tue, 12 Dec 2023 21:33:52 -0800 Subject: [PATCH] `setup-woocommerce-monorepo` Action in Highlight Changes Workflow (#42740) --- .github/workflows/ci.yml | 6 +- .github/workflows/pr-highlight-changes.yml | 104 ++++++++++----------- plugins/woocommerce/woocommerce.php | 2 + 3 files changed, 54 insertions(+), 58 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa94a7df058..47a4d143c16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }}' diff --git a/.github/workflows/pr-highlight-changes.yml b/.github/workflows/pr-highlight-changes.yml index c2dea8419c1..518f183d91b 100644 --- a/.github/workflows/pr-highlight-changes.yml +++ b/.github/workflows/pr-highlight-changes.yml @@ -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 }` ); + } diff --git a/plugins/woocommerce/woocommerce.php b/plugins/woocommerce/woocommerce.php index 6fc6ad5eaa2..989072719b4 100644 --- a/plugins/woocommerce/woocommerce.php +++ b/plugins/woocommerce/woocommerce.php @@ -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';