Skip to content

Commit 81bb17a

Browse files
committed
Run independent workflow steps in parallel
Use the new background/wait-all step keywords so slow, independent setup runs alongside the PHP and Composer setup: - reusable-functional: start MySQL (and the Windows Chocolatey install) in the background, wait right before the test database is prepared. - copilot-setup-steps: start MySQL in the background. - reusable-code-quality: set up Node in the background for Gherkin lint. - reusable-issue-triage: fetch labels/item details while Node and the Copilot CLI are installed. actionlint does not know these keywords yet, so ignore the two errors it reports for them until it does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XKUgMbWCUXHvDzgDBPWcZA
1 parent 9f22972 commit 81bb17a

5 files changed

Lines changed: 97 additions & 45 deletions

File tree

‎.github/actionlint.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ paths:
1111
# catching genuine typos in permission names.
1212
# See https://docs.github.com/en/copilot/how-tos/copilot-cli/use-copilot-cli-in-actions
1313
- 'unknown permission scope "copilot-requests"'
14+
# Steps can run in parallel through the `background`, `wait`, `wait-all`,
15+
# `cancel` and `parallel` keywords, but actionlint does not know them yet:
16+
# it rejects `background` as an unexpected key, and a `wait-all` or
17+
# `parallel` step as one that has neither `run` nor `uses`. Drop these
18+
# entries once actionlint supports the keywords. Until then, a step that is
19+
# genuinely missing both `run` and `uses` is no longer reported.
20+
# See https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsparallel
21+
- 'unexpected key "background" for step'
22+
- 'step must run script with "run" section or run action with "uses" section'

‎.github/workflows/copilot-setup-steps.yml‎

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,27 @@ jobs:
3939
id: check_composer_file
4040
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
4141

42+
# Without a database the Behat runner silently falls back to SQLite, so the
43+
# agent's test runs are not the ones CI will do. Mirrors the setup in
44+
# reusable-functional.yml.
45+
- name: Check existence of behat.yml file
46+
id: check_behat_file
47+
run: echo "files_exists=$(test -f behat.yml && echo true || echo false)" >> "$GITHUB_OUTPUT"
48+
49+
# Downloading and starting the database server is the slowest part of the
50+
# setup and it is independent of PHP and Composer, so it runs in the
51+
# background and is waited for right before the test database is prepared.
52+
- name: Setup MySQL Server
53+
if: steps.check_behat_file.outputs.files_exists == 'true'
54+
background: true
55+
uses: shogo82148/actions-setup-mysql@334a29f22d90428932f75b11e0d5fcc00bb6b4f4 # v1
56+
with:
57+
mysql-version: '8.0' # Standard MySQL version for these tests
58+
auto-start: true
59+
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
60+
user: ${{ env.WP_CLI_TEST_DBUSER }}
61+
password: ${{ env.WP_CLI_TEST_DBPASS }}
62+
4263
- name: Set up PHP environment
4364
if: steps.check_composer_file.outputs.files_exists == 'true'
4465
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
@@ -56,22 +77,8 @@ jobs:
5677
env:
5778
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
5879

59-
# Without a database the Behat runner silently falls back to SQLite, so the
60-
# agent's test runs are not the ones CI will do. Mirrors the setup in
61-
# reusable-functional.yml.
62-
- name: Check existence of behat.yml file
63-
id: check_behat_file
64-
run: echo "files_exists=$(test -f behat.yml && echo true || echo false)" >> "$GITHUB_OUTPUT"
65-
66-
- name: Setup MySQL Server
67-
if: steps.check_behat_file.outputs.files_exists == 'true'
68-
uses: shogo82148/actions-setup-mysql@334a29f22d90428932f75b11e0d5fcc00bb6b4f4 # v1
69-
with:
70-
mysql-version: '8.0' # Standard MySQL version for these tests
71-
auto-start: true
72-
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
73-
user: ${{ env.WP_CLI_TEST_DBUSER }}
74-
password: ${{ env.WP_CLI_TEST_DBPASS }}
80+
- name: Wait for the MySQL server
81+
wait-all:
7582

7683
- name: Remove system MySQL binary
7784
if: steps.check_behat_file.outputs.files_exists == 'true'

‎.github/workflows/reusable-code-quality.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ jobs:
121121
persist-credentials: false
122122
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
123123

