Skip to content

Commit 2f2fcab

Browse files
authored
Merge branch 'main' into try/composer-phar
2 parents b5a74cb + 8475849 commit 2f2fcab

15 files changed

Lines changed: 1031 additions & 622 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: Checkout code
24-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
24+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2525
with:
2626
persist-credentials: false
2727

‎.github/workflows/deployment.yml‎

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

2121
- name: Set up PHP environment
2222
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
@@ -110,7 +110,7 @@ jobs:
110110
if: ${{ github.repository_owner == 'wp-cli' }}
111111
steps:
112112
- name: Check out source code
113-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
113+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
114114

115115
- name: Install Ghostscript
116116
run: |
@@ -140,7 +140,7 @@ jobs:
140140
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
141141
142142
- name: Download built Phar file
143-
uses: actions/download-artifact@v8
143+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
144144
with:
145145
name: wp-cli-phar
146146

@@ -152,7 +152,7 @@ jobs:
152152
153153
- name: Setup MySQL Server
154154
id: setup-mysql
155-
uses: shogo82148/actions-setup-mysql@076e636c45996ec8cb1a455c65f9f5364aeebd8a # v1
155+
uses: shogo82148/actions-setup-mysql@3dcedf762c5e82d781a9e414462785b30208e79c # v1
156156
with:
157157
mysql-version: ${{ matrix.mysql }}
158158
auto-start: true
@@ -192,13 +192,13 @@ jobs:
192192
if: ${{ github.repository_owner == 'wp-cli' && github.event_name != 'workflow_dispatch' }}
193193
steps:
194194
- name: Check out builds repository
195-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
195+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
196196
with:
197197
repository: wp-cli/builds
198198
token: ${{ secrets.ACTIONS_BOT }}
199199

200200
- name: Download WP-CLI version
201-
uses: actions/download-artifact@v8
201+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
202202
with:
203203
name: cli_version
204204

@@ -207,12 +207,12 @@ jobs:
207207
cat cli_version.txt > phar/NIGHTLY_VERSION
208208
209209
- name: Download manifest file
210-
uses: actions/download-artifact@v8
210+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
211211
with:
212212
name: manifest
213213

214214
- name: Download built Phar file
215-
uses: actions/download-artifact@v8
215+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
216216
with:
217217
name: wp-cli-phar
218218

@@ -253,7 +253,7 @@ jobs:
253253
git commit -m "phar build: $GITHUB_REPOSITORY@$GITHUB_SHA"
254254
255255
- name: Push changes
256-
uses: ad-m/github-push-action@master
256+
uses: ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
257257
with:
258258
github_token: ${{ secrets.ACTIONS_BOT }}
259259
branch: gh-pages
@@ -311,13 +311,21 @@ jobs:
311311

312312
steps:
313313
- name: Check out builds repository
314-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
314+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
315315
with:
316316
repository: wp-cli/builds
317317
token: ${{ secrets.ACTIONS_BOT }}
318318

319+
- name: Check out bundle repository
320+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
321+
with:
322+
repository: ${{ github.repository }}
323+
ref: ${{ github.sha }}
324+
path: bundle
325+
persist-credentials: false
326+
319327
- name: Download built Phar file
320-
uses: actions/download-artifact@v8
328+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
321329
with:
322330
name: wp-cli-phar
323331

