Skip to content

Commit

Permalink
Build/Test Tools: Switch to using local references for reusable workf…
Browse files Browse the repository at this point in the history
…lows.

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
  • Loading branch information
johnbillion committed Jan 21, 2025
1 parent 41e124a commit f2f13cb
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ 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' }}

# 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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/install-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/javascript-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/local-docker-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' }}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) }}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-and-zip-default-themes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-build-processes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down Expand Up @@ -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' }}
Expand All @@ -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' }}
Expand All @@ -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' }}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-old-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/upgrade-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit f2f13cb

Please sign in to comment.