Skip to content

Commit f44fda7

Browse files
authored
Merge branch 'main' into main
2 parents cb8fdea + 8475849 commit f44fda7

16 files changed

Lines changed: 1153 additions & 691 deletions

‎.github/dependabot.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ updates:
77
open-pull-requests-limit: 10
88
labels:
99
- scope:distribution
10+
cooldown:
11+
default-days: 7
1012
- package-ecosystem: github-actions
1113
directory: "/"
1214
schedule:
1315
interval: daily
1416
open-pull-requests-limit: 10
1517
labels:
1618
- scope:distribution
19+
cooldown:
20+
default-days: 7
1721

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@ on:
99
paths:
1010
- .github/workflows/copilot-setup-steps.yml
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
copilot-setup-steps:
17+
name: Setup environment
1418
runs-on: ubuntu-latest
1519
permissions:
1620
contents: read
1721

1822
steps:
1923
- name: Checkout code
20-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
24+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25+
with:
26+
persist-credentials: false
2127

2228
- name: Check existence of composer.json file
2329
id: check_composer_file
2430
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
2531

2632
- name: Set up PHP environment
2733
if: steps.check_composer_file.outputs.files_exists == 'true'
28-
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
34+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
2935
with:
3036
php-version: 'latest'
3137
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -36,6 +42,6 @@ jobs:
3642

3743
- name: Install Composer dependencies & cache dependencies
3844
if: steps.check_composer_file.outputs.files_exists == 'true'
39-
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4
45+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
4046
env:
4147
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}

‎.github/workflows/deployment.yml‎

Lines changed: 104 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
if: ${{ github.repository_owner == 'wp-cli' }}
1717
steps:
1818
- name: Check out source code
19-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
19+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2020

2121
- name: Set up PHP environment
22-
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
22+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
2323
with:
2424
php-version: 'latest'
2525
extensions: mysql, zip, imagick
@@ -74,7 +74,7 @@ jobs:
7474
strategy:
7575
fail-fast: false
7676
matrix:
77-
php: ['7.2', '7.3', '7.4', '8.5']
77+
php: ['8.5', '7.4']
7878
wp: ['latest']
7979
mysql: ['8.0']
8080
include:
@@ -99,6 +99,9 @@ jobs:
9999
- php: '7.2'
100100
wp: '4.9'
101101
mysql: '5.6'
102+
- php: '7.2'
103+
wp: '6.9'
104+
mysql: '8.0'
102105
runs-on: ubuntu-22.04
103106
env:
104107
WP_CLI_BIN_DIR: /tmp/wp-cli-phar
@@ -107,15 +110,15 @@ jobs:
107110
if: ${{ github.repository_owner == 'wp-cli' }}
108111
steps:
109112
- name: Check out source code
110-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
113+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
111114

112115
- name: Install Ghostscript
113116
run: |
114117
sudo apt-get update
115118
sudo apt-get install ghostscript -y
116119
117120
- name: Set up PHP environment
118-
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
121+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
119122
with:
120123
php-version: '${{ matrix.php }}'
121124
extensions: imagick, mysql, zip
@@ -137,7 +140,7 @@ jobs:
137140
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
138141
139142
- name: Download built Phar file
140-
uses: actions/download-artifact@v8
143+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
141144
with:
142145
name: wp-cli-phar
143146

@@ -149,7 +152,7 @@ jobs:
149152
150153
- name: Setup MySQL Server
151154
id: setup-mysql
152-
uses: shogo82148/actions-setup-mysql@840178c12b07a58353c6312be784c23b63756eea # v1
155+
uses: shogo82148/actions-setup-mysql@3dcedf762c5e82d781a9e414462785b30208e79c # v1
153156
with:
154157
mysql-version: ${{ matrix.mysql }}
155158
auto-start: true
@@ -189,13 +192,13 @@ jobs:
189192
if: ${{ github.repository_owner == 'wp-cli' && github.event_name != 'workflow_dispatch' }}
190193
steps:
191194
- name: Check out builds repository
192-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
195+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
193196
with:
194197
repository: wp-cli/builds
195198
token: ${{ secrets.ACTIONS_BOT }}
196199

197200
- name: Download WP-CLI version
198-
uses: actions/download-artifact@v8
201+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
199202
with:
200203
name: cli_version
201204

@@ -204,12 +207,12 @@ jobs:
204207
cat cli_version.txt > phar/NIGHTLY_VERSION
205208
206209
- name: Download manifest file
207-
uses: actions/download-artifact@v8
210+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
208211
with:
209212
name: manifest
210213

211214
- name: Download built Phar file
212-
uses: actions/download-artifact@v8
215+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
213216
with:
214217
name: wp-cli-phar
215218

