Build/Test Tools: Backport updates to GitHub Actions.

This backports several changesets to GitHub Actions workflows. These changesets:

- address the deprecated notices related to save-output and set-output to ensure the workflows continue to run after these are removed.
- adds support for automatically retrying a failed workflow once.
- removes workflow files that are not applicable to the branch.

Merges [53736], [53737], [53940], [53947], [54039], [54108], [54293], [54313], [54342], [54343], [54373], [54511], [54649], [54650], [54651], [54674], [54750], [54852], [55152], [55487] to the 5.9 branch.
See #55652, #56407, #54695, #56820, #56816, #56793, #56820, #57572.

git-svn-id: https://develop.svn.wordpress.org/branches/5.9@55516 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2023-03-10 15:52:41 +00:00
parent 5c9b321e41
commit 2b10ea01c6
10 changed files with 265 additions and 529 deletions

View File

@ -9,8 +9,9 @@ on:
- '3.[89]'
- '[4-9].[0-9]'
tags:
- '3.[89]*'
- '[4-9].[0-9]*'
- '[0-9]+.[0-9]'
- '[0-9]+.[0-9].[0-9]+'
- '!3.7.[0-9]+'
pull_request:
branches:
- trunk
@ -20,7 +21,7 @@ on:
# Any change to a PHP or JavaScript file should run checks.
- '**.js'
- '**.php'
# These files configure NPM. Changes could affect the outcome.
# These files configure npm. Changes could affect the outcome.
- 'package*.json'
# These files configure Composer. Changes could affect the outcome.
- 'composer.*'
@ -63,10 +64,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Set up PHP
uses: shivammathur/setup-php@3eda58347216592f618bb1dff277810b6698e4ca # v2.19.1
uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0
with:
php-version: '7.4'
coverage: none
@ -81,18 +82,18 @@ jobs:
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT
- name: Cache PHPCS scan cache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
with:
path: .cache/phpcs.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}
- name: Install Composer dependencies
uses: ramsey/composer-install@f680dac46551dffb2234a240d65ae806c2999dd6 # v2.1.0
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0
with:
composer-options: "--no-progress --no-ansi --no-interaction"
composer-options: "--no-progress --no-ansi"
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
@ -116,9 +117,9 @@ jobs:
# Performs the following steps:
# - Checks out the repository.
# - Logs debug information about the GitHub Action runner.
# - Installs NodeJS.
# - Installs Node.js.
# - Logs updated debug information.
# _ Installs NPM dependencies.
# _ Installs npm dependencies.
# - Run the WordPress JSHint checks.
# - Ensures version-controlled files are not modified or deleted.
jshint:
@ -131,7 +132,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Log debug information
run: |
@ -140,8 +141,8 @@ jobs:
git --version
svn --version
- name: Install NodeJS
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
- name: Install Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: '.nvmrc'
cache: npm
@ -172,3 +173,34 @@ jobs:
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
needs: [ phpcs, jshint, slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
needs.phpcs.result == 'cancelled' || needs.phpcs.result == 'failure' ||
needs.jshint.result == 'cancelled' || needs.jshint.result == 'failure'
)
steps:
- name: Dispatch workflow run
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'failed-workflow.yml',
ref: 'trunk',
inputs: {
run_id: '${{ github.run_id }}'
}
});

View File

@ -8,8 +8,10 @@ on:
- '5.[3-9]'
- '[6-9].[0-9]'
tags:
- '5.[3-9]*'
- '[6-9].[0-9]*'
- '[0-9]+.[0-9]'
- '[0-9]+.[0-9].[0-9]+'
- '![34].[0-9].[0-9]+'
- '!5.[0-2].[0-9]+'
pull_request:
branches:
- trunk
@ -34,8 +36,8 @@ jobs:
# - Sets environment variables.
# - Checks out the repository.
# - Logs debug information about the GitHub Action runner.
# - Installs NodeJS.
# _ Installs NPM dependencies.
# - Installs Node.js.
# _ Installs npm dependencies.
# - Builds WordPress to run from the `build` directory.
# - Starts the WordPress Docker container.
# - Logs general debug information.
@ -57,7 +59,7 @@ jobs:
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Log debug information
run: |
@ -70,8 +72,8 @@ jobs:
php -i
locale -a
- name: Install NodeJS
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
- name: Install Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: '.nvmrc'
cache: npm
@ -128,3 +130,33 @@ jobs:
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
needs: [ e2e-tests, slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
needs.e2e-tests.result == 'cancelled' || needs.e2e-tests.result == 'failure'
)
steps:
- name: Dispatch workflow run
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'failed-workflow.yml',
ref: 'trunk',
inputs: {
run_id: '${{ github.run_id }}'
}
});

