From 88dfb68b1a91ccd33b611a06ed36e8a45d946c76 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 12 Nov 2025 20:44:29 -0500 Subject: [PATCH 1/4] Add a `post-branching` Grunt task This new `post-branching` task is meant for any tasks that should be run immediately after creating a new numbered branch. In addition to the pre-existing `replace:workflow-references-local-to-remote` task, a new `clean:workflows` task is being added that deletes the workflow files that are only intended for `trunk`. --- Gruntfile.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 61f1ccf95da32..38c69dee063a3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -216,7 +216,23 @@ module.exports = function(grunt) { cwd: WORKING_DIR, src: [] }, - qunit: ['tests/qunit/compiled.html'] + qunit: ['tests/qunit/compiled.html'], + + // This is only meant to run within a numberd branch after branching has occurred. + workflows: [ + // Reusable workflows should only be called from `trunk` in branches. + '.github/workflows/reusable-*.yml', + // These workflows are only intended to run from `trunk`. Delete them to avoid any confusion. + '.github/workflows/commit-built-file-changes.yml', + '.github/workflows/failed-workflow.yml', + '.github/workflows/install-testing.yml', + '.github/workflows/test-and-zip-default-themes.yml', + '.github/workflows/install-testing.yml', + '.github/workflows/slack-notifications.yml', + '.github/workflows/test-coverage.yml', + '.github/workflows/test-old-branches.yml', + '.github/workflows/upgrade-testing.yml' + ] }, file_append: { // grunt-file-append supports only strings for input and output. @@ -1708,6 +1724,11 @@ module.exports = function(grunt) { 'copy:workflow-references-remote-to-local', ]); + grunt.registerTask( 'post-branching', [ + 'clean:workflows', + 'replace:workflow-references-local-to-remote' + ]); + /** * Build verification tasks. */ From 05bad4ced459ad57f6268be0cbb814607d38d875 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 12 Nov 2025 21:55:04 -0500 Subject: [PATCH 2/4] Correct typo. --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 38c69dee063a3..dd6ab7a5b9653 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -218,7 +218,7 @@ module.exports = function(grunt) { }, qunit: ['tests/qunit/compiled.html'], - // This is only meant to run within a numberd branch after branching has occurred. + // This is only meant to run within a numbered branch after branching has occurred. workflows: [ // Reusable workflows should only be called from `trunk` in branches. '.github/workflows/reusable-*.yml', From eafa5d53b687e935be980b019fd6493ad353813b Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 12 Nov 2025 22:50:24 -0500 Subject: [PATCH 3/4] Only run `clean:workflows` when intended --- Gruntfile.js | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index dd6ab7a5b9653..0d0ddc0213c4c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -59,6 +59,22 @@ module.exports = function(grunt) { '!wp-includes/assets/script-modules-packages.min.php', ], + // All workflow files that should be deleted in old branches. + workflowFiles = [ + // Reusable workflows should only be called from `trunk` in branches. + '.github/workflows/reusable-*.yml', + // These workflows are only intended to run from `trunk`. + '.github/workflows/commit-built-file-changes.yml', + '.github/workflows/failed-workflow.yml', + '.github/workflows/install-testing.yml', + '.github/workflows/test-and-zip-default-themes.yml', + '.github/workflows/install-testing.yml', + '.github/workflows/slack-notifications.yml', + '.github/workflows/test-coverage.yml', + '.github/workflows/test-old-branches.yml', + '.github/workflows/upgrade-testing.yml' + ] + // Prepend `dir` to `file`, and keep `!` in place. setFilePath = function( dir, file ) { if ( '!' === file.charAt( 0 ) ) { @@ -219,20 +235,15 @@ module.exports = function(grunt) { qunit: ['tests/qunit/compiled.html'], // This is only meant to run within a numbered branch after branching has occurred. - workflows: [ - // Reusable workflows should only be called from `trunk` in branches. - '.github/workflows/reusable-*.yml', - // These workflows are only intended to run from `trunk`. Delete them to avoid any confusion. - '.github/workflows/commit-built-file-changes.yml', - '.github/workflows/failed-workflow.yml', - '.github/workflows/install-testing.yml', - '.github/workflows/test-and-zip-default-themes.yml', - '.github/workflows/install-testing.yml', - '.github/workflows/slack-notifications.yml', - '.github/workflows/test-coverage.yml', - '.github/workflows/test-old-branches.yml', - '.github/workflows/upgrade-testing.yml' - ] + workflows: { + filter: function( filepath ) { + var allowedTasks = [ 'post-branching', 'clean:workflows' ]; + return allowedTasks.some( function( task ) { + return grunt.cli.tasks.indexOf( task ) !== -1; + } ); + }, + src: workflowFiles + }, }, file_append: { // grunt-file-append supports only strings for input and output. From f271c8ff457cec987eddca3f12ca1acd5e54de4a Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Wed, 12 Nov 2025 22:55:51 -0500 Subject: [PATCH 4/4] Fix linting issues. --- Gruntfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0d0ddc0213c4c..ac9602d6e120a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -73,7 +73,7 @@ module.exports = function(grunt) { '.github/workflows/test-coverage.yml', '.github/workflows/test-old-branches.yml', '.github/workflows/upgrade-testing.yml' - ] + ], // Prepend `dir` to `file`, and keep `!` in place. setFilePath = function( dir, file ) { @@ -236,7 +236,7 @@ module.exports = function(grunt) { // This is only meant to run within a numbered branch after branching has occurred. workflows: { - filter: function( filepath ) { + filter: function() { var allowedTasks = [ 'post-branching', 'clean:workflows' ]; return allowedTasks.some( function( task ) { return grunt.cli.tasks.indexOf( task ) !== -1;