From 8ba5163b7cb17513715eb44d566a583110f7c5bd Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 10 Mar 2023 16:31:00 +0000 Subject: [PATCH] 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. - backports some Docker environment related tooling updates for the sake of consistency across branches. Merges [53736], [53737], [53940], [53947], [54039], [54096], [54108], [54293], [54313], [54342], [54343], [54373], [54511], [54650], [54651], [54674], [54750], [54852], [55152], [54651], [55487] to the 4.3 branch. See #55652, #56407, #56528, #54695, #56820, #56816, #56793, #56820, #57572. git-svn-id: https://develop.svn.wordpress.org/branches/4.3@55533 602fd350-edb4-49c9-b593-d223f7449a82 --- .env | 4 +- .github/workflows/coding-standards.yml | 45 ++++++++++-- .github/workflows/javascript-tests.yml | 45 ++++++++++-- .github/workflows/phpunit-tests.yml | 60 ++++++++++++---- .github/workflows/test-npm.yml | 71 ++++++++++++++----- .../workflows/welcome-new-contributors.yml | 3 +- docker-compose.yml | 2 +- 7 files changed, 180 insertions(+), 50 deletions(-) diff --git a/.env b/.env index cdcb59cb49..4e47ac4cd9 100644 --- a/.env +++ b/.env @@ -57,8 +57,8 @@ LOCAL_DB_TYPE=mysql # # Defaults to 5.6 with the assumption that LOCAL_DB_TYPE is set to `mysql` above. # -# When using `mysql`, see https://hub.docker.com/_/mysql/ for valid versions. -# When using `mariadb`, see https://hub.docker.com/_/mariadb for valid versions. +# When using `mysql`, see https://hub.docker.com/r/amd64/mysql for valid versions. +# When using `mariadb`, see https://hub.docker.com/r/amd64/mariadb for valid versions. ## LOCAL_DB_VERSION=5.6 diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index b0d2405306..6678d91b16 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -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.*' @@ -49,7 +50,7 @@ jobs: # - Logs debug information about the GitHub Action runner. # - Installs NodeJS. # - Logs updated debug information. - # _ Installs NPM dependencies. + # _ Installs npm dependencies. # - Run the WordPress JSHint checks. jshint: name: JavaScript coding standards @@ -61,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: | @@ -70,8 +71,8 @@ jobs: git --version svn --version - - name: Install NodeJS - uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0 + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: '.nvmrc' cache: npm @@ -99,3 +100,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: [ jshint, slack-notifications ] + if: | + always() && + github.repository == 'WordPress/wordpress-develop' && + github.event_name != 'pull_request' && + github.run_attempt < 2 && + ( + 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 }}' + } + }); diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index c8847c91ff..266ab52a07 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -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' @@ -45,7 +46,7 @@ jobs: # - Logs debug information about the GitHub Action runner. # - Installs NodeJS. # - Logs updated debug information. - # _ Installs NPM dependencies. + # _ Installs npm dependencies. # - Run the WordPress QUnit tests. test-js: name: QUnit Tests @@ -55,7 +56,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: | @@ -64,8 +65,8 @@ jobs: git --version svn --version - - name: Install NodeJS - uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0 + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: '.nvmrc' cache: npm @@ -93,3 +94,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 }}' + } + }); diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index d682766abd..d7e791e38a 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -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 @@ -30,7 +30,7 @@ env: LOCAL_DIR: build PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} COMPOSER_INSTALL: ${{ false }} - # Controls which NPM script to use for running PHPUnit tests. Options ar `php` and `php-composer`. + # Controls which npm script to use for running PHPUnit tests. Options ar `php` and `php-composer`. PHPUNIT_SCRIPT: php LOCAL_PHP_MEMCACHED: ${{ false }} SLOW_TESTS: 'external-http,media' @@ -43,7 +43,7 @@ jobs: # - Checks out the repository. # - Logs debug information about the GitHub Action runner. # - Installs NodeJS. - # _ Installs NPM dependencies. + # _ Installs npm dependencies. # - Builds WordPress to run from the `build` directory. # - Creates a ZIP file of compiled WordPress. # - Uploads ZIP file as an artifact. @@ -54,7 +54,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 +69,8 @@ jobs: php -i locale -a - - name: Install NodeJS - uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0 + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: '.nvmrc' cache: npm @@ -82,13 +82,13 @@ jobs: run: npm run build - name: Create ZIP artifact - uses: thedoctor0/zip-release@09336613be18a8208dfa66bd57efafd9e2685657 # v0.6.2 + uses: thedoctor0/zip-release@a24011d8d445e4da5935a7e73c1f98e22a439464 # v0.7.1 with: filename: built-wp-${{ github.sha }}.zip exclusions: '*.git* /*node_modules/* packagehash.txt' - name: Upload build artifact - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0 + uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: name: built-wp-${{ github.sha }} path: built-wp-${{ github.sha }}.zip @@ -102,7 +102,7 @@ jobs: # - Downloads the built WordPress artifact from the previous job. # - Unzips the artifact. # - Installs NodeJS. - # _ Installs NPM dependencies. + # _ Installs npm dependencies. # - Configures caching for Composer. # _ Installs Composer dependencies (if desired). # - Logs Docker debug information (about the Docker installation within the runner). @@ -171,15 +171,15 @@ jobs: echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV - name: Download the built WordPress artifact - uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0 + uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 with: name: built-wp-${{ github.sha }} - name: Unzip built artifact run: unzip built-wp-${{ github.sha }}.zip - - name: Install NodeJS - uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0 + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: '.nvmrc' cache: npm @@ -189,7 +189,7 @@ jobs: - name: Cache Composer dependencies if: ${{ env.COMPOSER_INSTALL == true }} - uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4 + uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6 env: cache-name: cache-composer-dependencies with: @@ -270,7 +270,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' @@ -301,3 +301,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 }}' + } + }); diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index 9dceb2243e..cc0013808f 100644 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -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,17 +37,17 @@ 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 npm dependencies. # - Builds WordPress to run from the `build` directory. # - Cleans up after building WordPress to the `build` directory. 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' }} @@ -55,7 +58,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 +68,8 @@ jobs: git --version svn --version - - name: Install NodeJS - uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0 + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: '.nvmrc' cache: npm @@ -80,25 +83,30 @@ jobs: - name: Clean after building run: npm run grunt clean - # 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 npm dependencies. # - Builds WordPress to run from the `build` directory. # - Cleans up after building WordPress to the `build` directory. test-npm-macos: - name: Test NPM on MacOS + name: Test npm on MacOS runs-on: macos-latest + 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: | @@ -108,8 +116,8 @@ jobs: git --version svn --version - - name: Install NodeJS - uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # v3.3.0 + - name: Set up Node.js + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version-file: '.nvmrc' cache: npm @@ -135,3 +143,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 }}' + } + }); diff --git a/.github/workflows/welcome-new-contributors.yml b/.github/workflows/welcome-new-contributors.yml index 44ddf0b02d..15457f65bd 100644 --- a/.github/workflows/welcome-new-contributors.yml +++ b/.github/workflows/welcome-new-contributors.yml @@ -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 }}! 👋 diff --git a/docker-compose.yml b/docker-compose.yml index c9cb014cb3..a68a894422 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,7 +53,7 @@ services: # The MySQL container. ## mysql: - image: ${LOCAL_DB_TYPE-mysql}:${LOCAL_DB_VERSION-5.6} + image: amd64/${LOCAL_DB_TYPE-mysql}:${LOCAL_DB_VERSION-5.6} networks: - wpdevnet