124+
# Node is only needed by the linter itself, so set it up while PHP and the
125+
# Composer dependencies are installed.
124126
- name: Setup node
127+
background: true
125128
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
126129
with:
127130
node-version: 'lts/*'
@@ -153,6 +156,9 @@ jobs:
153156
env:
154157
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
155158

159+
- name: Wait for Node to be set up
160+
wait-all:
161+
156162
- name: Check existence of vendor/bin/run-gherkin-lint-tests file
157163
id: check_linter_file
158164
run: echo "files_exists=$(test -f vendor/bin/run-gherkin-lint-tests && composer run-script --list 2>/dev/null | grep -q 'lint-gherkin' && echo true || echo false)" >> "$GITHUB_OUTPUT"

‎.github/workflows/reusable-functional.yml‎

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,45 @@ jobs:
9090
persist-credentials: false
9191
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
9292

93+
# MySQL 8.4 requires explicit loading of mysql_native_password plugin
94+
- name: Determine MySQL authentication configuration
95+
id: mysql-config
96+
if: ${{ inputs.dbtype != 'sqlite' && inputs.mysql == 'mysql-8.4' }}
97+
run: |
98+
echo "auth-config<<EOF" >> $GITHUB_OUTPUT
99+
echo "mysql_native_password=ON" >> $GITHUB_OUTPUT
100+
echo "authentication_policy=mysql_native_password," >> $GITHUB_OUTPUT
101+
echo "EOF" >> $GITHUB_OUTPUT
102+
103+
# Downloading and starting the database server is the slowest part of the
104+
# setup, and nothing needs it until the test database is prepared. Run it
105+
# in the background alongside the PHP and Composer setup below, and wait
106+
# for it right before it is first used. The action only downloads its own
107+
# binaries, so it cannot contend with apt, Homebrew or Chocolatey.
108+
- name: Setup MySQL Server
109+
id: setup-mysql
110+
if: ${{ inputs.dbtype != 'sqlite' }}
111+
background: true
112+
uses: shogo82148/actions-setup-mysql@334a29f22d90428932f75b11e0d5fcc00bb6b4f4 # v1
113+
with:
114+
mysql-version: ${{ inputs.mysql }}
115+
auto-start: true
116+
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
117+
user: ${{ env.WP_CLI_TEST_DBUSER}}
118+
password: ${{ env.WP_CLI_TEST_DBPASS}}
119+
# Fall back to legacy configuration for MySQL 5.6, 5.7, 8.0 and MariaDB.
120+
my-cnf: |
121+
${{ steps.mysql-config.outputs.auth-config || 'default_authentication_plugin=mysql_native_password' }}
122+
${{ inputs.dbtype == 'mariadb' && '[client]' || '' }}
123+
${{ inputs.dbtype == 'mariadb' && 'disable-ssl-verify-server-cert' || '' }}
124+
125+
# Chocolatey is slow and these packages are only needed by the Behat run
126+
# itself, so let it install them while PHP and Composer are set up.
127+
- name: Install dependencies (Windows)
128+
if: ${{ startsWith(inputs.os, 'windows') }}
129+
background: true
130+
run: choco install sqlite ghostscript --yes
131+
93132
# Ghostscript ships with the GitHub-hosted images, so the `apt-get update`
94133
# this used to run unconditionally cost every Behat leg ~25s for a package
95134
# that was already there. Keep the install as a fallback in case a future
@@ -107,10 +146,6 @@ jobs:
107146
sudo apt-get update
108147
sudo apt-get install ghostscript -y
109148
110-
- name: Install dependencies (Windows)
111-
if: ${{ startsWith(inputs.os, 'windows') }}
112-
run: choco install sqlite ghostscript --yes
113-
114149
- name: Install dependencies (macOS)
115150
if: ${{ startsWith(inputs.os, 'macos') }}
116151
run: |
@@ -160,31 +195,11 @@ jobs:
160195
env:
161196
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
162197

