Skip to content

Commit

Permalink
Build/Test Tools: Use the new concurrency setting for GitHub Actions.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
desrosj committed May 19, 2021
1 parent 585f62a commit 8624529
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 40 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ 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

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.
Expand All @@ -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
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/javascript-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 7 additions & 14 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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:
Expand Down
23 changes: 7 additions & 16 deletions .github/workflows/test-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8624529

Please sign in to comment.