Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/reusable-phpunit-tests-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ jobs:
- name: Install npm dependencies
run: npm ci

- name: Build WordPress
run: npm run build:dev

- name: General debug information
run: |
npm --version
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/reusable-test-core-build-process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ on:

env:
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
NODE_OPTIONS: --max-old-space-size=4096

# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/reusable-test-gutenberg-build-process.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
##
# A reusable workflow that tests the Gutenberg plugin build process when run within a wordpress-develop checkout.
##
name: Test the Gutenberg plugin Build Process

on:
workflow_call:
inputs:
os:
description: 'Operating system to run tests on'
required: false
type: 'string'
default: 'ubuntu-24.04'
directory:
description: 'Directory to run WordPress from. Valid values are `src` or `build`'
required: false
type: 'string'
default: 'src'

env:
GUTENBERG_DIRECTORY: ${{ inputs.directory == 'build' && 'build' || 'src' }}/wp-content/plugins/gutenberg
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
NODE_OPTIONS: '--max-old-space-size=8192'

# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}

jobs:
# Verifies that installing npm dependencies and building the Gutenberg plugin works as expected.
#
# Performs the following steps:
# - Checks out the repository.
# - Checks out the Gutenberg plugin into the plugins directory.
# - Sets up Node.js.
# - Logs debug information about the GitHub Action runner.
# - Installs Gutenberg npm dependencies.
# - Runs the Gutenberg build process.
# - Installs Core npm dependencies.
# - Builds WordPress to run from the relevant location (src or build).
# - Builds Gutenberg.
# - Ensures version-controlled files are not modified or deleted.
build-process-tests:
name: ${{ contains( inputs.os, 'macos-' ) && 'MacOS' || contains( inputs.os, 'windows-' ) && 'Windows' || 'Linux' }}
permissions:
contents: read
runs-on: ${{ inputs.os }}
timeout-minutes: 30

steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Checkout Gutenberg plugin
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: 'WordPress/gutenberg'
path: ${{ env.GUTENBERG_DIRECTORY }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Set up Node.js
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version-file: '.nvmrc'
cache: npm
cache-dependency-path: |
package-lock.json
${{ env.GUTENBERG_DIRECTORY }}/package-lock.json

- name: Log debug information
run: |
npm --version
node --version
curl --version
git --version

- name: Install Gutenberg Dependencies
run: npm ci
working-directory: ${{ env.GUTENBERG_DIRECTORY }}

- name: Build Gutenberg
run: npm run build
working-directory: ${{ env.GUTENBERG_DIRECTORY }}

- name: Install Core Dependencies
run: npm ci

- name: Build WordPress to run from ${{ inputs.directory }}
run: npm run ${{ inputs.directory == 'src' && 'build:dev' || 'build' }}

- name: Run Gutenberg build script after building Core to run from ${{ inputs.directory }}
run: npm run build
working-directory: ${{ env.GUTENBERG_DIRECTORY }}

- name: Ensure version-controlled files are not modified or deleted during building
run: git diff --exit-code
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ jobs:
- name: Install npm dependencies
run: npm ci

- name: Build WordPress
run: npm run build:dev

- name: General debug information
run: |
npm --version
Expand Down
44 changes: 43 additions & 1 deletion .github/workflows/test-build-processes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ on:
# Confirm any changes to relevant workflow files.
- '.github/workflows/test-build-processes.yml'
- '.github/workflows/reusable-test-core-build-process.yml'
- '.github/workflows/reusable-test-gutenberg-build-process.yml'
workflow_dispatch:

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

# Tests the Gutenberg plugin build process within a wordpress-develop checkout.
test-gutenberg-build-process:
name: Gutenberg running from ${{ matrix.directory }}
uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml
permissions:
contents: read
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-24.04' ]
directory: [ 'src', 'build' ]
with:
os: ${{ matrix.os }}
directory: ${{ matrix.directory }}

# Tests the Gutenberg plugin build process on additional operating systems.
#
# This is separate from the job above in order to use stricter conditions when determining when to test additional
# operating systems. This avoids unintentionally consuming excessive minutes. Windows-based jobs consume minutes at a
# 2x rate, and MacOS-based jobs at a 10x rate.
# See https://docs.github.com/en/billing/concepts/product-billing/github-actions#per-minute-rates.
#
# The `matrix` and `runner` contexts are not available for use within `if` expressions. So there is
# currently no way to determine the OS being used on a given job.
# See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability.
test-gutenberg-build-process-additional-os:
name: Gutenberg running from ${{ matrix.directory }}
uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml
permissions:
contents: read
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
strategy:
fail-fast: false
matrix:
os: [ 'macos-15', 'windows-2025' ]
directory: [ 'src', 'build' ]
with:
os: ${{ matrix.os }}
directory: ${{ matrix.directory }}

slack-notifications:
name: Slack Notifications
uses: ./.github/workflows/slack-notifications.yml
permissions:
actions: read
contents: read
needs: [ test-core-build-process, test-core-build-process-additional-os ]
needs: [ test-core-build-process, test-core-build-process-additional-os, test-gutenberg-build-process, test-gutenberg-build-process-additional-os ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
Expand Down
13 changes: 5 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ wp-tests-config.php
/node_modules
/npm-debug.log
/build
/gutenberg
/tests/phpunit/build
/wp-cli.local.yml
/jsdoc
Expand All @@ -31,17 +30,15 @@ wp-tests-config.php
/src/wp-admin/css/colors/*/*.css
/src/wp-admin/js
/src/wp-includes/assets/*
!/src/wp-includes/assets/script-loader-packages.min.php
!/src/wp-includes/assets/script-modules-packages.min.php
/src/wp-includes/js
/src/wp-includes/css/dist
/src/wp-includes/css/*.min.css
/src/wp-includes/css/*-rtl.css
/src/wp-includes/blocks/*
!/src/wp-includes/blocks/index.php
/src/wp-includes/build
/src/wp-includes/class-wp-block-parser.php
/src/wp-includes/class-wp-block-parser-block.php
/src/wp-includes/class-wp-block-parser-frame.php
/src/wp-includes/theme.json
/src/wp-includes/blocks/**/*.css
/src/wp-includes/blocks/**/*.js
/src/wp-includes/blocks/**/*.js.map
/packagehash.txt
/artifacts
/setup.log
Expand Down
83 changes: 19 additions & 64 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* globals Set */
var webpackConfig = require( './webpack.config' );
var installChanged = require( 'install-changed' );
var json2php = require( 'json2php' );

module.exports = function(grunt) {
var path = require('path'),
Expand Down Expand Up @@ -1278,14 +1279,6 @@ module.exports = function(grunt) {
BUILD_DIR + 'wp-includes/js/dist/commands.js',
],
dest: BUILD_DIR + 'wp-includes/js/dist/'
},
{
expand: true,
flatten: true,
src: [
BUILD_DIR + 'wp-includes/js/dist/vendor/**/*.js'
],
dest: BUILD_DIR + 'wp-includes/js/dist/vendor/'
}
]
}
Expand Down Expand Up @@ -1421,58 +1414,6 @@ module.exports = function(grunt) {
grunt.task.run( 'wp-packages:refresh-deps' );
} );

