Skip to content

Commit 34a4efa

Browse files
committed
Revert "Build: Update Gutenberg integration to checkout-and-build approach."
This reverts commit 22294af.
1 parent 8f4bc4f commit 34a4efa

235 files changed

Lines changed: 33457 additions & 1996 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/reusable-phpunit-tests-v3.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ jobs:
165165
- name: Install npm dependencies
166166
run: npm ci
167167

168-
- name: Build WordPress
169-
run: npm run build:dev
170-
171168
- name: General debug information
172169
run: |
173170
npm --version

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ on:
3939

4040
env:
4141
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
42-
NODE_OPTIONS: --max-old-space-size=4096
4342

4443
# Disable permissions for all available scopes by default.
4544
# Any needed permissions should be configured at the job level.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
##
2+
# A reusable workflow that tests the Gutenberg plugin build process when run within a wordpress-develop checkout.
3+
##
4+
name: Test the Gutenberg plugin Build Process
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
os:
10+
description: 'Operating system to run tests on'
11+
required: false
12+
type: 'string'
13+
default: 'ubuntu-24.04'
14+
directory:
15+
description: 'Directory to run WordPress from. Valid values are `src` or `build`'
16+
required: false
17+
type: 'string'
18+
default: 'src'
19+
20+
env:
21+
GUTENBERG_DIRECTORY: ${{ inputs.directory == 'build' && 'build' || 'src' }}/wp-content/plugins/gutenberg
22+
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
23+
NODE_OPTIONS: '--max-old-space-size=8192'
24+
25+
# Disable permissions for all available scopes by default.
26+
# Any needed permissions should be configured at the job level.
27+
permissions: {}
28+
29+
jobs:
30+
# Verifies that installing npm dependencies and building the Gutenberg plugin works as expected.
31+
#
32+
# Performs the following steps:
33+
# - Checks out the repository.
34+
# - Checks out the Gutenberg plugin into the plugins directory.
35+
# - Sets up Node.js.
36+
# - Logs debug information about the GitHub Action runner.
37+
# - Installs Gutenberg npm dependencies.
38+
# - Runs the Gutenberg build process.
39+
# - Installs Core npm dependencies.
40+
# - Builds WordPress to run from the relevant location (src or build).
41+
# - Builds Gutenberg.
42+
# - Ensures version-controlled files are not modified or deleted.
43+
build-process-tests:
44+
name: ${{ contains( inputs.os, 'macos-' ) && 'MacOS' || contains( inputs.os, 'windows-' ) && 'Windows' || 'Linux' }}
45+
permissions:
46+
contents: read
47+
runs-on: ${{ inputs.os }}
48+
timeout-minutes: 30
49+
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
53+
with:
54+
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
55+
persist-credentials: false
56+
57+
- name: Checkout Gutenberg plugin
58+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
59+
with:
60+
repository: 'WordPress/gutenberg'
61+
path: ${{ env.GUTENBERG_DIRECTORY }}
62+
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
63+
persist-credentials: false
64+
65+
- name: Set up Node.js
66+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
67+
with:
68+
node-version-file: '.nvmrc'
69+
cache: npm
70+
cache-dependency-path: |
71+
package-lock.json
72+
${{ env.GUTENBERG_DIRECTORY }}/package-lock.json
73+
74+
- name: Log debug information
75+
run: |
76+
npm --version
77+
node --version
78+
curl --version
79+
git --version
80+
81+
- name: Install Gutenberg Dependencies
82+
run: npm ci
83+
working-directory: ${{ env.GUTENBERG_DIRECTORY }}
84+
85+
- name: Build Gutenberg
86+
run: npm run build
87+
working-directory: ${{ env.GUTENBERG_DIRECTORY }}
88+
89+
- name: Install Core Dependencies
90+
run: npm ci
91+
92+
- name: Build WordPress to run from ${{ inputs.directory }}
93+
run: npm run ${{ inputs.directory == 'src' && 'build:dev' || 'build' }}
94+
95+
- name: Run Gutenberg build script after building Core to run from ${{ inputs.directory }}
96+
run: npm run build
97+
working-directory: ${{ env.GUTENBERG_DIRECTORY }}
98+
99+
- name: Ensure version-controlled files are not modified or deleted during building
100+
run: git diff --exit-code

.github/workflows/reusable-test-local-docker-environment-v1.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ jobs:
120120
- name: Install npm dependencies
121121
run: npm ci
122122

123-
- name: Build WordPress
124-
run: npm run build:dev
125-
126123
- name: General debug information
127124
run: |
128125
npm --version

.github/workflows/test-build-processes.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ on:
3232
# Confirm any changes to relevant workflow files.
3333
- '.github/workflows/test-build-processes.yml'
3434
- '.github/workflows/reusable-test-core-build-process.yml'
35+
- '.github/workflows/reusable-test-gutenberg-build-process.yml'
3536
workflow_dispatch:
3637

