Skip to content

Commit 505c36f

Browse files
committed
Build/Test Tools: Introduce post-branching Grunt task.
In [59673], a Grunt subtask was introduced to convert workflow file references in GitHub Action workflows from local ones to remote ones that target the `trunk` branch. The `workflow-references-local-to-remote` Grunt task should be run after creating a new numbered branch to take advantage of the work started in [58165]. This commit introduces a new target for the `clean` Grunt task: `workflows`. Running `grunt clean:workflows` will delete all workflow files that are not intended to exist outside of `trunk`. Another Grunt task (`post-branching`) has also been added as a way to group all tasks taht should run within a newly created branch. For now, this contains `clean:workflows` and `replace:workflow-references-local-to-remote`. But more can be added in the future as more aspects of the branching process are automated. Props johnbillion. See #64227. git-svn-id: https://develop.svn.wordpress.org/trunk@61286 602fd350-edb4-49c9-b593-d223f7449a82
1 parent cd301d0 commit 505c36f

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

Gruntfile.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ module.exports = function(grunt) {
5959
'!wp-includes/assets/script-modules-packages.min.php',
6060
],
6161

62+
// All workflow files that should be deleted from non-default branches.
63+
workflowFiles = [
64+
// Reusable workflows should be called from `trunk` within branches.
65+
'.github/workflows/reusable-*.yml',
66+
// These workflows are only intended to run from `trunk`.
67+
'.github/workflows/commit-built-file-changes.yml',
68+
'.github/workflows/failed-workflow.yml',
69+
'.github/workflows/install-testing.yml',
70+
'.github/workflows/test-and-zip-default-themes.yml',
71+
'.github/workflows/install-testing.yml',
72+
'.github/workflows/slack-notifications.yml',
73+
'.github/workflows/test-coverage.yml',
74+
'.github/workflows/test-old-branches.yml',
75+
'.github/workflows/upgrade-testing.yml'
76+
],
77+
6278
// Prepend `dir` to `file`, and keep `!` in place.
6379
setFilePath = function( dir, file ) {
6480
if ( '!' === file.charAt( 0 ) ) {
@@ -216,7 +232,18 @@ module.exports = function(grunt) {
216232
cwd: WORKING_DIR,
217233
src: []
218234
},
219-
qunit: ['tests/qunit/compiled.html']
235+
qunit: ['tests/qunit/compiled.html'],
236+
237+
// This is only meant to run within a numbered branch after branching has occurred.
238+
workflows: {
239+
filter: function() {
240+
var allowedTasks = [ 'post-branching', 'clean:workflows' ];
241+
return allowedTasks.some( function( task ) {
242+
return grunt.cli.tasks.indexOf( task ) !== -1;
243+
} );
244+
},
245+
src: workflowFiles
246+
},
220247
},
221248
file_append: {
222249
// grunt-file-append supports only strings for input and output.
@@ -1708,6 +1735,11 @@ module.exports = function(grunt) {
17081735
'copy:workflow-references-remote-to-local',
17091736
]);
17101737

1738+
grunt.registerTask( 'post-branching', [
1739+
'clean:workflows',
1740+
'replace:workflow-references-local-to-remote'
1741+
]);
1742+
17111743
/**
17121744
* Build verification tasks.
17131745
*/

0 commit comments

Comments
 (0)