Skip to content

Commit 5d201af

Browse files
authored
Run independent deployment steps in parallel (#1156)
1 parent 6b07a52 commit 5d201af

2 files changed

Lines changed: 88 additions & 54 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/deployment.yml‎

Lines changed: 79 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,23 @@ jobs:
4848
echo "CLI_VERSION=$CLI_VERSION" > $GITHUB_ENV
4949
echo "$CLI_VERSION" > cli_version.txt
5050
51-
- name: Upload WP-CLI version
52-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
53-
with:
54-
name: cli_version
55-
path: cli_version.txt
56-
57-
- name: Upload manifest file
58-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
59-
with:
60-
name: manifest
61-
path: vendor/wp-cli/wp-cli/manifest.json
62-
63-
- name: Build the Phar file
64-
run: php -dphar.readonly=0 utils/make-phar.php wp-cli.phar --version=$CLI_VERSION
51+
# The version and manifest uploads do not depend on the Phar, so they run
52+
# alongside the build instead of ahead of it.
53+
- parallel:
54+
- name: Upload WP-CLI version
55+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
56+
with:
57+
name: cli_version
58+
path: cli_version.txt
59+
60+
- name: Upload manifest file
61+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
62+
with:
63+
name: manifest
64+
path: vendor/wp-cli/wp-cli/manifest.json
65+
66+
- name: Build the Phar file
67+
run: php -dphar.readonly=0 utils/make-phar.php wp-cli.phar --version=$CLI_VERSION
6568

6669
- name: Upload built Phar file
6770
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
@@ -112,6 +115,29 @@ jobs:
112115
- name: Check out source code
113116
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
114117

118+
# Neither the database server nor the built Phar is needed until the tests
119+
# are prepared, so fetch both in the background while PHP and the Composer
120+
# dependencies are set up. The MySQL action only downloads its own
121+
# binaries, so it cannot contend with apt.
122+
- name: Setup MySQL Server
123+
id: setup-mysql
124+
background: true
125+
uses: shogo82148/actions-setup-mysql@334a29f22d90428932f75b11e0d5fcc00bb6b4f4 # v1
126+
with:
127+
mysql-version: ${{ matrix.mysql }}
128+
auto-start: true
129+
root-password: root
130+
user: wp_cli_test
131+
password: password1
132+
my-cnf: |
133+
default_authentication_plugin=mysql_native_password
134+
135+
- name: Download built Phar file
136+
background: true
137+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
138+
with:
139+
name: wp-cli-phar
140+
115141
- name: Install Ghostscript
116142
timeout-minutes: 10
117143
run: |
@@ -140,29 +166,15 @@ jobs:
140166
run: |
141167
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
142168
143-
- name: Download built Phar file
144-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
145-
with:
146-
name: wp-cli-phar
169+
- name: Wait for the MySQL server and the Phar download
170+
wait-all:
147171

148172
- name: Prepare built Phar file for Behat tests
149173
run: |
150174
mkdir -p $WP_CLI_BIN_DIR
151175
mv wp-cli.phar $WP_CLI_BIN_DIR/wp
152176
chmod +x $WP_CLI_BIN_DIR/wp
153177
154-
- name: Setup MySQL Server
155-
id: setup-mysql
156-
uses: shogo82148/actions-setup-mysql@334a29f22d90428932f75b11e0d5fcc00bb6b4f4 # v1
157-
with:
158-
mysql-version: ${{ matrix.mysql }}
159-
auto-start: true
160-
root-password: root
161-
user: wp_cli_test
162-
password: password1
163-
my-cnf: |
164-
default_authentication_plugin=mysql_native_password
165-
166178
- name: Configure DB environment
167179
run: |
168180
echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV
@@ -198,25 +210,26 @@ jobs:
198210
repository: wp-cli/builds
199211
token: ${{ secrets.ACTIONS_BOT }}
200212

201-
- name: Download WP-CLI version
202-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
203-
with:
204-
name: cli_version
213+
- parallel:
214+
- name: Download WP-CLI version
215+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
216+
with:
217+
name: cli_version
218+
219+
- name: Download manifest file
220+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
221+
with:
222+
name: manifest
223+
224+
- name: Download built Phar file
225+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
226+
with:
227+
name: wp-cli-phar
205228

206229
- name: Set new nightly version
207230
run: |
208231
cat cli_version.txt > phar/NIGHTLY_VERSION
209232
210-
- name: Download manifest file
211-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
212-
with:
213-
name: manifest
214-
215-
- name: Download built Phar file
216-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
217-
with:
218-
name: wp-cli-phar
219-
220233
- name: Set file name for release branch
221234
if: ${{ contains(github.ref, 'release') }}
222235
run: |
@@ -267,6 +280,14 @@ jobs:
267280
needs: [deploy]
268281

269282
steps:
283+
# The RPM tooling comes from apt, which is slow and independent of the
284+
# checkouts and the Phar download, so install it in the background.
285+
- name: Install RPM build tooling
286+
background: true
287+
run: |
288+
sudo apt-get update
289+
sudo apt-get install rpm rpmlint -y
290+
270291
- name: Check out builds repository
271292
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
272293
with:
@@ -286,16 +307,14 @@ jobs:
286307
with:
287308
name: wp-cli-phar
288309

289-
- name: Install RPM build tooling
290-
run: |
291-
sudo apt-get update
292-
sudo apt-get install rpm rpmlint -y
293-
294310
- name: Copy RPM build configuration
295311
run: |
296312
cp bundle/utils/wp-cli-rpm.spec .
297313
cp bundle/utils/wp-cli-updaterpm.sh .
298314
315+
- name: Wait for the RPM build tooling
316+
wait-all:
317+
299318
- name: Build RPM package
300319
run: |
301320
bash wp-cli-updaterpm.sh
@@ -356,6 +375,14 @@ jobs:
356375
needs: [build-rpm]
357376

358377
steps:
378+
# The DEB tooling comes from apt, which is slow and independent of the
379+
# checkouts and the Phar download, so install it in the background.
380+
- name: Install DEB build tooling
381+
background: true
382+
run: |
383+
sudo apt-get update
384+
sudo apt-get install fakeroot lintian -y
385+
359386
- name: Check out builds repository
360387
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
361388
with:
@@ -375,15 +402,13 @@ jobs:
375402
with:
376403
name: wp-cli-phar
377404

378-
- name: Install DEB build tooling
379-
run: |
380-
sudo apt-get update
381-
sudo apt-get install fakeroot lintian -y
382-
383405
- name: Copy DEB build configuration
384406
run: |
385407
cp bundle/utils/wp-cli-updatedeb.sh .
386408
409+
- name: Wait for the DEB build tooling
410+
wait-all:
411+
387412
- name: Build DEB package
388413
run: |
389414
bash wp-cli-updatedeb.sh

0 commit comments

Comments
 (0)