View File

@ -8,8 +8,9 @@ on:
- '3.[89]'
- '[4-9].[0-9]'
tags:
- '3.[89]*'
- '[4-9].[0-9]*'
- '[0-9]+.[0-9]'
- '[0-9]+.[0-9].[0-9]+'
- '!3.7.[0-9]+'
pull_request:
branches:
- trunk
@ -18,7 +19,7 @@ on:
paths:
# Any change to a JavaScript file should run tests.
- '**.js'
# These files configure NPM. Changes could affect the outcome.
# These files configure npm. Changes could affect the outcome.
- 'package*.json'
# This file configures ESLint. Changes could affect the outcome.
- '.eslintignore'
@ -43,9 +44,9 @@ jobs:
# Performs the following steps:
# - Checks out the repository.
# - Logs debug information about the GitHub Action runner.
# - Installs NodeJS.
# - Installs Node.js.
# - Logs updated debug information.
# _ Installs NPM dependencies.
# _ Installs npm dependencies.
# - Run the WordPress QUnit tests.
# - Ensures version-controlled files are not modified or deleted.
test-js:
@ -56,7 +57,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Log debug information
run: |
@ -65,8 +66,8 @@ jobs:
git --version
svn --version
- name: Install NodeJS
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
- name: Install Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: '.nvmrc'
cache: npm
@ -97,3 +98,33 @@ jobs:
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
needs: [ test-js, slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
needs.test-js.result == 'cancelled' || needs.test-js.result == 'failure'
)
steps:
- name: Dispatch workflow run
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'failed-workflow.yml',
ref: 'trunk',
inputs: {
run_id: '${{ github.run_id }}'
}
});

View File

@ -8,8 +8,10 @@ on:
- '5.[5-9]'
- '[6-9].[0-9]'
tags:
- '5.[5-9]*'
- '[6-9].[0-9]*'
- '[0-9]+.[0-9]'
- '[0-9]+.[0-9].[0-9]+'
- '![34].[0-9].[0-9]+'
- '!5.[0-4].[0-9]+'
pull_request:
branches:
- trunk
@ -57,10 +59,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Set up PHP
uses: shivammathur/setup-php@3eda58347216592f618bb1dff277810b6698e4ca # v2.19.1
uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d # v2.24.0
with:
php-version: '7.4'
coverage: none
@ -75,18 +77,18 @@ jobs:
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT
- name: Cache PHP compatibility scan cache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6
with:
path: .cache/phpcompat.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcompat-cache-${{ hashFiles('**/composer.json', 'phpcompat.xml.dist') }}
- name: Install Composer dependencies
uses: ramsey/composer-install@f680dac46551dffb2234a240d65ae806c2999dd6 # v2.1.0
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0
with:
composer-options: "--no-progress --no-ansi --no-interaction"
composer-options: "--no-progress --no-ansi"
- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH
@ -112,3 +114,33 @@ jobs:
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
needs: [ php-compatibility, slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
needs.php-compatibility.result == 'cancelled' || needs.php-compatibility.result == 'failure'
)
steps:
- name: Dispatch workflow run
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'failed-workflow.yml',
ref: 'trunk',
inputs: {
run_id: '${{ github.run_id }}'
}
});

View File

@ -7,8 +7,8 @@ on:
- '3.[7-9]'
- '[4-9].[0-9]'
tags:
- '3.[7-9]*'
- '[4-9].[0-9]*'
- '[0-9]+.[0-9]'
- '[0-9]+.[0-9].[0-9]+'
pull_request:
branches:
- trunk
@ -40,8 +40,8 @@ jobs:
# Performs the following steps:
# - Sets environment variables.
# - Sets up the environment variables needed for testing with memcached (if desired).
# - Installs NodeJS.
# - Installs NPM dependencies
# - Installs Node.js.
# - Installs npm dependencies
# - Configures caching for Composer.
# - Installs Composer dependencies.
# - Logs Docker debug information (about the Docker installation within the runner).
@ -110,33 +110,33 @@ jobs:
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Install NodeJS
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
- name: Install Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Dependencies
- name: Install npm dependencies
run: npm ci
# This date is used to ensure that the Composer cache is refreshed at least once every week.
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT
- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "composer_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # v3.2.3
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.composer_dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-date-${{ steps.get-date.outputs.date }}-composer-${{ hashFiles('**/composer.json') }}
- name: Install Composer dependencies
@ -231,7 +231,7 @@ jobs:
- name: Checkout the WordPress Test Reporter
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
repository: 'WordPress/phpunit-test-runner'
path: 'test-runner'
@ -254,3 +254,33 @@ jobs:
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
needs: [ test-php, slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
needs.test-php.result == 'cancelled' || needs.test-php.result == 'failure'
)
steps:
- name: Dispatch workflow run
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'failed-workflow.yml',
ref: 'trunk',
inputs: {
run_id: '${{ github.run_id }}'
}
});