3738
# Cancels all previous workflow runs for pull requests that have not completed.
@@ -97,13 +98,54 @@ jobs:
9798
os: ${{ matrix.os }}
9899
directory: ${{ matrix.directory }}
99100

101+
# Tests the Gutenberg plugin build process within a wordpress-develop checkout.
102+
test-gutenberg-build-process:
103+
name: Gutenberg running from ${{ matrix.directory }}
104+
uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml
105+
permissions:
106+
contents: read
107+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
108+
strategy:
109+
fail-fast: false
110+
matrix:
111+
os: [ 'ubuntu-24.04' ]
112+
directory: [ 'src', 'build' ]
113+
with:
114+
os: ${{ matrix.os }}
115+
directory: ${{ matrix.directory }}
116+
117+
# Tests the Gutenberg plugin build process on additional operating systems.
118+
#
119+
# This is separate from the job above in order to use stricter conditions when determining when to test additional
120+
# operating systems. This avoids unintentionally consuming excessive minutes. Windows-based jobs consume minutes at a
121+
# 2x rate, and MacOS-based jobs at a 10x rate.
122+
# See https://docs.github.com/en/billing/concepts/product-billing/github-actions#per-minute-rates.
123+
#
124+
# The `matrix` and `runner` contexts are not available for use within `if` expressions. So there is
125+
# currently no way to determine the OS being used on a given job.
126+
# See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability.
127+
test-gutenberg-build-process-additional-os:
128+
name: Gutenberg running from ${{ matrix.directory }}
129+
uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml
130+
permissions:
131+
contents: read
132+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
133+
strategy:
134+
fail-fast: false
135+
matrix:
136+
os: [ 'macos-15', 'windows-2025' ]
137+
directory: [ 'src', 'build' ]
138+
with:
139+
os: ${{ matrix.os }}
140+
directory: ${{ matrix.directory }}
141+
100142
slack-notifications:
101143
name: Slack Notifications
102144
uses: ./.github/workflows/slack-notifications.yml
103145
permissions:
104146
actions: read
105147
contents: read
106-
needs: [ test-core-build-process, test-core-build-process-additional-os ]
148+
needs: [ test-core-build-process, test-core-build-process-additional-os, test-gutenberg-build-process, test-gutenberg-build-process-additional-os ]
107149
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
108150
with:
109151
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}

.gitignore

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ wp-tests-config.php
2020
/node_modules
2121
/npm-debug.log
2222
/build
23-
/gutenberg
2423
/tests/phpunit/build
2524
/wp-cli.local.yml
2625
/jsdoc
@@ -31,18 +30,15 @@ wp-tests-config.php
3130
/src/wp-admin/css/colors/*/*.css
3231
/src/wp-admin/js
3332
/src/wp-includes/assets/*
33+
!/src/wp-includes/assets/script-loader-packages.min.php
34+
!/src/wp-includes/assets/script-modules-packages.min.php
3435
/src/wp-includes/js
3536
/src/wp-includes/css/dist
3637
/src/wp-includes/css/*.min.css
3738
/src/wp-includes/css/*-rtl.css
38-
/src/wp-includes/blocks/*
39-
!/src/wp-includes/blocks/index.php
40-
/src/wp-includes/build
41-
/src/wp-includes/class-wp-block-parser.php
42-
/src/wp-includes/class-wp-block-parser-block.php
43-
/src/wp-includes/class-wp-block-parser-frame.php
44-
/src/wp-includes/theme.json
45-
/src/wp-includes/theme-i18n.json
39+
/src/wp-includes/blocks/**/*.css
40+
/src/wp-includes/blocks/**/*.js
41+
/src/wp-includes/blocks/**/*.js.map
4642
/packagehash.txt
4743
/artifacts
4844
/setup.log

Gruntfile.js

Lines changed: 19 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/* globals Set */
44
var webpackConfig = require( './webpack.config' );
55
var installChanged = require( 'install-changed' );
6+
var json2php = require( 'json2php' );
67

78
module.exports = function(grunt) {
89
var path = require('path'),
@@ -1278,14 +1279,6 @@ module.exports = function(grunt) {
12781279
BUILD_DIR + 'wp-includes/js/dist/commands.js',
12791280
],
12801281
dest: BUILD_DIR + 'wp-includes/js/dist/'
1281-
},
1282-
{
1283-
expand: true,
1284-
flatten: true,
1285-
src: [
1286-
BUILD_DIR + 'wp-includes/js/dist/vendor/**/*.js'
1287-
],
1288-
dest: BUILD_DIR + 'wp-includes/js/dist/vendor/'
12891282
}
12901283
]
12911284
}
@@ -1421,59 +1414,6 @@ module.exports = function(grunt) {
14211414
grunt.task.run( 'wp-packages:refresh-deps' );
14221415
} );
14231416

