From f2f13cbff083e2dd7973565bdb9523f10746085e Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 21 Jan 2025 15:40:51 +0000 Subject: [PATCH] Build/Test Tools: Switch to using local references for reusable workflows. The benefit of this is that when PRs are made to make changes to a reusable workflow, the references doesn't need to be updated to point to the fork in order for the changed workflow to run. A `npm run grunt replace:workflow-references-local-to-remote` command has also been introduced in order to convert these local references back to remote ones. This command can be used to switch release branches over to using remote workflows, as they are currently, so they continue to benefit from workflow changes in trunk without the need for continual backporting to all the branches. Props desrosj, johnbillion Fixes #62416 git-svn-id: https://develop.svn.wordpress.org/trunk@59673 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/coding-standards.yml | 6 ++-- .github/workflows/end-to-end-tests.yml | 4 +-- .github/workflows/install-testing.yml | 4 +-- .github/workflows/javascript-tests.yml | 4 +-- .../workflows/local-docker-environment.yml | 6 ++-- .github/workflows/performance.yml | 4 +-- .github/workflows/php-compatibility.yml | 4 +-- .github/workflows/phpunit-tests.yml | 10 +++---- .../workflows/test-and-zip-default-themes.yml | 2 +- .github/workflows/test-build-processes.yml | 10 +++---- .github/workflows/test-coverage.yml | 4 +-- .github/workflows/test-old-branches.yml | 2 +- .github/workflows/upgrade-testing.yml | 16 +++++----- Gruntfile.js | 30 +++++++++++++++++++ 14 files changed, 68 insertions(+), 38 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 3c9854dc9e..9d68d091e9 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -49,7 +49,7 @@ jobs: # Runs the PHP coding standards checks. phpcs: name: PHP coding standards - uses: WordPress/wordpress-develop/.github/workflows/reusable-coding-standards-php.yml@trunk + uses: ./.github/workflows/reusable-coding-standards-php.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} @@ -57,14 +57,14 @@ jobs: # Runs the JavaScript coding standards checks. jshint: name: JavaScript coding standards - uses: WordPress/wordpress-develop/.github/workflows/reusable-coding-standards-javascript.yml@trunk + uses: ./.github/workflows/reusable-coding-standards-javascript.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/end-to-end-tests.yml b/.github/workflows/end-to-end-tests.yml index d77e439b29..fe516381eb 100644 --- a/.github/workflows/end-to-end-tests.yml +++ b/.github/workflows/end-to-end-tests.yml @@ -38,7 +38,7 @@ jobs: # Runs the end-to-end test suite. e2e-tests: name: Test with SCRIPT_DEBUG ${{ matrix.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-end-to-end-tests.yml@trunk + uses: ./.github/workflows/reusable-end-to-end-tests.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} @@ -51,7 +51,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/install-testing.yml b/.github/workflows/install-testing.yml index f347958e8b..4f3a79aa8f 100644 --- a/.github/workflows/install-testing.yml +++ b/.github/workflows/install-testing.yml @@ -43,7 +43,7 @@ jobs: # Determines the supported values for PHP and database versions based on the WordPress version being tested. build-test-matrix: name: Build Test Matrix - uses: WordPress/wordpress-develop/.github/workflows/reusable-support-json-reader-v1.yml@trunk + uses: ./.github/workflows/reusable-support-json-reader-v1.yml permissions: contents: read secrets: inherit @@ -132,7 +132,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/javascript-tests.yml b/.github/workflows/javascript-tests.yml index 5872bc5b16..e2766e6fa8 100644 --- a/.github/workflows/javascript-tests.yml +++ b/.github/workflows/javascript-tests.yml @@ -47,14 +47,14 @@ jobs: # Runs the WordPress Core JavaScript tests. test-js: name: QUnit Tests - uses: WordPress/wordpress-develop/.github/workflows/reusable-javascript-tests.yml@trunk + uses: ./.github/workflows/reusable-javascript-tests.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/local-docker-environment.yml b/.github/workflows/local-docker-environment.yml index 09b212e90e..61676269b1 100644 --- a/.github/workflows/local-docker-environment.yml +++ b/.github/workflows/local-docker-environment.yml @@ -63,7 +63,7 @@ jobs: # build-test-matrix: name: Build Test Matrix - uses: WordPress/wordpress-develop/.github/workflows/reusable-support-json-reader-v1.yml@trunk + uses: ./.github/workflows/reusable-support-json-reader-v1.yml permissions: contents: read secrets: inherit @@ -74,7 +74,7 @@ jobs: # Tests the local Docker environment. environment-tests-mysql: name: PHP ${{ matrix.php }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-test-local-docker-environment-v1.yml@trunk + uses: ./.github/workflows/reusable-test-local-docker-environment-v1.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} @@ -108,7 +108,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index dbb672a30d..731d171917 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -33,7 +33,7 @@ jobs: # Runs the performance test suite. performance: name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-performance.yml@trunk + uses: ./.github/workflows/reusable-performance.yml permissions: contents: read if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) }} @@ -50,7 +50,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/php-compatibility.yml b/.github/workflows/php-compatibility.yml index eb4163edf3..3dbd97b7be 100644 --- a/.github/workflows/php-compatibility.yml +++ b/.github/workflows/php-compatibility.yml @@ -44,14 +44,14 @@ jobs: # Runs PHP compatibility testing. php-compatibility: name: Check PHP compatibility - uses: WordPress/wordpress-develop/.github/workflows/reusable-php-compatibility.yml@trunk + uses: ./.github/workflows/reusable-php-compatibility.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 3fe069b709..8c5e325722 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -36,7 +36,7 @@ jobs: # test-with-mysql: name: PHP ${{ matrix.php }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk + uses: ./.github/workflows/reusable-phpunit-tests-v3.yml permissions: contents: read secrets: inherit @@ -107,7 +107,7 @@ jobs: # test-with-mariadb: name: PHP ${{ matrix.php }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk + uses: ./.github/workflows/reusable-phpunit-tests-v3.yml permissions: contents: read secrets: inherit @@ -157,7 +157,7 @@ jobs: # test-innovation-releases: name: PHP ${{ matrix.php }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk + uses: ./.github/workflows/reusable-phpunit-tests-v3.yml permissions: contents: read secrets: inherit @@ -200,7 +200,7 @@ jobs: # specific-test-groups: name: ${{ matrix.phpunit-test-groups }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk + uses: ./.github/workflows/reusable-phpunit-tests-v3.yml permissions: contents: read secrets: inherit @@ -220,7 +220,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/test-and-zip-default-themes.yml b/.github/workflows/test-and-zip-default-themes.yml index c7e7b3012f..8a68016a31 100644 --- a/.github/workflows/test-and-zip-default-themes.yml +++ b/.github/workflows/test-and-zip-default-themes.yml @@ -198,7 +198,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/test-build-processes.yml b/.github/workflows/test-build-processes.yml index a7b6e2f924..bd0acbb456 100644 --- a/.github/workflows/test-build-processes.yml +++ b/.github/workflows/test-build-processes.yml @@ -31,7 +31,7 @@ jobs: # Tests the WordPress Core build process on multiple operating systems. test-core-build-process: name: Core running from ${{ matrix.directory }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-test-core-build-process.yml@trunk + uses: ./.github/workflows/reusable-test-core-build-process.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} @@ -63,7 +63,7 @@ jobs: # See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability. test-core-build-process-macos: name: Core running from ${{ matrix.directory }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-test-core-build-process.yml@trunk + uses: ./.github/workflows/reusable-test-core-build-process.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' }} @@ -79,7 +79,7 @@ jobs: # Tests the Gutenberg plugin build process on multiple operating systems when run within a wordpress-develop checkout. test-gutenberg-build-process: name: Gutenberg running from ${{ matrix.directory }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-test-gutenberg-build-process.yml@trunk + uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} @@ -102,7 +102,7 @@ jobs: # See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability. test-gutenberg-build-process-macos: name: Gutenberg running from ${{ matrix.directory }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-test-gutenberg-build-process.yml@trunk + uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' }} @@ -117,7 +117,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index 3240671b8a..4ddfdeae80 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -49,7 +49,7 @@ jobs: # test-coverage-report: name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report - uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk + uses: ./.github/workflows/reusable-phpunit-tests-v3.yml permissions: contents: read if: ${{ github.repository == 'WordPress/wordpress-develop' }} @@ -67,7 +67,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml index 85a7000bcf..29c7aeac25 100644 --- a/.github/workflows/test-old-branches.yml +++ b/.github/workflows/test-old-branches.yml @@ -132,7 +132,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/.github/workflows/upgrade-testing.yml b/.github/workflows/upgrade-testing.yml index 9ee2665b0b..81037ba371 100644 --- a/.github/workflows/upgrade-testing.yml +++ b/.github/workflows/upgrade-testing.yml @@ -57,7 +57,7 @@ jobs: # Tests the full list of PHP/MySQL combinations for the last two versions of WordPress. upgrade-tests-last-two-releases: name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk + uses: ./.github/workflows/reusable-upgrade-testing.yml if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} permissions: contents: read @@ -94,7 +94,7 @@ jobs: # Tests the remaining 6.x releases on the oldest and newest supported versions of PHP 7 & 8. upgrade-tests-wp-6x-mysql: name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk + uses: ./.github/workflows/reusable-upgrade-testing.yml if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} permissions: contents: read @@ -126,7 +126,7 @@ jobs: # Tests 5.x releases where the WordPress database version changed on the oldest and newest supported versions of PHP 7. upgrade-tests-wp-5x-php-7x-mysql: name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk + uses: ./.github/workflows/reusable-upgrade-testing.yml if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} strategy: fail-fast: false @@ -160,7 +160,7 @@ jobs: # - array/string offset with curly braces. upgrade-tests-wp-5x-php-8x-mysql: name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk + uses: ./.github/workflows/reusable-upgrade-testing.yml if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} strategy: fail-fast: false @@ -185,7 +185,7 @@ jobs: # The oldest version of WordPress receiving security updates should always be tested. upgrade-tests-wp-4x-php-7x-mysql: name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk + uses: ./.github/workflows/reusable-upgrade-testing.yml if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} strategy: fail-fast: false @@ -221,7 +221,7 @@ jobs: # - array/string offset with curly braces. upgrade-tests-wp-4x-php-8x-mysql: name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk + uses: ./.github/workflows/reusable-upgrade-testing.yml if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} strategy: fail-fast: false @@ -245,7 +245,7 @@ jobs: # the full list of PHP/MySQL combinations. upgrade-tests-oldest-wp-mysql: name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }} - uses: WordPress/wordpress-develop/.github/workflows/reusable-upgrade-testing.yml@trunk + uses: ./.github/workflows/reusable-upgrade-testing.yml if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }} strategy: fail-fast: false @@ -279,7 +279,7 @@ jobs: slack-notifications: name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk + uses: ./.github/workflows/slack-notifications.yml permissions: actions: read contents: read diff --git a/Gruntfile.js b/Gruntfile.js index 4f8a3d6aa2..10b3bcfbab 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -456,6 +456,28 @@ module.exports = function(grunt) { } ); } } + }, + 'workflow-references-local-to-remote': { + options: { + processContent: function( src ) { + return src.replace( /uses: \.\/\.github\/workflows\/([^\.]+)\.yml/g, function( match, $1 ) { + return 'uses: WordPress/wordpress-develop/.github/workflows/' + $1 + '.yml@trunk'; + } ); + } + }, + src: '.github/workflows/*.yml', + dest: './' + }, + 'workflow-references-remote-to-local': { + options: { + processContent: function( src ) { + return src.replace( /uses: WordPress\/wordpress-develop\/\.github\/workflows\/([^\.]+)\.yml@trunk/g, function( match, $1 ) { + return 'uses: ./.github/workflows/' + $1 + '.yml'; + } ); + } + }, + src: '.github/workflows/*.yml', + dest: './' } }, sass: { @@ -1513,6 +1535,14 @@ module.exports = function(grunt) { 'copy:version', ] ); + grunt.registerTask( 'replace:workflow-references-local-to-remote', [ + 'copy:workflow-references-local-to-remote', + ]); + + grunt.registerTask( 'replace:workflow-references-remote-to-local', [ + 'copy:workflow-references-remote-to-local', + ]); + /** * Build verification tasks. */