From 8e15999eff4a423b2e24154ba82c69ebb777a977 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 26 Mar 2021 13:16:23 +0000 Subject: [PATCH] Build/Test Tools: Run test workflows on old branches on a schedule. On TravisCI, old branches still receiving security updates were tested on a regular basis. This ensured tests continued to pass as time passed even if updates were not made to these branches. On GitHub Actions, there is no interface to configure this (TravisCI had a UI), but there is a `schedule` event that can trigger workflow runs on cron that can be used to accomplish the same thing. This introduces a workflow file that runs twice a month (on the 1st and 15th) to verify the tests within older branches. Because the `schedule` event only runs within the primary branch, the appropriate workflows in each old branch will be triggered manually through the `workflow_dispatch` trigger using the GitHub REST API. `workflow_dispatch` will need to be added to all workflows in all old branches in order for the event to dispatch successfully. Merges [50590] to the 5.7 branch. See #52653. git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50591 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/coding-standards.yml | 1 + .github/workflows/end-to-end-tests.yml | 1 + .github/workflows/javascript-tests.yml | 1 + .github/workflows/php-compatibility.yml | 1 + .github/workflows/phpunit-tests.yml | 1 + .github/workflows/test-npm.yml | 1 + .github/workflows/test-old-branches.yml | 58 +++++++++++++++++++++++++ 7 files changed, 64 insertions(+) create mode 100644 .github/workflows/test-old-branches.yml diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 8109118f9b..ad81be3290 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -32,6 +32,7 @@ on: - 'phpcs.xml.dist' # Changes to workflow files should always verify all workflows are successful. - '.github/workflows/*.yml' + workflow_dispatch: jobs: # Runs PHP coding standards checks. diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index fb3f281c5e..0a59c51a4c 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -17,6 +17,7 @@ on: - trunk - '5.[3-9]' - '[6-9].[0-9]' + workflow_dispatch: env: LOCAL_DIR: build diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index a2d4758a36..0bf9f5a461 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -30,6 +30,7 @@ on: - 'tests/qunit/**' # Changes to workflow files should always verify all workflows are successful. - '.github/workflows/*.yml' + workflow_dispatch: jobs: # Runs the QUnit tests for WordPress. diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index 0ca0761297..78b63abccf 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -26,6 +26,7 @@ on: - 'phpcompat.xml.dist' # Changes to workflow files should always verify all workflows are successful. - '.github/workflows/*.yml' + workflow_dispatch: jobs: diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index c5b5947785..daf04b146d 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -14,6 +14,7 @@ on: - master - '3.[7-9]' - '[4-9].[0-9]' + workflow_dispatch: # Once weekly On Sundays at 00:00 UTC. schedule: - cron: '0 0 * * 0' diff --git a/.github/workflows/test-npm.yml b/.github/workflows/test-npm.yml index 8a3d9db82e..8362db4c6d 100644 --- a/.github/workflows/test-npm.yml +++ b/.github/workflows/test-npm.yml @@ -23,6 +23,7 @@ on: - '**.css' # Changes to workflow files should always verify all workflows are successful. - '.github/workflows/**.yml' + workflow_dispatch: env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml new file mode 100644 index 0000000000..76aef76dfd --- /dev/null +++ b/.github/workflows/test-old-branches.yml @@ -0,0 +1,58 @@ +name: Test old branches + +on: + # Once weekly On Mondays at 00:00 UTC. + schedule: + - cron: '0 0 1,15 * *' + +jobs: + dispatch-workflows-for-old-branches: + name: ${{ matrix.workflow }} for ${{ matrix.branch }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + workflow: [ + 'coding-standards.yml', + 'javascript-tests.yml', + 'phpunit-tests.yml', + 'test-npm.yml' + ] + branch: [ + '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.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.7' + 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' + + steps: + - name: Dispatch workflow run + uses: actions/github-script@47f7cf65b5ced0830a325f705cad64f2f58dddf7 # v3.1.0 + with: + github-token: ${{ secrets.GHA_OLD_BRANCH_DISPATCH }} + script: | + github.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: '${{ matrix.workflow }}', + ref: '${{ matrix.branch }}' + });