1424-
// Gutenberg integration tasks.
1425-
grunt.registerTask( 'gutenberg-checkout', 'Checks out the Gutenberg repository.', function() {
1426-
const done = this.async();
1427-
grunt.util.spawn( {
1428-
cmd: 'node',
1429-
args: [ 'tools/gutenberg/checkout-gutenberg.js' ],
1430-
opts: { stdio: 'inherit' }
1431-
}, function( error ) {
1432-
done( ! error );
1433-
} );
1434-
} );
1435-
1436-
grunt.registerTask( 'gutenberg-build', 'Builds the Gutenberg repository.', function() {
1437-
const done = this.async();
1438-
grunt.util.spawn( {
1439-
cmd: 'node',
1440-
args: [ 'tools/gutenberg/build-gutenberg.js' ],
1441-
opts: { stdio: 'inherit' }
1442-
}, function( error ) {
1443-
done( ! error );
1444-
} );
1445-
} );
1446-
1447-
grunt.registerTask( 'gutenberg-copy', 'Copies Gutenberg build output to WordPress Core.', function() {
1448-
const done = this.async();
1449-
const buildDir = grunt.option( 'dev' ) ? 'src' : 'build';
1450-
grunt.util.spawn( {
1451-
cmd: 'node',
1452-
args: [ 'tools/gutenberg/copy-gutenberg-build.js', `--build-dir=${ buildDir }` ],
1453-
opts: { stdio: 'inherit' }
1454-
}, function( error ) {
1455-
done( ! error );
1456-
} );
1457-
} );
1458-
1459-
grunt.registerTask( 'gutenberg-integrate', 'Complete Gutenberg integration workflow.', [
1460-
'gutenberg-checkout',
1461-
'gutenberg-build',
1462-
'gutenberg-copy'
1463-
] );
1464-
1465-
grunt.registerTask( 'copy-vendor-scripts', 'Copies vendor scripts from node_modules to wp-includes/js/dist/vendor/.', function() {
1466-
const done = this.async();
1467-
const buildDir = grunt.option( 'dev' ) ? 'src' : 'build';
1468-
grunt.util.spawn( {
1469-
cmd: 'node',
1470-
args: [ 'tools/vendors/copy-vendors.js', `--build-dir=${ buildDir }` ],
1471-
opts: { stdio: 'inherit' }
1472-
}, function( error ) {
1473-
done( ! error );
1474-
} );
1475-
} );
1476-
14771417
grunt.renameTask( 'watch', '_watch' );
14781418

14791419
grunt.registerTask( 'watch', function() {
@@ -1629,6 +1569,23 @@ module.exports = function(grunt) {
16291569
}
16301570
} );
16311571

1572+
grunt.registerTask( 'copy:block-json', 'Copies block.json file contents to block-json.php.', function() {
1573+
var blocks = {};
1574+
grunt.file.recurse( SOURCE_DIR + 'wp-includes/blocks', function( abspath, rootdir, subdir, filename ) {
1575+
if ( /^block\.json$/.test( filename ) ) {
1576+
blocks[ subdir ] = grunt.file.readJSON( abspath );
1577+
}
1578+
} );
1579+
grunt.file.write(
1580+
SOURCE_DIR + 'wp-includes/blocks/blocks-json.php',
1581+
'<?php return ' + json2php.make( {
1582+
linebreak: '\n',
1583+
indent: ' ',
1584+
shortArraySyntax: false
1585+
} )( blocks ) + ';'
1586+
);
1587+
} );
1588+
16321589
grunt.registerTask( 'copy:js', [
16331590
'copy:npm-packages',
16341591
'copy:vendor-js',
@@ -1766,6 +1723,7 @@ module.exports = function(grunt) {
17661723
grunt.registerTask( 'build:files', [
17671724
'clean:files',
17681725
'copy:files',
1726+
'copy:block-json',
17691727
'copy:version',
17701728
] );
17711729

@@ -1895,8 +1853,6 @@ module.exports = function(grunt) {
18951853
grunt.task.run( [
18961854
'build:js',
18971855
'build:css',
1898-
'gutenberg-integrate',
1899-
'copy-vendor-scripts',
19001856
'build:certificates'
19011857
] );
19021858
} else {
@@ -1905,8 +1861,6 @@ module.exports = function(grunt) {
19051861
'build:files',
19061862
'build:js',
19071863
'build:css',
1908-
'gutenberg-integrate',
1909-
'copy-vendor-scripts',
19101864
'replace:source-maps',
19111865
'verify:build'
19121866
] );

0 commit comments

Comments
 (0)