Skip to content

Commit c6eaf2a

Browse files
authored
Merge pull request #6985 from ampproject/sync/dependency-updates-from-develop
[2.2] Sync dependency updates and more from develop
2 parents 997b351 + 99f1929 commit c6eaf2a

8 files changed

Lines changed: 981 additions & 807 deletions

File tree

.github/workflows/auto-merge.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
name: Automerge
1+
# This is based on <https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request>.
2+
name: Dependabot auto-merge
23

4+
# Only trigger, when the build workflow succeeded, per <https://stackoverflow.com/a/65698892/93579>.
35
on:
4-
# ⚠️ WARNING: Secrets can be accessed by forks when triggered via this event!
5-
# In this case no code is checked out and no cache is being saved, so this workflow should be fine.
6-
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
7-
pull_request_target:
8-
types: [opened, reopened, synchronize]
6+
workflow_run:
7+
workflows: ["Build, test & measure"]
8+
types:
9+
- completed
10+
11+
permissions:
12+
pull-requests: write
13+
contents: write
914

1015
# Cancel previous workflow run groups that have not completed.
1116
concurrency:
@@ -14,15 +19,24 @@ concurrency:
1419
cancel-in-progress: true
1520

1621
jobs:
17-
automerge-dependencies:
18-
name: Automerge dependencies
22+
dependabot:
1923
runs-on: ubuntu-latest
20-
if: >
21-
github.actor == 'dependabot[bot]' &&
22-
github.event.pull_request.auto_merge == null
24+
if: ${{ github.actor == 'dependabot[bot]' }}
2325
steps:
24-
- name: Enable auto-merge for the PR
26+
- name: Dependabot metadata
27+
id: metadata
28+
uses: dependabot/fetch-metadata@v1.3.0
29+
with:
30+
github-token: "${{ secrets.GITHUB_TOKEN }}"
31+
- name: Enable auto-merge for Dependabot PRs
32+
if: ${{ github.event.pull_request.auto_merge == null && ( steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' ) }}
2533
run: gh pr merge --auto --merge "$PR_URL"
2634
env:
27-
PR_URL: ${{ github.event.pull_request.html_url }}
28-
GITHUB_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }}
35+
PR_URL: ${{github.event.pull_request.html_url}}
36+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
37+
- name: Approve PR
38+
run: gh pr review --approve "$PR_URL"
39+
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' }}
40+
env:
41+
PR_URL: ${{github.event.pull_request.html_url}}
42+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/build-test-measure.yml

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ jobs:
3030
- name: Checkout including last 2 commits
3131
# Fetch last 2 commits if it's not a PR, so that we can determine the list of modified files.
3232
if: ${{ github.base_ref == null }}
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@v3
3434
with:
3535
fetch-depth: 2
3636

3737
- name: Checkout
3838
# Do usual checkout if it's a PR.
3939
if: ${{ github.base_ref != null }}
40-
uses: actions/checkout@v2
40+
uses: actions/checkout@v3
4141

4242
- name: Fetch base branch
4343
# Only fetch base ref if it's a PR.
@@ -87,7 +87,7 @@ jobs:
8787
runs-on: ubuntu-latest
8888
steps:
8989
- name: Checkout
90-
uses: actions/checkout@v2
90+
uses: actions/checkout@v3
9191

9292
- name: Setup Node
9393
uses: actions/setup-node@v3.0.0
@@ -112,7 +112,7 @@ jobs:
112112
runs-on: ubuntu-latest
113113
steps:
114114
- name: Checkout
115-
uses: actions/checkout@v2
115+
uses: actions/checkout@v3
116116

117117
- name: Setup Node
118118
uses: actions/setup-node@v3.0.0
@@ -161,7 +161,7 @@ jobs:
161161
runs-on: ubuntu-latest
162162
steps:
163163
- name: Checkout
164-
uses: actions/checkout@v2
164+
uses: actions/checkout@v3
165165

166166
- name: Setup PHP
167167
uses: shivammathur/setup-php@v2
@@ -206,7 +206,7 @@ jobs:
206206
if: needs.pre-run.outputs.changed-php-count > 0
207207
steps:
208208
- name: Checkout
209-
uses: actions/checkout@v2
209+
uses: actions/checkout@v3
210210

211211
- name: Setup PHP
212212
uses: shivammathur/setup-php@v2
@@ -246,7 +246,7 @@ jobs:
246246

247247
steps:
248248
- name: Checkout
249-
uses: actions/checkout@v2
249+
uses: actions/checkout@v3
250250

251251
- name: Setup Node
252252
uses: actions/setup-node@v3.0.0
@@ -285,7 +285,7 @@ jobs:
285285

286286
steps:
287287
- name: Checkout
288-
uses: actions/checkout@v2
288+
uses: actions/checkout@v3
289289

290290
- name: Setup PHP
291291
uses: shivammathur/setup-php@v2
@@ -343,7 +343,6 @@ jobs:
343343
name: "Unit test${{ matrix.coverage && ' (with coverage)' || '' }}: PHP ${{ matrix.php }}, WP ${{ matrix.wp }}"
344344
runs-on: ubuntu-latest
345345
needs: pre-run
346-
if: needs.pre-run.outputs.changed-file-count > 0
347346
env:
348347
WP_CORE_DIR: /tmp/wordpress
349348
services:
@@ -400,10 +399,20 @@ jobs:
400399
coverage: false
401400

402401
steps:
402+
# Note: The repeated `needs.pre-run.outputs.changed-php-count > 0` checks would be avoided if a step could short-
403+
# circuit per <https://github.com/actions/runner/issues/662>. The reason why the if statement can't be put on the
404+
# job as a whole is because the name is variable based on the matrix, and if the condition is not met then the
405+
# name won't be interpolated in order to match the required jobs set up in branch protection.
406+
- name: Notice
407+
if: needs.pre-run.outputs.changed-php-count == 0
408+
run: echo "No PHP files were changed so no PHP unit tests will run"
409+
403410
- name: Checkout
404-
uses: actions/checkout@v2
411+
if: needs.pre-run.outputs.changed-php-count > 0
412+
uses: actions/checkout@v3
405413

406414
- name: Setup PHP
415+
if: needs.pre-run.outputs.changed-php-count > 0
407416
uses: shivammathur/setup-php@v2
408417
with:
409418
php-version: ${{ matrix.php }}
@@ -412,25 +421,30 @@ jobs:
412421
ini-values: pcov.directory=.
413422

414423
- name: Shutdown default MySQL service
424+
if: needs.pre-run.outputs.changed-php-count > 0
415425
run: sudo service mysql stop
416426

417427
- name: Verify MariaDB connection
428+
if: needs.pre-run.outputs.changed-php-count > 0
418429
run: |
419430
while ! mysqladmin ping -h"127.0.0.1" -P"${{ job.services.mysql.ports[3306] }}" --silent; do
420431
sleep 1
421432
done
422433
423434
- name: Setup Node
435+
if: needs.pre-run.outputs.changed-php-count > 0
424436
uses: actions/setup-node@v3.0.0
425437
with:
426438
node-version-file: '.nvmrc'
427439
cache: npm
428440

429441
- name: Get Composer Cache Directory
442+
if: needs.pre-run.outputs.changed-php-count > 0
430443
id: composer-cache
431444
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
432445

433446
- name: Configure Composer cache
447+
if: needs.pre-run.outputs.changed-php-count > 0
434448
uses: actions/cache@v2
435449
with:
436450
path: ${{ steps.composer-cache.outputs.dir }}
@@ -439,29 +453,35 @@ jobs:
439453
${{ runner.os }}-composer-
440454
441455
- name: Install Composer dependencies
456+
if: needs.pre-run.outputs.changed-php-count > 0
442457
run: composer install --prefer-dist --ignore-platform-reqs --no-progress --no-interaction
443458

444459
- name: Install Node dependencies
460+
if: needs.pre-run.outputs.changed-php-count > 0
445461
run: npm ci
446462
env:
447463
CI: true
448464

449465
- name: Build plugin
466+
if: needs.pre-run.outputs.changed-php-count > 0
450467
run: npm run build:js
451468

452469
# Scan the logs for failing tests and surface that information by creating annotations and log file decorations.
453470
- name: Setup problem matcher to provide annotations for PHPUnit
471+
if: needs.pre-run.outputs.changed-php-count > 0
454472
# The JSON file is provided by the `shivammathur/setup-php` action. See https://github.com/shivammathur/setup-php#problem-matchers.
455473
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
456474

457475
- name: Install WP tests
476+
if: needs.pre-run.outputs.changed-php-count > 0
458477
run: bash bin/ci/install-wp-tests.sh wordpress_test root '' 127.0.0.1:${{ job.services.mysql.ports['3306'] }} ${{ matrix.wp }} true
459478

460479
- name: Post install of WP tests
480+
if: needs.pre-run.outputs.changed-php-count > 0
461481
run: bash bin/ci/after-wp-install.sh ${{ matrix.wp }} ${{ matrix.install-pwa-plugin == true }} /tmp/wordpress-tests
462482

463483
- name: Setup PCOV
464-
if: ${{ matrix.coverage == true }}
484+
if: ${{ matrix.coverage == true && needs.pre-run.outputs.changed-php-count > 0 }}
465485
# phpdocumentor/reflection has to be removed as it makes use of an outdated dependency, making pcov/clobber
466486
# unable to be installed.
467487
run: |
@@ -470,25 +490,26 @@ jobs:
470490
vendor/bin/pcov clobber
471491
472492
- name: Copy plugin to WP plugins directory
493+
if: needs.pre-run.outputs.changed-php-count > 0
473494
run: cp -r "$PWD" "$WP_CORE_DIR/src/wp-content/plugins/amp"
474495

475496
- name: Run tests
476-
if: ${{ matrix.coverage == false }}
497+
if: ${{ matrix.coverage == false && needs.pre-run.outputs.changed-php-count > 0 }}
477498
run: vendor/bin/phpunit --verbose
478499
working-directory: ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
479500

480501
- name: Run tests with coverage
481-
if: ${{ matrix.coverage == true }}
502+
if: ${{ matrix.coverage == true && needs.pre-run.outputs.changed-php-count > 0 }}
482503
run: vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml
483504
working-directory: ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
484505

485506
- name: Run external HTTP tests
486-
if: ${{ matrix.external-http == true }}
507+
if: ${{ matrix.external-http == true && needs.pre-run.outputs.changed-php-count > 0 }}
487508
run: vendor/bin/phpunit --testsuite external-http
488509
working-directory: ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp
489510

490511
- name: Upload code coverage report
491-
if: ${{ matrix.coverage == true }}
512+
if: ${{ matrix.coverage == true && needs.pre-run.outputs.changed-php-count > 0 }}
492513
uses: codecov/codecov-action@v2.1.0
493514
with:
494515
file: ${{ env.WP_CORE_DIR }}/src/wp-content/plugins/amp/build/logs/clover.xml
@@ -500,7 +521,7 @@ jobs:
500521
feature-test-php:
501522
name: "Feature test${{ matrix.coverage && ' (with coverage)' || '' }}: PHP ${{ matrix.php }}, WP ${{ matrix.wp }}"
502523
needs: pre-run
503-
if: needs.pre-run.outputs.changed-file-count > 0
524+
if: needs.pre-run.outputs.changed-php-count > 0
504525
runs-on: ubuntu-latest
505526
env:
506527
WP_VERSION: ${{ matrix.wp }}
@@ -550,7 +571,7 @@ jobs:
550571

551572
steps:
552573
- name: Checkout
553-
uses: actions/checkout@v2
574+
uses: actions/checkout@v3
554575

555576
- name: Setup PHP
556577
uses: shivammathur/setup-php@v2
@@ -662,7 +683,7 @@ jobs:
662683

663684
steps:
664685
- name: Check out source files
665-
uses: actions/checkout@v2
686+
uses: actions/checkout@v3
666687

667688
- name: Setup PHP
668689
uses: shivammathur/setup-php@v2

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- name: Checkout
36-
uses: actions/checkout@v2
36+
uses: actions/checkout@v3
3737

3838
- name: Initialize CodeQL
3939
uses: github/codeql-action/init@v1

.github/workflows/gutenberg-packages-update.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
# Once a day (https://crontab.guru/once-a-day)
88
- cron: '0 0 * * *'
99

10+
permissions:
11+
pull-requests: write
12+
contents: write
13+
1014
# Cancel previous workflow run groups that have not completed.
1115
concurrency:
1216
# Group workflow runs by workflow name, along with the head branch ref of the pull request
@@ -71,7 +75,7 @@ jobs:
7175
# Needed to later close PR.
7276
- name: Checkout repo
7377
if: steps.latest-pr.num != ''
74-
uses: actions/checkout@v2
78+
uses: actions/checkout@v3
7579

7680
- name: Close latest open PR
7781
if: steps.latest-pr.num != ''
@@ -88,7 +92,7 @@ jobs:
8892
needs: check-gutenberg-release
8993
steps:
9094
- name: Checkout
91-
uses: actions/checkout@v2
95+
uses: actions/checkout@v3
9296
with:
9397
# Fetch history for all branches and tags to allow for successful merge of base branch if needed.
9498
fetch-depth: 0
@@ -168,6 +172,6 @@ jobs:
168172
gh pr merge --auto --merge "$PR_URL"
169173
env:
170174
VERSION: ${{ needs.check-gutenberg-release.outputs.latest-version }}
171-
GITHUB_TOKEN: ${{ secrets.GUTENBERG_PACKAGES_UPDATE_TOKEN }}
175+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
172176
BASE_BRANCH: ${{ steps.branches.outputs.base }}
173177
HEAD_BRANCH: ${{ steps.branches.outputs.head }}

.github/workflows/release-draft.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1717

1818
- name: Draft release
1919
uses: ./.github/actions/draft-release

0 commit comments

Comments
 (0)