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
This commit is contained in:
Jonathan Desrosiers 2021-05-19 17:36:54 +00:00
parent 585f62ad8c
commit 862452984e
6 changed files with 42 additions and 40 deletions

View File

@ -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.
#

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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:

View File

@ -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