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
28 changes: 28 additions & 0 deletions .github/workflows/reusable-phpunit-tests-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ on:
required: false
type: 'string'
default: 'ubuntu-24.04'
repository:
description: 'The repository to check out and test. Defaults to the repository calling this workflow.'
required: false
type: 'string'
default: ''
ref:
description: 'The branch, tag, or SHA to check out. Defaults to the ref that triggered the calling workflow.'
required: false
type: 'string'
default: ''
php:
description: 'The version of PHP to use, in the format of X.Y'
required: true
Expand Down Expand Up @@ -82,6 +92,11 @@ on:
required: false
type: string
default: ''
overlay-artifact:
description: 'The name of a same-workflow artifact whose contents are unpacked over the checkout. Optional: for callers whose test files are not part of the repository being tested.'
required: false
type: string
default: ''
secrets:
CODECOV_TOKEN:
description: 'The Codecov token required for uploading reports.'
Expand Down Expand Up @@ -111,6 +126,7 @@ jobs:
# Performs the following steps:
# - Sets environment variables.
# - Checks out the repository.
# - Unpacks the caller-provided overlay artifact over the checkout, if any.
# - Downloads the prepared Gutenberg build provided by the calling workflow.
# - Sets up Node.js.
# - Sets up PHP.
Expand Down Expand Up @@ -143,9 +159,21 @@ jobs:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

# If the caller specifies an overlay artifact then unpack it over the checkout.
- name: Download overlay artifact
if: inputs.overlay-artifact != ''
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
# Without a run ID, this action reads only from the caller's current workflow run.
name: ${{ inputs.overlay-artifact }}
path: .
digest-mismatch: error

# Branches >= 5.9 call this workflow at @trunk without the producer job, so they
# pass no artifact. They skip this step and fall back to a per-job download.
- name: Download prepared Gutenberg build
Expand Down
36 changes: 32 additions & 4 deletions .github/workflows/reusable-prepare-gutenberg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ name: Prepare Gutenberg build

on:
workflow_call:
inputs:
repository:
description: 'The repository to check out. Defaults to the repository calling this workflow.'
required: false
type: 'string'
default: ''
ref:
description: 'The branch, tag, or SHA to check out. Defaults to the commit that started the calling workflow run.'
required: false
type: 'string'
default: ''
artifact-name:
description: 'The name of the uploaded artifact. Callers preparing more than one build per run must give each a unique name.'
required: false
type: 'string'
default: 'gutenberg-build'
outputs:
gutenberg-sha:
description: 'The immutable Gutenberg source SHA verified by this workflow.'
Expand All @@ -29,8 +45,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
# Resolve the Gutenberg ref from the exact commit that started this workflow run.
ref: ${{ github.sha }}
repository: ${{ inputs.repository || github.repository }}
# Resolve the Gutenberg ref from the exact commit that started this workflow run,
# unless the caller is preparing a build for a repository or branch of its own.
ref: ${{ inputs.ref || github.sha }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

Expand All @@ -42,7 +60,17 @@ jobs:
- name: Download and verify Gutenberg build
id: download
run: |
node tools/gutenberg/download.js
# Branches whose download.js predates the in-script retry stream the blob straight
# into tar in a single attempt, so an interrupted stream fails the run outright.
for attempt in 1 2 3; do
node tools/gutenberg/download.js && break
if [ "$attempt" = 3 ]; then
echo "Gutenberg download failed after $attempt attempts." >&2
exit 1
fi
echo "Gutenberg download failed; retrying in 5 seconds..."
sleep 5
done
gutenberg_sha="$(tr -d '\n' < gutenberg/.gutenberg-hash)"
if [[ ! "$gutenberg_sha" =~ ^[a-fA-F0-9]{40}$ ]]; then
echo "Expected a 40-character Gutenberg SHA, received: $gutenberg_sha" >&2
Expand All @@ -53,7 +81,7 @@ jobs:
- name: Upload Gutenberg build
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: gutenberg-build
name: ${{ inputs.artifact-name }}
path: gutenberg/
if-no-files-found: error
include-hidden-files: true
Expand Down
Loading