@@ -250,7 +253,7 @@ jobs:
250253
git commit -m "phar build: $GITHUB_REPOSITORY@$GITHUB_SHA"
251254
252255
- name: Push changes
253-
uses: ad-m/github-push-action@master
256+
uses: ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
254257
with:
255258
github_token: ${{ secrets.ACTIONS_BOT }}
256259
branch: gh-pages
@@ -264,13 +267,21 @@ jobs:
264267

265268
steps:
266269
- name: Check out builds repository
267-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
270+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
268271
with:
269272
repository: wp-cli/builds
270273
token: ${{ secrets.ACTIONS_BOT }}
271274

275+
- name: Check out bundle repository
276+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
277+
with:
278+
repository: ${{ github.repository }}
279+
ref: ${{ github.sha }}
280+
path: bundle
281+
persist-credentials: false
282+
272283
- name: Download built Phar file
273-
uses: actions/download-artifact@v8
284+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
274285
with:
275286
name: wp-cli-phar
276287

@@ -279,18 +290,45 @@ jobs:
279290
sudo apt-get update
280291
sudo apt-get install rpm rpmlint -y
281292
282-
- name: Download RPM build configuration
293+
- name: Copy RPM build configuration
283294
run: |
284-
wget -O wp-cli-rpm.spec https://raw.githubusercontent.com/wp-cli/wp-cli-bundle/main/utils/wp-cli-rpm.spec
285-
wget -O wp-cli-updaterpm.sh https://raw.githubusercontent.com/wp-cli/wp-cli-bundle/main/utils/wp-cli-updaterpm.sh
295+
cp bundle/utils/wp-cli-rpm.spec .
296+
cp bundle/utils/wp-cli-updaterpm.sh .
286297
287298
- name: Build RPM package
288299
run: |
289300
bash wp-cli-updaterpm.sh
290301
291302
- name: Verify built RPM package contents
292303
run: |
293-
ls rpm-src/noarch
304+
set -euxo pipefail
305+
rpm_file="$(ls rpm-src/noarch/wp-cli-*.noarch.rpm)"
306+
# The package must ship a launcher in the bin dir and the Phar in the data dir.
307+
rpm -qlp "$rpm_file" | tee /tmp/rpm-files.txt
308+
grep -qx '/usr/bin/wp' /tmp/rpm-files.txt
309+
grep -qx '/usr/share/wp-cli/wp-cli.phar' /tmp/rpm-files.txt
310+
# /usr/bin/wp must be the shell launcher that honors WP_CLI_PHP / WP_CLI_PHP_ARGS,
311+
# not the Phar itself.
312+
mkdir -p rpm-verify
313+
( cd rpm-verify && rpm2cpio "../$rpm_file" | cpio -idm )
314+
test -x rpm-verify/usr/bin/wp
315+
head -n1 rpm-verify/usr/bin/wp | grep -q '^#!/bin/sh'
316+
grep -q '/usr/share/wp-cli/wp-cli.phar' rpm-verify/usr/bin/wp
317+
test -s rpm-verify/usr/share/wp-cli/wp-cli.phar
318+
# Run the extracted launcher through a probe standing in for PHP: it must
319+
# forward WP_CLI_PHP_ARGS before the Phar and export WP_CLI_PHP_USED. The
320+
# probe asserts and exits without needing the Phar at its installed path.
321+
printf '%s\n' \
322+
'#!/bin/sh' \
323+
'case " $* " in' \
324+
' *" -d memory_limit=256M "*) : ;;' \
325+
' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
326+
'esac' \
327+
'[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
328+
'exit 0' \
329+
> /tmp/wp-cli-php-probe
330+
chmod +x /tmp/wp-cli-php-probe
331+
WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" rpm-verify/usr/bin/wp cli version
294332
295333
- name: Copy RPM package into builds folder
296334
run: |
@@ -304,7 +342,7 @@ jobs:
304342
git commit -m "rpm build: $GITHUB_REPOSITORY@$GITHUB_SHA"
305343
306344
- name: Push changes
307-
uses: ad-m/github-push-action@master
345+
uses: ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
308346
with:
309347
github_token: ${{ secrets.ACTIONS_BOT }}
310348
branch: gh-pages
@@ -318,13 +356,21 @@ jobs:
318356

319357
steps:
320358
- name: Check out builds repository
321-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
359+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
322360
with:
323361
repository: wp-cli/builds
324362
token: ${{ secrets.ACTIONS_BOT }}
325363

364+
- name: Check out bundle repository
365+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
366+
with:
367+
repository: ${{ github.repository }}
368+
ref: ${{ github.sha }}
369+
path: bundle
370+
persist-credentials: false
371+
326372
- name: Download built Phar file
327-
uses: actions/download-artifact@v8
373+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
328374
with:
329375
name: wp-cli-phar
330376