View File

@ -1,191 +0,0 @@
##
# A reusable workflow for posting messages to the Making WordPress
# Core Slack Instance by submitting data to Slack webhook URLs
# received by Slack Workflows.
##
name: Slack Notifications
on:
workflow_run:
workflows:
- Code Coverage Report
- Coding Standards
- End-to-end Tests
- JavaScript Tests
- PHP Compatibility
- PHPUnit Tests
- Test NPM
- Test old branches
types:
- completed
branches:
- '[3-4].[0-9]'
- '5.[0-8]'
workflow_call:
inputs:
calling_status:
description: 'The status of the calling workflow'
type: string
required: true
secrets:
SLACK_GHA_SUCCESS_WEBHOOK:
description: 'The Slack webhook URL for a successful build.'
required: true
SLACK_GHA_CANCELLED_WEBHOOK:
description: 'The Slack webhook URL for a cancelled build.'
required: true
SLACK_GHA_FIXED_WEBHOOK:
description: 'The Slack webhook URL for a fixed build.'
required: true
SLACK_GHA_FAILURE_WEBHOOK:
description: 'The Slack webhook URL for a failed build.'
required: true
env:
CURRENT_BRANCH: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }}
jobs:
# Gathers the details needed for Slack notifications.
#
# These details are passed as outputs to the subsequent, dependant jobs that
# submit data to Slack webhook URLs configured to post messages.
#
# Performs the following steps:
# - Retrieves the workflow ID (if necessary).
# - Retrieves the workflow URL (if necessary).
# - Retrieves the previous workflow run and stores its conclusion.
# - Sets the previous conclusion as an output.
# - Prepares the commit message.
# - Constructs and stores a message payload as an output.
prepare:
name: Prepare notifications
runs-on: ubuntu-latest
timeout-minutes: 5
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event.workflow_run.event != 'pull_request' }}
outputs:
previous_conclusion: ${{ steps.previous-conclusion.outputs.previous_conclusion }}
payload: ${{ steps.create-payload.outputs.payload }}
steps:
- name: Get the workflow ID
id: current-workflow-id
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0
with:
script: |
const workflow_run = await github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.run_id }},
});
return workflow_run.data.workflow_id;
- name: Get details about the previous workflow run
id: previous-result
uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0
with:
script: |
const previous_runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.workflow_id || steps.current-workflow-id.outputs.result }},
branch: '${{ env.CURRENT_BRANCH }}',
per_page: 1,
page: 2,
});
return previous_runs.data.workflow_runs[0].conclusion;
- name: Store previous conclusion as an output
id: previous-conclusion
run: echo "::set-output name=previous_conclusion::${{ steps.previous-result.outputs.result }}"
- name: Get the commit message
id: current-commit-message
uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }}
with:
script: |
const commit_details = await github.rest.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: '${{ github.sha }}'
});
return commit_details.data.commit.message;
- name: Prepare commit message.
id: commit-message
run: |
COMMIT_MESSAGE=$(cat <<'EOF' | awk 'NR==1' | sed 's/`/\\`/g' | sed 's/\"/\\\\\\"/g' | sed 's/\$/\\$/g'
${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_commit.message || ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && fromJson( steps.current-commit-message.outputs.result ) || github.event.head_commit.message }}
EOF
)
echo "::set-output name=commit_message_escaped::${COMMIT_MESSAGE}"
- name: Construct payload and store as an output
id: create-payload
run: echo "::set-output name=payload::{\"workflow_name\":\"${{ github.event_name == 'workflow_run' && github.event.workflow_run.name || github.workflow }}\",\"ref_name\":\"${{ env.CURRENT_BRANCH }}\",\"run_url\":\"https://github.com/WordPress/wordpress-develop/actions/runs/${{ github.event_name == 'workflow_run' && github.event.workflow_run.id || github.run_id }}\",\"commit_message\":\"${{ steps.commit-message.outputs.commit_message_escaped }}\"}"
# Posts notifications when a workflow fails.
failure:
name: Failure notifications
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [ prepare ]
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' || inputs.calling_status == 'failure' || failure() }}
steps:
- name: Post failure notifications to Slack
uses: slackapi/slack-github-action@410ae57cff5c6b682b106440be0e6c7eb8c98c9d # v1.16.0
with:
payload: ${{ needs.prepare.outputs.payload }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
# Posts notifications the first time a workflow run succeeds after previously failing.
fixed:
name: Fixed notifications
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [ prepare ]
if: ${{ needs.prepare.outputs.previous_conclusion == 'failure' && ( github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || inputs.calling_status == 'success' ) && success() }}
steps:
- name: Post failure notifications to Slack
uses: slackapi/slack-github-action@410ae57cff5c6b682b106440be0e6c7eb8c98c9d # v1.16.0
with:
payload: ${{ needs.prepare.outputs.payload }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
# Posts notifications when a workflow is successful.
success:
name: Success notifications
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [ prepare ]
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || inputs.calling_status == 'success' && success() }}
steps:
- name: Post success notifications to Slack
uses: slackapi/slack-github-action@410ae57cff5c6b682b106440be0e6c7eb8c98c9d # v1.16.0
with:
payload: ${{ needs.prepare.outputs.payload }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
# Posts notifications when a workflow is cancelled.
cancelled:
name: Cancelled notifications
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [ prepare ]
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'cancelled' || inputs.calling_status == 'cancelled' || cancelled() }}
steps:
- name: Post cancelled notifications to Slack
uses: slackapi/slack-github-action@410ae57cff5c6b682b106440be0e6c7eb8c98c9d # v1.16.0
with:
payload: ${{ needs.prepare.outputs.payload }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}

