From 862452984ee65f712cb341c33f2226985f901c18 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 19 May 2021 17:36:54 +0000 Subject: [PATCH] Build/Test Tools: Use the new `concurrency` setting for GitHub Actions. The new `concurrency` setting can be used to ensure only a single workflow run or job is in progress. When used in combination with the `cancel-in-progress` setting, incomplete workflow runs can be cancelled automatically to prevent running workflows unnecessarily. The workflows that take longer to run previously had this built into a step and utilized a 3rd-party action. Now that this is natively supported by GitHub Actions, using that is preferred. This option is currently in beta, but is stable enough to use in our workflows for the time being. Props ocean90. Fixes #53080. git-svn-id: https://develop.svn.wordpress.org/trunk@50930 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/coding-standards.yml | 7 +++++++ .github/workflows/end-to-end-tests.yml | 12 +++++++----- .github/workflows/javascript-tests.yml | 12 +++++++----- .github/workflows/php-compatibility.yml | 7 +++++++ .github/workflows/phpunit-tests.yml | 21 +++++++-------------- .github/workflows/test-npm.yml | 23 +++++++---------------- 6 files changed, 42 insertions(+), 40 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index ad81be3290..7f04b14183 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -34,6 +34,13 @@ on: - '.github/workflows/*.yml' workflow_dispatch: +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: # Runs PHP coding standards checks. # diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index 0a59c51a4c..2be14d9a2c 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -19,6 +19,13 @@ on: - '[6-9].[0-9]' workflow_dispatch: +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + env: LOCAL_DIR: build @@ -26,7 +33,6 @@ jobs: # Runs the end-to-end test suite. # # Performs the following steps: - # - Cancels all previous workflow runs for pull requests that have not completed. # - Set environment variables. # - Checks out the repository. # - Logs debug information about the runner container. @@ -47,10 +53,6 @@ jobs: if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} steps: - - name: Cancel previous runs of this workflow (pull requests only) - if: ${{ github.event_name == 'pull_request' }} - uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0 - - name: Configure environment variables run: | echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index 0bf9f5a461..335812b61f 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -32,11 +32,17 @@ on: - '.github/workflows/*.yml' workflow_dispatch: +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: # Runs the QUnit tests for WordPress. # # Performs the following steps: - # - Cancels all previous workflow runs for pull requests that have not completed. # - Checks out the repository. # - Logs debug information about the runner container. # - Installs NodeJS 14. @@ -51,10 +57,6 @@ jobs: if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} steps: - - name: Cancel previous runs of this workflow (pull requests only) - if: ${{ github.event_name == 'pull_request' }} - uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0 - - name: Checkout repository uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index 78b63abccf..b7c35fdd9f 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -28,6 +28,13 @@ on: - '.github/workflows/*.yml' workflow_dispatch: +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + jobs: # Runs PHP compatibility testing. diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 926ff6e94d..1fd865823f 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -21,6 +21,13 @@ on: schedule: - cron: '0 0 * * 0' +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} COMPOSER_INSTALL: ${{ false }} @@ -30,20 +37,6 @@ env: SLOW_TESTS: 'external-http,media,restapi' jobs: - # Sets up the workflow for testing. - # - # Performs the following steps: - # - Cancels all previous workflow runs for pull requests that have not completed. - setup-workflow: - name: Setup Workflow - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - - steps: - - name: Cancel previous runs of this workflow (pull requests only) - if: ${{ github.event_name == 'pull_request' }} - uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0 - # Runs the PHPUnit tests for WordPress. # # Performs the following steps: diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index ceefcdbb5d..ce16cb2815 100644 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -25,24 +25,17 @@ on: - '.github/workflows/**.yml' workflow_dispatch: +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} jobs: - # Prepares the workflow. - # - # Performs the following steps: - # - Cancels all previous workflow runs for pull requests that have not completed. - prepare-workflow: - name: Prepare the workflow - runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - - steps: - - name: Cancel previous runs of this workflow (pull requests only) - if: ${{ github.event_name == 'pull_request' }} - uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0 - # Verifies that installing NPM dependencies and building WordPress works as expected. # # Performs the following steps: @@ -59,7 +52,6 @@ jobs: name: Test NPM on ${{ matrix.os }} runs-on: ${{ matrix.os }} if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} - needs: prepare-workflow strategy: fail-fast: false matrix: @@ -134,7 +126,6 @@ jobs: name: Test NPM on MacOS runs-on: macos-latest if: ${{ github.repository == 'WordPress/wordpress-develop' }} - needs: prepare-workflow steps: - name: Checkout repository uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4