@@ -326,18 +334,45 @@ jobs:
326334
sudo apt-get update
327335
sudo apt-get install rpm rpmlint -y
328336
329-
- name: Download RPM build configuration
337+
- name: Copy RPM build configuration
330338
run: |
331-
wget -O wp-cli-rpm.spec https://raw.githubusercontent.com/wp-cli/wp-cli-bundle/main/utils/wp-cli-rpm.spec
332-
wget -O wp-cli-updaterpm.sh https://raw.githubusercontent.com/wp-cli/wp-cli-bundle/main/utils/wp-cli-updaterpm.sh
339+
cp bundle/utils/wp-cli-rpm.spec .
340+
cp bundle/utils/wp-cli-updaterpm.sh .
333341
334342
- name: Build RPM package
335343
run: |
336344
bash wp-cli-updaterpm.sh
337345
338346
- name: Verify built RPM package contents
339347
run: |
340-
ls rpm-src/noarch
348+
set -euxo pipefail
349+
rpm_file="$(ls rpm-src/noarch/wp-cli-*.noarch.rpm)"
350+
# The package must ship a launcher in the bin dir and the Phar in the data dir.
351+
rpm -qlp "$rpm_file" | tee /tmp/rpm-files.txt
352+
grep -qx '/usr/bin/wp' /tmp/rpm-files.txt
353+
grep -qx '/usr/share/wp-cli/wp-cli.phar' /tmp/rpm-files.txt
354+
# /usr/bin/wp must be the shell launcher that honors WP_CLI_PHP / WP_CLI_PHP_ARGS,
355+
# not the Phar itself.
356+
mkdir -p rpm-verify
357+
( cd rpm-verify && rpm2cpio "../$rpm_file" | cpio -idm )
358+
test -x rpm-verify/usr/bin/wp
359+
head -n1 rpm-verify/usr/bin/wp | grep -q '^#!/bin/sh'
360+
grep -q '/usr/share/wp-cli/wp-cli.phar' rpm-verify/usr/bin/wp
361+
test -s rpm-verify/usr/share/wp-cli/wp-cli.phar
362+
# Run the extracted launcher through a probe standing in for PHP: it must
363+
# forward WP_CLI_PHP_ARGS before the Phar and export WP_CLI_PHP_USED. The
364+
# probe asserts and exits without needing the Phar at its installed path.
365+
printf '%s\n' \
366+
'#!/bin/sh' \
367+
'case " $* " in' \
368+
' *" -d memory_limit=256M "*) : ;;' \
369+
' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
370+
'esac' \
371+
'[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
372+
'exit 0' \
373+
> /tmp/wp-cli-php-probe
374+
chmod +x /tmp/wp-cli-php-probe
375+
WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" rpm-verify/usr/bin/wp cli version
341376
342377
- name: Copy RPM package into builds folder
343378
run: |
@@ -351,7 +386,7 @@ jobs:
351386
git commit -m "rpm build: $GITHUB_REPOSITORY@$GITHUB_SHA"
352387
353388
- name: Push changes
354-
uses: ad-m/github-push-action@master
389+
uses: ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
355390
with:
356391
github_token: ${{ secrets.ACTIONS_BOT }}
357392
branch: gh-pages
@@ -365,13 +400,21 @@ jobs:
365400

366401
steps:
367402
- name: Check out builds repository
368-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
403+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
369404
with:
370405
repository: wp-cli/builds
371406
token: ${{ secrets.ACTIONS_BOT }}
372407

408+
- name: Check out bundle repository
409+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
410+
with:
411+
repository: ${{ github.repository }}
412+
ref: ${{ github.sha }}
413+
path: bundle
414+
persist-credentials: false
415+
373416
- name: Download built Phar file
374-
uses: actions/download-artifact@v8
417+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
375418
with:
376419
name: wp-cli-phar
377420