View File

@ -1,183 +0,0 @@
name: Code Coverage Report
on:
# Verify
push:
branches:
- trunk
paths:
- '.github/workflows/test-coverage.yml'
- 'phpunit.xml.dist'
- 'tests/phpunit/multisite.xml'
# Once daily at 00:00 UTC.
schedule:
- cron: '0 0 * * *'
# Allow manually triggering the workflow.
workflow_dispatch:
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
LOCAL_PHP: '7.4-fpm'
LOCAL_PHP_XDEBUG: true
LOCAL_PHP_MEMCACHED: ${{ false }}
jobs:
# Sets up WordPress for testing or development use.
#
# Performs the following steps:
# - Set environment variables.
# - Checks out the repository.
# - Checks out the WordPress Importer plugin (needed for the Core PHPUnit tests).
# - Logs debug information about the runner container.
# - Installs NodeJS 14.
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
# - Logs Docker debug information (about the Docker installation within the runner).
# - Starts the WordPress Docker container.
# - Logs debug general information.
# - Logs the running Docker containers.
# - Logs WordPress Docker container debug information.
# - Logs debug information about what's installed within the WordPress Docker containers.
# - Install WordPress within the Docker container.
# - Run the PHPUnit tests as a single site.
# - Ensures version-controlled files are not modified or deleted.
# - Upload the single site code coverage report to Codecov.io.
# - Run the PHPUnit tests as a multisite.
# - Ensures version-controlled files are not modified or deleted.
# - Upload the multisite code coverage report to Codecov.io.
test-coverage-report:
name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report
runs-on: ubuntu-latest
timeout-minutes: 120
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
strategy:
fail-fast: false
matrix:
multisite: [ false, true ]
steps:
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
- name: Log debug information
run: |
echo "$GITHUB_REF"
echo "$GITHUB_EVENT_NAME"
npm --version
node --version
curl --version
git --version
svn --version
php --version
php -i
locale -a
- name: Install NodeJS
uses: actions/setup-node@270253e841af726300e85d718a5f606959b2903c # v2.4.1
with:
node-version: 14
cache: npm
- name: Install Dependencies
run: npm ci
# This date is used to ensure that the Composer cache is refreshed at least once every week.
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer dependencies
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-date-${{ steps.get-date.outputs.date }}-composer-${{ hashFiles('**/composer.json') }}
- name: Install Composer dependencies
run: |
docker-compose run --rm php composer --version
# Install using `composer update` as there is no `composer.lock` file.
docker-compose run --rm php composer update
- name: Docker debug information
run: |
docker -v
docker-compose -v
- name: Start Docker environment
run: |
npm run env:start
- name: General debug information
run: |
npm --version
node --version
curl --version
git --version
svn --version
- name: Log running Docker containers
run: docker ps -a
- name: WordPress Docker container debug information
run: |
docker-compose run --rm mysql mysql --version
docker-compose run --rm php php --version
docker-compose run --rm php php -m
docker-compose run --rm php php -i
docker-compose run --rm php locale -a
- name: Install WordPress
run: npm run env:install
- name: Run tests as a single site
if: ${{ ! matrix.multisite }}
run: npm run test:php -- --verbose -c phpunit.xml.dist --coverage-clover wp-code-coverage-single-clover-${{ github.sha }}.xml
- name: Ensure version-controlled files are not modified during the tests
run: git diff --exit-code
- name: Upload single site report to Codecov
if: ${{ ! matrix.multisite }}
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
file: wp-code-coverage-single-clover-${{ github.sha }}.xml
flags: single,php
- name: Run tests as a multisite install
if: ${{ matrix.multisite }}
run: npm run test:php -- --verbose -c tests/phpunit/multisite.xml --coverage-clover wp-code-coverage-multisite-clover-${{ github.sha }}.xml
- name: Ensure version-controlled files are not modified during the tests
run: git diff --exit-code
- name: Upload multisite report to Codecov
if: ${{ matrix.multisite }}
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
file: wp-code-coverage-multisite-clover-${{ github.sha }}.xml
flags: multisite,php
slack-notifications:
name: Slack Notifications
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
needs: [ test-coverage-report ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ needs.test-coverage-report.result == 'success' && 'success' || needs.test-coverage-report.result == 'cancelled' && 'cancelled' || 'failure' }}
secrets:
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}

