Skip to content

Commit 81a4c4c

Browse files
committed
Build/Test Tools: Fix the precommit:emoji script.
GitHub recently sunset support for Subversion, causing the `precommit:emoji` Grunt script to break. Since there’s no direct replacement for `svn ls` in Git, this has been replaced with a query through the GitHub CLI. This also adds a step in the workflow that tests the build process to run the `precommit:emoji` script to ensure no changes to built files are missed when updating the Twemoji library in the future. Follow up to [57626]. Props kraftbj, peterwilsoncc, swissspidy. Fixes #60520. See #57600. git-svn-id: https://develop.svn.wordpress.org/trunk@57758 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 79f570a commit 81a4c4c

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

.github/workflows/callable-test-core-build-process.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ jobs:
6262
- name: Install npm Dependencies
6363
run: npm ci
6464

65+
- name: Run Emoji precommit task
66+
run: npm run grunt precommit:emoji
67+
env:
68+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
6570
- name: Build WordPress to run from ${{ inputs.directory }}
6671
run: npm run build${{ inputs.directory == 'src' && ':dev' || '' }}
6772

Gruntfile.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,19 +1047,34 @@ module.exports = function(grunt) {
10471047
{
10481048
match: /\/\/ START: emoji arrays[\S\s]*\/\/ END: emoji arrays/g,
10491049
replacement: function() {
1050-
var regex, files,
1050+
var regex, files, ghCli,
10511051
partials, partialsSet,
1052-
entities, emojiArray;
1052+
entities, emojiArray,
1053+
apiResponse, query;
10531054

10541055
grunt.log.writeln( 'Fetching list of Twemoji files...' );
10551056

1057+
// Ensure that the GitHub CLI is installed.
1058+
ghCli = spawn( 'gh', [ '--version' ] );
1059+
if ( 0 !== ghCli.status ) {
1060+
grunt.fatal( 'Emoji precommit script requires GitHub CLI. See https://cli.github.com/.' );
1061+
}
1062+
10561063
// Fetch a list of the files that Twemoji supplies.
1057-
files = spawn( 'svn', [ 'ls', 'https://github.com/twitter/twemoji.git/trunk/assets/svg' ] );
1064+
query = 'query={repository(owner: "jdecked", name: "twemoji") {object(expression: "v15.0.3:assets/svg") {... on Tree {entries {name}}}}}';
1065+
files = spawn( 'gh', [ 'api', 'graphql', '-f', query] );
1066+
10581067
if ( 0 !== files.status ) {
10591068
grunt.fatal( 'Unable to fetch Twemoji file list' );
10601069
}
10611070

1062-
entities = files.stdout.toString();
1071+
try {
1072+
apiResponse = JSON.parse( files.stdout.toString() );
1073+
} catch ( e ) {
1074+
grunt.fatal( 'Unable to parse Twemoji file list' );
1075+
}
1076+
entities = apiResponse.data.repository.object.entries;
1077+
entities = entities.reduce( function( accumulator, val ) { return accumulator + val.name + '\n'; }, '' );
10631078

10641079
// Tidy up the file list.
10651080
entities = entities.replace( /\.svg/g, '' );

0 commit comments

Comments
 (0)