Skip to content

Commit 8624529

Browse files
committed
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
1 parent 585f62a commit 8624529

6 files changed

Lines changed: 42 additions & 40 deletions

File tree

.github/workflows/coding-standards.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ on:
3434
- '.github/workflows/*.yml'
3535
workflow_dispatch:
3636

37+
# Cancels all previous workflow runs for pull requests that have not completed.
38+
concurrency:
39+
# The concurrency group contains the workflow name and the branch name for pull requests
40+
# or the commit hash for any other events.
41+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
42+
cancel-in-progress: true
43+
3744
jobs:
3845
# Runs PHP coding standards checks.
3946
#

.github/workflows/end-to-end-tests.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ on:
1919
- '[6-9].[0-9]'
2020
workflow_dispatch:
2121

22+
# Cancels all previous workflow runs for pull requests that have not completed.
23+
concurrency:
24+
# The concurrency group contains the workflow name and the branch name for pull requests
25+
# or the commit hash for any other events.
26+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
27+
cancel-in-progress: true
28+
2229
env:
2330
LOCAL_DIR: build
2431

2532
jobs:
2633
# Runs the end-to-end test suite.
2734
#
2835
# Performs the following steps:
29-
# - Cancels all previous workflow runs for pull requests that have not completed.
3036
# - Set environment variables.
3137
# - Checks out the repository.
3238
# - Logs debug information about the runner container.
@@ -47,10 +53,6 @@ jobs:
4753
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
4854

4955
steps:
50-
- name: Cancel previous runs of this workflow (pull requests only)
51-
if: ${{ github.event_name == 'pull_request' }}
52-
uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0
53-
5456
- name: Configure environment variables
5557
run: |
5658
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV

.github/workflows/javascript-tests.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,17 @@ on:
3232
- '.github/workflows/*.yml'
3333
workflow_dispatch:
3434

35+
# Cancels all previous workflow runs for pull requests that have not completed.
36+
concurrency:
37+
# The concurrency group contains the workflow name and the branch name for pull requests
38+
# or the commit hash for any other events.
39+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
40+
cancel-in-progress: true
41+
3542
jobs:
3643
# Runs the QUnit tests for WordPress.
3744
#
3845
# Performs the following steps:
39-
# - Cancels all previous workflow runs for pull requests that have not completed.
4046
# - Checks out the repository.
4147
# - Logs debug information about the runner container.
4248
# - Installs NodeJS 14.
@@ -51,10 +57,6 @@ jobs:
5157
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
5258

5359
steps:
54-
- name: Cancel previous runs of this workflow (pull requests only)
55-
if: ${{ github.event_name == 'pull_request' }}
56-
uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0
57-
5860
- name: Checkout repository
5961
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
6062

.github/workflows/php-compatibility.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ on:
2828
- '.github/workflows/*.yml'
2929
workflow_dispatch:
3030

31+
# Cancels all previous workflow runs for pull requests that have not completed.
32+
concurrency:
33+
# The concurrency group contains the workflow name and the branch name for pull requests
34+
# or the commit hash for any other events.
35+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
36+
cancel-in-progress: true
37+
3138
jobs:
3239

3340
# Runs PHP compatibility testing.

.github/workflows/phpunit-tests.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ on:
2121
schedule:
2222
- cron: '0 0 * * 0'
2323

24+
# Cancels all previous workflow runs for pull requests that have not completed.
25+
concurrency:
26+
# The concurrency group contains the workflow name and the branch name for pull requests
27+
# or the commit hash for any other events.
28+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
29+
cancel-in-progress: true
30+
2431
env:
2532
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
2633
COMPOSER_INSTALL: ${{ false }}
@@ -30,20 +37,6 @@ env:
3037
SLOW_TESTS: 'external-http,media,restapi'
3138

3239
jobs:
33-
# Sets up the workflow for testing.
34-
#
35-
# Performs the following steps:
36-
# - Cancels all previous workflow runs for pull requests that have not completed.
37-
setup-workflow:
38-
name: Setup Workflow
39-
runs-on: ubuntu-latest
40-
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
41-
42-
steps:
43-
- name: Cancel previous runs of this workflow (pull requests only)
44-
if: ${{ github.event_name == 'pull_request' }}
45-
uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0
46-
4740
# Runs the PHPUnit tests for WordPress.
4841
#
4942
# Performs the following steps:

.github/workflows/test-npm.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,17 @@ on:
2525
- '.github/workflows/**.yml'
2626
workflow_dispatch:
2727

28+
# Cancels all previous workflow runs for pull requests that have not completed.
29+
concurrency:
30+
# The concurrency group contains the workflow name and the branch name for pull requests
31+
# or the commit hash for any other events.
32+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
33+
cancel-in-progress: true
34+
2835
env:
2936
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
3037

3138
jobs:
32-
# Prepares the workflow.
33-
#
34-
# Performs the following steps:
35-
# - Cancels all previous workflow runs for pull requests that have not completed.
36-
prepare-workflow:
37-
name: Prepare the workflow
38-
runs-on: ubuntu-latest
39-
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
40-
41-
steps:
42-
- name: Cancel previous runs of this workflow (pull requests only)
43-
if: ${{ github.event_name == 'pull_request' }}
44-
uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0
45-
4639
# Verifies that installing NPM dependencies and building WordPress works as expected.
4740
#
4841
# Performs the following steps:
@@ -59,7 +52,6 @@ jobs:
5952
name: Test NPM on ${{ matrix.os }}
6053
runs-on: ${{ matrix.os }}
6154
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
62-
needs: prepare-workflow
6355
strategy:
6456
fail-fast: false
6557
matrix:
@@ -134,7 +126,6 @@ jobs:
134126
name: Test NPM on MacOS
135127
runs-on: macos-latest
136128
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
137-
needs: prepare-workflow
138129
steps:
139130
- name: Checkout repository
140131
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4

0 commit comments

Comments
 (0)