View File

@ -1,4 +1,4 @@
name: Test NPM
name: Test npm
on:
push:
@ -6,17 +6,20 @@ on:
- trunk
- '3.[7-9]'
- '[4-9].[0-9]'
tags:
- '[0-9]+.[0-9]'
- '[0-9]+.[0-9].[0-9]+'
pull_request:
branches:
- trunk
- '3.[7-9]'
- '[4-9].[0-9]'
paths:
# These files configure NPM. Changes could affect the outcome.
# These files configure npm. Changes could affect the outcome.
- 'package*.json'
# JavaScript files are built using NPM.
# JavaScript files are built using npm.
- '**.js'
# CSS and SCSS files are built using NPM.
# CSS and SCSS files are built using npm.
- '**.scss'
- '**.css'
# Changes to workflow files should always verify all workflows are successful.
@ -34,13 +37,13 @@ env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
jobs:
# Verifies that installing NPM dependencies and building WordPress works as expected.
# Verifies that installing npm dependencies and building WordPress works as expected.
#
# Performs the following steps:
# - Checks out the repository.
# - Logs debug information about the GitHub Action runner.
# - Installs NodeJS.
# _ Installs NPM dependencies.
# - Installs Node.js.
# _ Installs npm dependencies.
# - Builds WordPress to run from the `build` directory.
# - Cleans up after building WordPress to the `build` directory.
# - Ensures version-controlled files are not modified or deleted.
@ -48,7 +51,7 @@ jobs:
# - Cleans up after building WordPress to the `src` directory.
# - Ensures version-controlled files are not modified or deleted.
test-npm:
name: Test NPM on ${{ matrix.os }}
name: Test npm on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
@ -59,7 +62,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Log debug information
run: |
@ -69,8 +72,8 @@ jobs:
git --version
svn --version
- name: Install NodeJS
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
- name: Install Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: '.nvmrc'
cache: npm
@ -96,16 +99,20 @@ jobs:
- name: Ensure version-controlled files are not modified or deleted during building and cleaning
run: git diff --exit-code
# Verifies that installing NPM dependencies and building WordPress works as expected on MacOS.
# Verifies that installing npm dependencies and building WordPress works as expected on MacOS.
#
# This is separate from the job above in order to use stricter conditions about when to run.
# This avoids unintentionally consuming excessive minutes, as MacOS jobs consume minutes at a 10x rate.
#
# The `matrix` and `runner` contexts are not available for use within `if` expressions. So there is
# currently no way to determine the OS being used on a given job.
# See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability.
#
# Performs the following steps:
# - Checks out the repository.
# - Logs debug information about the GitHub Action runner.
# - Installs NodeJS.
# _ Installs NPM dependencies.
# - Installs Node.js.
# _ Installs npm dependencies.
# - Builds WordPress to run from the `build` directory.
# - Cleans up after building WordPress to the `build` directory.
# - Ensures version-controlled files are not modified or deleted.
@ -113,13 +120,13 @@ jobs:
# - Cleans up after building WordPress to the `src` directory.
# - Ensures version-controlled files are not modified or deleted.
test-npm-macos:
name: Test NPM on MacOS
name: Test npm on MacOS
runs-on: macos-latest
timeout-minutes: 20
timeout-minutes: 30
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
steps:
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Log debug information
run: |
@ -129,8 +136,8 @@ jobs:
git --version
svn --version
- name: Install NodeJS
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0
- name: Install Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version-file: '.nvmrc'
cache: npm
@ -168,3 +175,34 @@ jobs:
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
needs: [ test-npm, test-npm-macos, slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
needs.test-npm.result == 'cancelled' || needs.test-npm.result == 'failure' ||
needs.test-npm-macos.result == 'cancelled' || needs.test-npm-macos.result == 'failure'
)
steps:
- name: Dispatch workflow run
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'failed-workflow.yml',
ref: 'trunk',
inputs: {
run_id: '${{ github.run_id }}'
}
});

