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
This commit is contained in:
John Blackbourn 2025-01-21 15:40:51 +00:00
parent 41e124ad55
commit f2f13cbff0
14 changed files with 68 additions and 38 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.
*/