Skip to content
Closed
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
72 changes: 47 additions & 25 deletions .github/workflows/reusable-test-gutenberg-build-process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ on:
default: 'src'

env:
GUTENBERG_CHECKOUT_DIRECTORY: gutenberg-checkout
GUTENBERG_BUILD_DIRECTORY: /tmp/gutenberg-built
GUTENBERG_DIRECTORY: ${{ inputs.directory == 'build' && 'build' || 'src' }}/wp-content/plugins/gutenberg
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
NODE_OPTIONS: '--max-old-space-size=8192'
Expand All @@ -30,15 +32,18 @@ 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.
# - Checks out the Gutenberg plugin to a temporary directory.
# - Sets up Node.js for Gutenberg.
# - Installs Gutenberg npm dependencies.
# - Builds Gutenberg.
# - Moves built Gutenberg to a temporary location.
# - Removes the Gutenberg checkout to avoid npm conflicts.
# - Checks out the wordpress-develop repository.
# - Sets up Node.js for WordPress.
# - Logs debug information about the GitHub Action runner.
# - Installs Core npm dependencies.
# - Installs Gutenberg npm dependencies.
# - Runs the Gutenberg build process.
# - Moves built Gutenberg to the plugins directory.
# - 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' }}
Expand All @@ -48,28 +53,51 @@ jobs:
timeout-minutes: 30

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

- name: Checkout Gutenberg plugin
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: '${{ env.GUTENBERG_CHECKOUT_DIRECTORY }}/.nvmrc'
cache: npm
cache-dependency-path: ${{ env.GUTENBERG_CHECKOUT_DIRECTORY }}/package-lock.json

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

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

- name: Move built Gutenberg to temporary location
shell: bash
run: |
mkdir -p ${{ env.GUTENBERG_BUILD_DIRECTORY }}
cp -rL ${{ env.GUTENBERG_CHECKOUT_DIRECTORY }}/. ${{ env.GUTENBERG_BUILD_DIRECTORY }}/

- name: Remove Gutenberg checkout
shell: bash
run: rm -rf ${{ env.GUTENBERG_CHECKOUT_DIRECTORY }}

- name: Checkout wordpress-develop repository
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
- name: Set up Node.js for WordPress
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: '.nvmrc'
cache: npm
cache-dependency-path: |
package-lock.json
${{ env.GUTENBERG_DIRECTORY }}/package-lock.json
cache-dependency-path: package-lock.json

- name: Log debug information
run: |
Expand All @@ -81,20 +109,14 @@ jobs:
- name: Install Core Dependencies
run: npm ci

- 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: Move built Gutenberg to WordPress plugins directory
shell: bash
run: |
mkdir -p ${{ env.GUTENBERG_DIRECTORY }}
cp -rL ${{ env.GUTENBERG_BUILD_DIRECTORY }}/. ${{ env.GUTENBERG_DIRECTORY }}/

- 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