// Gutenberg integration tasks.
grunt.registerTask( 'gutenberg-checkout', 'Checks out the Gutenberg repository.', function() {
const done = this.async();
grunt.util.spawn( {
cmd: 'node',
args: [ 'tools/gutenberg/checkout-gutenberg.js' ],
opts: { stdio: 'inherit' }
}, function( error ) {
done( ! error );
} );
} );

grunt.registerTask( 'gutenberg-build', 'Builds the Gutenberg repository.', function() {
const done = this.async();
grunt.util.spawn( {
cmd: 'node',
args: [ 'tools/gutenberg/build-gutenberg.js' ],
opts: { stdio: 'inherit' }
}, function( error ) {
done( ! error );
} );
} );

grunt.registerTask( 'gutenberg-copy', 'Copies Gutenberg build output to WordPress Core.', function() {
const done = this.async();
const buildDir = grunt.option( 'dev' ) ? 'src' : 'build';
grunt.util.spawn( {
cmd: 'node',
args: [ 'tools/gutenberg/copy-gutenberg-build.js', `--build-dir=${ buildDir }` ],
opts: { stdio: 'inherit' }
}, function( error ) {
done( ! error );
} );
} );

grunt.registerTask( 'gutenberg-integrate', 'Complete Gutenberg integration workflow.', [
'gutenberg-build',
'gutenberg-copy'
] );

grunt.registerTask( 'copy-vendor-scripts', 'Copies vendor scripts from node_modules to wp-includes/js/dist/vendor/.', function() {
const done = this.async();
const buildDir = grunt.option( 'dev' ) ? 'src' : 'build';
grunt.util.spawn( {
cmd: 'node',
args: [ 'tools/vendors/copy-vendors.js', `--build-dir=${ buildDir }` ],
opts: { stdio: 'inherit' }
}, function( error ) {
done( ! error );
} );
} );

grunt.renameTask( 'watch', '_watch' );

grunt.registerTask( 'watch', function() {
Expand Down Expand Up @@ -1628,6 +1569,23 @@ module.exports = function(grunt) {
}
} );

grunt.registerTask( 'copy:block-json', 'Copies block.json file contents to block-json.php.', function() {
var blocks = {};
grunt.file.recurse( SOURCE_DIR + 'wp-includes/blocks', function( abspath, rootdir, subdir, filename ) {
if ( /^block\.json$/.test( filename ) ) {
blocks[ subdir ] = grunt.file.readJSON( abspath );
}
} );
grunt.file.write(
SOURCE_DIR + 'wp-includes/blocks/blocks-json.php',
'<?php return ' + json2php.make( {
linebreak: '\n',
indent: ' ',
shortArraySyntax: false
} )( blocks ) + ';'
);
} );

grunt.registerTask( 'copy:js', [
'copy:npm-packages',
'copy:vendor-js',
Expand Down Expand Up @@ -1765,6 +1723,7 @@ module.exports = function(grunt) {
grunt.registerTask( 'build:files', [
'clean:files',
'copy:files',
'copy:block-json',
'copy:version',
] );

Expand Down Expand Up @@ -1894,8 +1853,6 @@ module.exports = function(grunt) {
grunt.task.run( [
'build:js',
'build:css',
'gutenberg-integrate',
'copy-vendor-scripts',
'build:certificates'
] );
} else {
Expand All @@ -1904,8 +1861,6 @@ module.exports = function(grunt) {
'build:files',
'build:js',
'build:css',
'gutenberg-integrate',
'copy-vendor-scripts',
'replace:source-maps',
'verify:build'
] );
Expand Down
Loading
Loading