View File

@ -1,84 +0,0 @@
name: Test old branches
on:
# Verify the workflow is successful when this file is updated.
push:
branches:
- trunk
paths:
- '.github/workflows/test-old-branches.yml'
# Run twice a month on the 1st and 15th at 00:00 UTC.
schedule:
- cron: '0 0 1 * *'
- cron: '0 0 15 * *'
jobs:
dispatch-workflows-for-old-branches:
name: ${{ matrix.workflow }} for ${{ matrix.branch }}
runs-on: ubuntu-latest
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
strategy:
fail-fast: false
matrix:
workflow: [
'coding-standards.yml',
'javascript-tests.yml',
'phpunit-tests.yml',
'test-npm.yml'
]
branch: [
'5.8', '5.7', '5.6', '5.5', '5.4', '5.3', '5.2', '5.1', '5.0',
'4.9', '4.8', '4.7', '4.6', '4.5', '4.4', '4.3', '4.2', '4.1', '4.0',
'3.9', '3.8', '3.7'
]
include:
# PHP Compatibility testing was introduced in 5.5.
- branch: '5.8'
workflow: 'php-compatibility.yml'
- branch: '5.7'
workflow: 'php-compatibility.yml'
- branch: '5.6'
workflow: 'php-compatibility.yml'
- branch: '5.5'
workflow: 'php-compatibility.yml'
# End to End testing was introduced in 5.3 but later removed as there were no meaningful assertions.
# Only the officially supported major branch runs E2E tests so that more assertions can be added, and the
# workflow does not continue to run needlessly on old branches.
- branch: '5.8'
workflow: 'end-to-end-tests.yml'
exclude:
# Coding standards and JavaScript testing did not take place in 3.7.
- branch: '3.7'
workflow: 'coding-standards.yml'
- branch: '3.7'
workflow: 'javascript-tests.yml'
# Run all branches monthly, but only the currently supported one twice per month.
steps:
- name: Dispatch workflow run
uses: actions/github-script@441359b1a30438de65712c2fbca0abe4816fa667 # v5.0.0
if: ${{ github.event_name == 'push' || github.event.schedule == '0 0 15 * *' || matrix.branch == '5.7' }}
with:
github-token: ${{ secrets.GHA_OLD_BRANCH_DISPATCH }}
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: '${{ matrix.workflow }}',
ref: '${{ matrix.branch }}'
});
slack-notifications:
name: Slack Notifications
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
needs: [ dispatch-workflows-for-old-branches ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ needs.dispatch-workflows-for-old-branches.result == 'success' && 'success' || needs.dispatch-workflows-for-old-branches.result == 'cancelled' && 'cancelled' || 'failure' }}
secrets:
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}

View File

@ -12,9 +12,8 @@ jobs:
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
steps:
- uses: bubkoo/welcome-action@8dbbac2540d155744c90e4e37da6b05ffc9c5e2c # v1.0.3
- uses: wow-actions/welcome@72817eb31cda1de60f51893d80e2e82ce57f7e76 # v1.3.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FIRST_PR_COMMENT: >
Hi @{{ author }}! 👋