@@ -380,17 +423,50 @@ jobs:
380423
sudo apt-get update
381424
sudo apt-get install fakeroot lintian -y
382425
383-
- name: Download DEB build configuration
426+
- name: Copy DEB build configuration
384427
run: |
385-
wget -O wp-cli-updatedeb.sh https://raw.githubusercontent.com/wp-cli/wp-cli-bundle/main/utils/wp-cli-updatedeb.sh
428+
cp bundle/utils/wp-cli-updatedeb.sh .
386429
387430
- name: Build DEB package
388431
run: |
389432
bash wp-cli-updatedeb.sh
390433
391434
- name: Verify built DEB package contents
392435
run: |
393-
ls .
436+
set -euxo pipefail
437+
deb_file="$(ls php-wpcli*all.deb)"
438+
# The package must ship a launcher in the bin dir and the Phar in the data dir.
439+
dpkg-deb -c "$deb_file" | tee /tmp/deb-files.txt
440+
grep -Eq ' \./usr/bin/wp$' /tmp/deb-files.txt
441+
grep -Eq ' \./usr/share/wp-cli/wp-cli.phar$' /tmp/deb-files.txt
442+
# Install the package and exercise the launcher (php ships on the runner).
443+
sudo dpkg -i "$deb_file" || sudo apt-get install -f -y
444+
test -x /usr/bin/wp
445+
head -n1 /usr/bin/wp | grep -q '^#!/bin/sh'
446+
test -s /usr/share/wp-cli/wp-cli.phar
447+
# Default interpreter works.
448+
wp --info
449+
wp cli version
450+
# A probe that stands in for PHP and asserts what the launcher forwarded:
451+
# it must receive WP_CLI_PHP_ARGS before the Phar and inherit WP_CLI_PHP_USED.
452+
printf '%s\n' \
453+
'#!/bin/sh' \
454+
'case " $* " in' \
455+
' *" -d memory_limit=256M "*) : ;;' \
456+
' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
457+
'esac' \
458+
'[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
459+
'exit 0' \
460+
> /tmp/wp-cli-php-probe
461+
chmod +x /tmp/wp-cli-php-probe
462+
# Proves WP_CLI_PHP selects the interpreter AND WP_CLI_PHP_ARGS reaches it.
463+
WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" wp cli version
464+
# A deliberately broken WP_CLI_PHP must actually be used: if it were ignored,
465+
# this would still succeed. This is the regression guard for the whole fix.
466+
if WP_CLI_PHP=/bin/false wp cli version 2>/dev/null; then
467+
echo "WP_CLI_PHP was ignored by the launcher" >&2
468+
exit 1
469+
fi
394470
395471
- name: Copy DEB package into builds folder
396472
run: |
@@ -404,7 +480,7 @@ jobs:
404480
git commit -m "deb build: $GITHUB_REPOSITORY@$GITHUB_SHA"
405481
406482
- name: Push changes
407-
uses: ad-m/github-push-action@master
483+
uses: ad-m/github-push-action@881a6320fdb16eb5318c5054f31c218aec2b324c # v1
408484
with:
409485
github_token: ${{ secrets.ACTIONS_BOT }}
410486
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

‎.github/workflows/update-framework.yml‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
if: ${{ github.repository_owner == 'wp-cli' }}
2828
steps:
2929
- name: Check out source code
30-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
30+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3131
with:
32-
token: ${{ secrets.ACTIONS_BOT }}
32+
token: ${{ secrets.GITHUB_TOKEN }}
3333

3434
- name: Set up PHP environment
3535
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
@@ -57,7 +57,8 @@ jobs:
5757
5858
- name: Commit and Create Pull Request
5959
env:
60-
GH_TOKEN: ${{ secrets.ACTIONS_BOT }}
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
6162
PR_BODY: |
6263
**This is an automated pull-request**
6364
@@ -72,19 +73,19 @@ jobs:
7273
7374
git push -f origin update-framework
7475
75-
PR_NUMBER=$(gh pr list --head update-framework --json number --jq '.[0].number // empty')
76+
PR_NUMBER=$(gh pr list --head "update-framework" --base "$DEFAULT_BRANCH" --state open --json number --jq '.[0].number // empty')
7677
if [ -z "$PR_NUMBER" ]; then
7778
gh pr create \
7879
--title "Update wp-cli framework" \
7980
--body "$PR_BODY" \
8081
--label "scope:framework" \
81-
--base "${{ github.event.repository.default_branch }}" \
82+
--base "$DEFAULT_BRANCH" \
8283
--head "update-framework"
8384
else
8485
gh pr edit "$PR_NUMBER" \
8586
--title "Update wp-cli framework" \
8687
--body "$PR_BODY" \
8788
--add-label "scope:framework" \
88-
--base "${{ github.event.repository.default_branch }}"
89+
--base "$DEFAULT_BRANCH"
8990
fi
9091
fi

0 commit comments

Comments
 (0)