@@ -333,17 +379,50 @@ jobs:
333379
sudo apt-get update
334380
sudo apt-get install fakeroot lintian -y
335381
336-
- name: Download DEB build configuration
382+
- name: Copy DEB build configuration
337383
run: |
338-
wget -O wp-cli-updatedeb.sh https://raw.githubusercontent.com/wp-cli/wp-cli-bundle/main/utils/wp-cli-updatedeb.sh
384+
cp bundle/utils/wp-cli-updatedeb.sh .
339385
340386
- name: Build DEB package
341387
run: |
342388
bash wp-cli-updatedeb.sh
343389
344390
- name: Verify built DEB package contents
345391
run: |
346-
ls .
392+
set -euxo pipefail
393+
deb_file="$(ls php-wpcli*all.deb)"
394+
# The package must ship a launcher in the bin dir and the Phar in the data dir.
395+
dpkg-deb -c "$deb_file" | tee /tmp/deb-files.txt
396+
grep -Eq ' \./usr/bin/wp$' /tmp/deb-files.txt
397+
grep -Eq ' \./usr/share/wp-cli/wp-cli.phar$' /tmp/deb-files.txt
398+
# Install the package and exercise the launcher (php ships on the runner).
399+
sudo dpkg -i "$deb_file" || sudo apt-get install -f -y
400+
test -x /usr/bin/wp
401+
head -n1 /usr/bin/wp | grep -q '^#!/bin/sh'
402+
test -s /usr/share/wp-cli/wp-cli.phar
403+
# Default interpreter works.
404+
wp --info
405+
wp cli version
406+
# A probe that stands in for PHP and asserts what the launcher forwarded:
407+
# it must receive WP_CLI_PHP_ARGS before the Phar and inherit WP_CLI_PHP_USED.
408+
printf '%s\n' \
409+
'#!/bin/sh' \
410+
'case " $* " in' \
411+
' *" -d memory_limit=256M "*) : ;;' \
412+
' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
413+
'esac' \
414+
'[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
415+
'exit 0' \
416+
> /tmp/wp-cli-php-probe
417+
chmod +x /tmp/wp-cli-php-probe
418+
# Proves WP_CLI_PHP selects the interpreter AND WP_CLI_PHP_ARGS reaches it.
419+
WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" wp cli version
420+
# A deliberately broken WP_CLI_PHP must actually be used: if it were ignored,
421+
# this would still succeed. This is the regression guard for the whole fix.
422+
if WP_CLI_PHP=/bin/false wp cli version 2>/dev/null; then
423+
echo "WP_CLI_PHP was ignored by the launcher" >&2
424+
exit 1
425+
fi
347426
348427
- name: Copy DEB package into builds folder
349428
run: |
@@ -357,7 +436,7 @@ jobs:
357436
git commit -m "deb build: $GITHUB_REPOSITORY@$GITHUB_SHA"
358437
359438
- name: Push changes
360-
uses: ad-m/github-push-action@master
439+
uses: ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
361440
with:
362441
github_token: ${{ secrets.ACTIONS_BOT }}
363442
branch: gh-pages

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ name: Issue and PR Triage
1616
permissions:
1717
issues: write
1818
pull-requests: write
19-
actions: write
2019
contents: read
2120
models: read
21+
# A caller can only cap a reusable workflow's permissions, never raise them,
22+
# so `actions: write` has to be granted here for the dispatch job downstream
23+
# to work at all. The reusable workflow narrows it to that single job, so the
24+
# `pull_request_target` job does not receive it. Removing it here breaks
25+
# dispatching (see #271/#272); narrow it there instead.
26+
actions: write
2227

2328
jobs:
2429
issue-triage:

‎.github/workflows/testing.yml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,33 @@ on:
1313
jobs:
1414
test:
1515
uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main
16+
17+
minimum-php-guard:
18+
name: Minimum PHP guard - PHP ${{ matrix.php }}
19+
runs-on: ubuntu-22.04
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
php: ['5.6', '7.1']
24+
steps:
25+
- name: Check out source code
26+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
27+
with:
28+
persist-credentials: false
29+
30+
- name: Set up PHP environment
31+
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
32+
with:
33+
php-version: '${{ matrix.php }}'
34+
coverage: none
35+
36+
- name: Check minimum PHP guard
37+
run: |
38+
if php php/boot-phar.php > stdout.txt 2> stderr.txt; then
39+
echo 'Expected boot-phar.php to reject unsupported PHP version.'
40+
exit 1
41+
fi
42+
43+
test ! -s stdout.txt
44+
printf 'Error: WP-CLI requires PHP 7.2.24 or newer. You are running version %s.\n' "$(php -r 'echo PHP_VERSION;')" > expected.txt
45+
diff -u expected.txt stderr.txt

0 commit comments

Comments
 (0)