Skip to content

Commit 4a117c5

Browse files
committed
Consolidate into pre-existing workflow.
1 parent 79a6bd6 commit 4a117c5

5 files changed

Lines changed: 104 additions & 204 deletions

File tree

.github/workflows/check-built-files.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,11 @@ jobs:
4949
uses: ./.github/workflows/reusable-check-built-files.yml
5050
permissions:
5151
contents: read
52+
53+
# Compares the results of the build script with WordPress/WordPress.
54+
compare-build-script-results:
55+
name: Compare built files
56+
uses: reusable-compare-built-files-v1.yml
57+
permissions:
58+
contents: read
59+
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}

.github/workflows/compare-built-files.yml

Lines changed: 0 additions & 96 deletions
This file was deleted.

.github/workflows/pull-request-comments.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request_target:
66
types: [ 'opened', 'synchronize', 'reopened', 'edited' ]
77
workflow_run:
8-
workflows: [ 'Compares Built Files', 'Test Build Processes' ]
8+
workflows: [ 'Check Built Files (PRs)', 'Test Build Processes' ]
99
types:
1010
- completed
1111

@@ -87,6 +87,7 @@ jobs:
8787
if: >
8888
github.repository == 'WordPress/wordpress-develop' &&
8989
github.event.workflow_run.event == 'pull_request' &&
90+
github.event.workflow_run.name == 'Test Build Processes' &&
9091
github.event.workflow_run.conclusion == 'success'
9192
steps:
9293
- name: Download artifact
@@ -190,6 +191,7 @@ jobs:
190191
if: >
191192
github.repository == 'WordPress/wordpress-develop' &&
192193
github.event.workflow_run.event == 'pull_request' &&
194+
github.event.workflow_run.name == 'Check Built Files (PRs)' &&
193195
github.event.workflow_run.conclusion == 'success'
194196
steps:
195197
- name: Download artifact

.github/workflows/reusable-check-built-files.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,96 @@ jobs:
108108
with:
109109
name: pr-built-file-changes
110110
path: changes.diff
111+
112+
# Compares the results of npm run build with WordPress/WordPress
113+
#
114+
# Performs the following steps:
115+
# - Checks out the repository.
116+
# - Sets up Node.js.
117+
# - Logs debug information about the GitHub Action runner.
118+
# - Installs npm dependencies.
119+
# - Builds WordPress to run from the build directory.
120+
# - Ensures version-controlled files are not modified or deleted.
121+
# - Checks out the WordPress/WordPress repository.
122+
# - Creates a directory for text files to be uploaded as an artifact.
123+
# - Storse a list of files that differ in the build directory from WordPress/WordPress.
124+
# - Storse a diff file comparing the build directory to WordPress/WordPress.
125+
# - Saves the pull request number to a text file.
126+
# - Uploads the generated files as an artifact.
127+
compare-built-files:
128+
name: Detect differences between WordPress/WordPress
129+
runs-on: ubuntu-24.04
130+
permissions:
131+
contents: read
132+
timeout-minutes: 10
133+
134+
steps:
135+
- name: Checkout repository
136+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
137+
with:
138+
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
139+
persist-credentials: false
140+
141+
- name: Set up Node.js
142+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
143+
with:
144+
node-version-file: '.nvmrc'
145+
cache: npm
146+
147+
- name: Set up PHP
148+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2.37.0
149+
with:
150+
php-version: '8.4'
151+
coverage: none
152+
153+
# Since Composer dependencies are installed using `composer update` and no lock file is in version control,
154+
# passing a custom cache suffix ensures that the cache is flushed at least once per week.
155+
- name: Install Composer dependencies
156+
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4.0.0
157+
with:
158+
custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F")
159+
160+
- name: Log debug information
161+
run: |
162+
npm --version
163+
node --version
164+
git --version
165+
166+
- name: Install npm Dependencies
167+
run: npm ci
168+
169+
- name: Build WordPress to run from build directory
170+
run: npm run build
171+
172+
- name: Ensure version-controlled files are not modified or deleted
173+
run: git diff --exit-code
174+
175+
- name: Checkout WordPress/WordPress
176+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
177+
with:
178+
repository: 'WordPress/WordPress'
179+
path: ${{ github.workspace }}/built-wordpress
180+
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
181+
persist-credentials: false
182+
183+
- name: Create directory for artifacts
184+
run: mkdir artifacts
185+
186+
- name: Create a list of files that have changed
187+
run: diff -rq ${{ github.workspace }}/build ${{ github.workspace }}/built-wordpress | sed "s|${{ github.workspace }}/||g" > artifacts/file-changes.txt
188+
189+
- name: Create a list of files that have changed
190+
run: diff -r ${{ github.workspace }}/build ${{ github.workspace }}/built-wordpress | sed "s|${{ github.workspace }}/||g" > artifacts/changes.diff
191+
192+
- name: Save PR number
193+
run: echo "${EVENT_NUMBER}" > ./artifacts/NR
194+
env:
195+
EVENT_NUMBER: ${{ github.event.number }}
196+
197+
# Uploads the associated text files as an artifact.
198+
- name: Upload comparison results as an artifact
199+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
200+
#if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request' }}
201+
with:
202+
name: build-script-comparison
203+
path: artifacts/

.github/workflows/reusable-compare-built-files-v1.yml

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)