163-
# MySQL 8.4 requires explicit loading of mysql_native_password plugin
164-
- name: Determine MySQL authentication configuration
165-
id: mysql-config
166-
if: ${{ inputs.dbtype != 'sqlite' && inputs.mysql == 'mysql-8.4' }}
167-
run: |
168-
echo "auth-config<<EOF" >> $GITHUB_OUTPUT
169-
echo "mysql_native_password=ON" >> $GITHUB_OUTPUT
170-
echo "authentication_policy=mysql_native_password," >> $GITHUB_OUTPUT
171-
echo "EOF" >> $GITHUB_OUTPUT
172-
173-
- name: Setup MySQL Server
174-
id: setup-mysql
175-
if: ${{ inputs.dbtype != 'sqlite' }}
176-
uses: shogo82148/actions-setup-mysql@334a29f22d90428932f75b11e0d5fcc00bb6b4f4 # v1
177-
with:
178-
mysql-version: ${{ inputs.mysql }}
179-
auto-start: true
180-
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
181-
user: ${{ env.WP_CLI_TEST_DBUSER}}
182-
password: ${{ env.WP_CLI_TEST_DBPASS}}
183-
# Fall back to legacy configuration for MySQL 5.6, 5.7, 8.0 and MariaDB.
184-
my-cnf: |
185-
${{ steps.mysql-config.outputs.auth-config || 'default_authentication_plugin=mysql_native_password' }}
186-
${{ inputs.dbtype == 'mariadb' && '[client]' || '' }}
187-
${{ inputs.dbtype == 'mariadb' && 'disable-ssl-verify-server-cert' || '' }}
198+
# Waits for the database server and the Windows dependencies. `wait-all`
199+
# rather than `wait: setup-mysql`, as either background step may have been
200+
# skipped by its condition. A failure in either fails the job here.
201+
- name: Wait for background setup steps
202+
wait-all:
188203

189204
- name: Remove system MySQL binary
190205
if: ${{ inputs.dbtype != 'sqlite' && !startsWith(inputs.os, 'windows') && !startsWith(inputs.os, 'macos') }}

‎.github/workflows/reusable-issue-triage.yml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
# ends of the list can never match the allowlist.
4949
- name: Get available labels
5050
id: get-labels
51+
background: true
5152
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
5253
with:
5354
result-encoding: string
@@ -63,6 +64,9 @@ jobs:
6364
const labelNames = labels.map(label => label.name);
6465
return labelNames.join(', ');
6566
67+
# The lookups above run in the background while Node and the Copilot CLI
68+
# are installed below; they are waited for before their outputs are used.
69+
#
6670
# The Copilot CLI is not preinstalled on GitHub-hosted runners, and
6771
# `actions/ai-inference` v3 only shells out to it - it never installs it.
6872
- name: Set up Node.js
@@ -79,6 +83,9 @@ jobs:
7983
- name: Install Copilot CLI
8084
run: npm install -g @github/copilot
8185

86+
- name: Wait for the GitHub API lookups
87+
wait-all:
88+
8289
- name: Analyze with AI
8390
id: ai-triage
8491
uses: actions/ai-inference@2c43c91ae16266ca159d311430343c67a5ffa222 # v3
@@ -343,6 +350,7 @@ jobs:
343350
# ends of the list can never match the allowlist.
344351
- name: Get available labels
345352
id: get-labels
353+
background: true
346354
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
347355
with:
348356
result-encoding: string
@@ -360,6 +368,7 @@ jobs:
360368
361369
- name: Get item details
362370
id: get-item
371+
background: true
363372
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
364373
env:
365374
# This job only ever runs on `workflow_dispatch`, and that payload
@@ -387,6 +396,9 @@ jobs:
387396
type: itemType
388397
};
389398
399+
# The lookups above run in the background while Node and the Copilot CLI
400+
# are installed below; they are waited for before their outputs are used.
401+
#
390402
# The Copilot CLI is not preinstalled on GitHub-hosted runners, and
391403
# `actions/ai-inference` v3 only shells out to it - it never installs it.
392404
- name: Set up Node.js
@@ -403,6 +415,9 @@ jobs:
403415
- name: Install Copilot CLI
404416
run: npm install -g @github/copilot
405417

418+
- name: Wait for the GitHub API lookups
419+
wait-all:
420+
406421
- name: Analyze with AI
407422
id: ai-triage
408423
uses: actions/ai-inference@2c43c91ae16266ca159d311430343c67a5ffa222 # v3

0 commit comments

Comments
 (0)