Skip to content

Commit bd3ec2b

Browse files
committed
Merge branch 'trunk' of https://github.com/sabernhardt/wordpress-develop into trunk
2 parents 6f7f964 + a412372 commit bd3ec2b

63 files changed

Lines changed: 1582 additions & 828 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/performance.yml

Lines changed: 106 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -66,38 +66,45 @@ jobs:
6666
# - Install WordPress.
6767
# - Install WordPress Importer plugin.
6868
# - Import mock data.
69+
# - Deactivate WordPress Importer plugin.
6970
# - Update permalink structure.
71+
# - Install additional languages.
72+
# - Disable external HTTP requests.
73+
# - Disable cron.
74+
# - List defined constants.
7075
# - Install MU plugin.
7176
# - Run performance tests (current commit).
72-
# - Print performance tests results.
73-
# - Check out target commit (target branch or previous commit).
74-
# - Switch Node.js versions if necessary.
75-
# - Install npm dependencies.
76-
# - Build WordPress.
77+
# - Download previous build artifact (target branch or previous commit).
78+
# - Download artifact.
79+
# - Unzip the build.
7780
# - Run any database upgrades.
81+
# - Flush cache.
82+
# - Delete expired transients.
7883
# - Run performance tests (previous/target commit).
79-
# - Print target performance tests results.
80-
# - Reset to original commit.
81-
# - Switch Node.js versions if necessary.
82-
# - Install npm dependencies.
8384
# - Set the environment to the baseline version.
8485
# - Run any database upgrades.
86+
# - Flush cache.
87+
# - Delete expired transients.
8588
# - Run baseline performance tests.
86-
# - Print baseline performance tests results.
87-
# - Compare results with base.
89+
# - Archive artifacts.
90+
# - Compare results.
8891
# - Add workflow summary.
8992
# - Set the base sha.
9093
# - Set commit details.
9194
# - Publish performance results.
9295
# - Ensure version-controlled files are not modified or deleted.
93-
# - Dispatch workflow run.
9496
performance:
95-
name: Run performance tests
97+
name: Run performance tests ${{ matrix.memcached && '(with memcached)' || '' }}
9698
runs-on: ubuntu-latest
9799
permissions:
98100
contents: read
99101
if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) && ! contains( github.event.before, '00000000' ) }}
100-
102+
strategy:
103+
fail-fast: false
104+
matrix:
105+
memcached: [ true, false ]
106+
env:
107+
LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
101108
steps:
102109
- name: Configure environment variables
103110
run: |
@@ -127,14 +134,17 @@ jobs:
127134
run: npm ci
128135

129136
- name: Install Playwright browsers
130-
run: npx playwright install --with-deps
137+
run: npx playwright install --with-deps chromium
131138

132139
- name: Build WordPress
133140
run: npm run build
134141

135142
- name: Start Docker environment
136-
run: |
137-
npm run env:start
143+
run: npm run env:start
144+
145+
- name: Install object cache drop-in
146+
if: ${{ matrix.memcached }}
147+
run: cp src/wp-content/object-cache.php build/wp-content/object-cache.php
138148

139149
- name: Log running Docker containers
140150
run: docker ps -a
@@ -160,16 +170,29 @@ jobs:
160170
npm run env:cli -- import themeunittestdata.wordpress.xml --authors=create --path=/var/www/${{ env.LOCAL_DIR }}
161171
rm themeunittestdata.wordpress.xml
162172
173+
- name: Deactivate WordPress Importer plugin
174+
run: npm run env:cli -- plugin deactivate wordpress-importer --path=/var/www/${{ env.LOCAL_DIR }}
175+
163176
- name: Update permalink structure
164-
run: |
165-
npm run env:cli -- rewrite structure '/%year%/%monthnum%/%postname%/' --path=/var/www/${{ env.LOCAL_DIR }}
177+
run: npm run env:cli -- rewrite structure '/%year%/%monthnum%/%postname%/' --path=/var/www/${{ env.LOCAL_DIR }}
166178

167179
- name: Install additional languages
168180
run: |
169181
npm run env:cli -- language core install de_DE --path=/var/www/${{ env.LOCAL_DIR }}
170182
npm run env:cli -- language plugin install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
171183
npm run env:cli -- language theme install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
172184
185+
# Prevent background update checks from impacting test stability.
186+
- name: Disable external HTTP requests
187+
run: npm run env:cli -- config set WP_HTTP_BLOCK_EXTERNAL true --raw --type=constant --path=/var/www/${{ env.LOCAL_DIR }}
188+
189+
# Prevent background tasks from impacting test stability.
190+
- name: Disable cron
191+
run: npm run env:cli -- config set DISABLE_WP_CRON true --raw --type=constant --path=/var/www/${{ env.LOCAL_DIR }}
192+
193+
- name: List defined constants
194+
run: npm run env:cli -- config list --path=/var/www/${{ env.LOCAL_DIR }}
195+
173196
- name: Install MU plugin
174197
run: |
175198
mkdir ./${{ env.LOCAL_DIR }}/wp-content/mu-plugins
@@ -178,82 +201,101 @@ jobs:
178201
- name: Run performance tests (current commit)
179202
run: npm run test:performance
180203

181-
- name: Print performance tests results
182-
run: node ./tests/performance/results.js
204+
- name: Download previous build artifact (target branch or previous commit)
205+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
206+
id: get-previous-build
207+
with:
208+
script: |
209+
const artifacts = await github.rest.actions.listArtifactsForRepo({
210+
owner: context.repo.owner,
211+
repo: context.repo.repo,
212+
name: 'wordpress-build-' + process.env.TARGET_SHA,
213+
});
214+
215+
const matchArtifact = artifacts.data.artifacts[0];
183216
184-
- name: Check out target commit (target branch or previous commit)
185-
run: |
186-
if [[ -z "$TARGET_REF" ]]; then
187-
git fetch -n origin $TARGET_SHA
188-
else
189-
git fetch -n origin $TARGET_REF
190-
fi
191-
git reset --hard $TARGET_SHA
217+
if ( ! matchArtifact ) {
218+
core.setFailed( 'No artifact found!' );
219+
return false;
220+
}
192221
193-
- name: Set up Node.js
194-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
195-
with:
196-
node-version-file: '.nvmrc'
197-
cache: npm
222+
const download = await github.rest.actions.downloadArtifact( {
223+
owner: context.repo.owner,
224+
repo: context.repo.repo,
225+
artifact_id: matchArtifact.id,
226+
archive_format: 'zip',
227+
} );
198228
199-
- name: Install npm dependencies
200-
run: npm ci
229+
const fs = require( 'fs' );
230+
fs.writeFileSync( '${{ github.workspace }}/before.zip', Buffer.from( download.data ) )
201231
202-
- name: Build WordPress
203-
run: npm run build
232+
return true;
233+
234+
- name: Unzip the build
235+
if: ${{ steps.get-previous-build.outputs.result }}
236+
run: |
237+
unzip ${{ github.workspace }}/before.zip
238+
unzip -o ${{ github.workspace }}/wordpress.zip
204239
205240
- name: Run any database upgrades
241+
if: ${{ steps.get-previous-build.outputs.result }}
206242
run: npm run env:cli -- core update-db --path=/var/www/${{ env.LOCAL_DIR }}
207243

208-
- name: Run target performance tests (base/previous commit)
209-
env:
210-
TEST_RESULTS_PREFIX: before
211-
run: npm run test:performance
244+
- name: Flush cache
245+
if: ${{ steps.get-previous-build.outputs.result }}
246+
run: npm run env:cli -- cache flush --path=/var/www/${{ env.LOCAL_DIR }}
247+
248+
- name: Delete expired transients
249+
if: ${{ steps.get-previous-build.outputs.result }}
250+
run: npm run env:cli -- transient delete --expired --path=/var/www/${{ env.LOCAL_DIR }}
212251

213-
- name: Print target performance tests results
252+
- name: Run target performance tests (previous/target commit)
253+
if: ${{ steps.get-previous-build.outputs.result }}
214254
env:
215255
TEST_RESULTS_PREFIX: before
216-
run: node ./tests/performance/results.js
217-
218-
- name: Reset to original commit
219-
run: git reset --hard $GITHUB_SHA
220-
221-
- name: Set up Node.js
222-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
223-
with:
224-
node-version-file: '.nvmrc'
225-
cache: npm
226-
227-
- name: Install npm dependencies
228-
run: npm ci
256+
run: npm run test:performance
229257

230258
- name: Set the environment to the baseline version
259+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
231260
run: |
232261
npm run env:cli -- core update --version=${{ env.BASE_TAG }} --force --path=/var/www/${{ env.LOCAL_DIR }}
233262
npm run env:cli -- core version --path=/var/www/${{ env.LOCAL_DIR }}
234263
235264
- name: Run any database upgrades
265+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
236266
run: npm run env:cli -- core update-db --path=/var/www/${{ env.LOCAL_DIR }}
237267

268+
- name: Flush cache
269+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
270+
run: npm run env:cli -- cache flush --path=/var/www/${{ env.LOCAL_DIR }}
271+
272+
- name: Delete expired transients
273+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
274+
run: npm run env:cli -- transient delete --expired --path=/var/www/${{ env.LOCAL_DIR }}
275+
238276
- name: Run baseline performance tests
277+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
239278
env:
240279
TEST_RESULTS_PREFIX: base
241280
run: npm run test:performance
242281

243-
- name: Print baseline performance tests results
244-
env:
245-
TEST_RESULTS_PREFIX: base
246-
run: node ./tests/performance/results.js
282+
- name: Archive artifacts
283+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
284+
if: always()
285+
with:
286+
name: performance-artifacts${{ matrix.memcached && '-memcached' || '' }}-${{ github.run_id }}
287+
path: artifacts
288+
if-no-files-found: ignore
247289

248-
- name: Compare results with base
290+
- name: Compare results
249291
run: node ./tests/performance/compare-results.js ${{ runner.temp }}/summary.md
250292

251293
- name: Add workflow summary
252294
run: cat ${{ runner.temp }}/summary.md >> $GITHUB_STEP_SUMMARY
253295

254296
- name: Set the base sha
255297
# Only needed when publishing results.
256-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
298+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' && ! matrix.memcached }}
257299
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
258300
id: base-sha
259301
with:
@@ -264,7 +306,7 @@ jobs:
264306
265307
- name: Set commit details
266308
# Only needed when publishing results.
267-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
309+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' && ! matrix.memcached }}
268310
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
269311
id: commit-timestamp
270312
with:
@@ -275,7 +317,7 @@ jobs:
275317
276318
- name: Publish performance results
277319
# Only publish results on pushes to trunk.
278-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
320+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' && ! matrix.memcached }}
279321
env:
280322
BASE_SHA: ${{ steps.base-sha.outputs.result }}
281323
COMMITTED_AT: ${{ steps.commit-timestamp.outputs.result }}

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

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
**Pull requests are never merged on GitHub.** The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.
5050
5151
52-
More information about how GitHub pull requests can be used to contribute to WordPress can be found in [this blog post](https://make.wordpress.org/core/2020/02/21/working-on-trac-tickets-using-github-pull-requests/).
52+
More information about how GitHub pull requests can be used to contribute to WordPress can be found in [the Core Handbook](https://make.wordpress.org/core/handbook/contribute/git/github-pull-requests-for-code-review/).
5353
5454
5555
**Please include automated tests.** Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the [Automated Testing](https://make.wordpress.org/core/handbook/testing/automated-testing/) page in the handbook.
@@ -163,3 +163,50 @@ jobs:
163163
`;
164164
165165
github.rest.issues.createComment( commentInfo );
166+
167+
# Leaves a comment on a pull request when no Trac ticket is included in the pull request description.
168+
trac-ticket-check:
169+
name: Comment on a pull request when no Trac ticket is included
170+
runs-on: ubuntu-latest
171+
permissions:
172+
issues: write
173+
pull-requests: write
174+
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request_target' && ! github.event.pull_request.draft && github.event.pull_request.state == 'open' }}
175+
steps:
176+
- name: Check for Trac ticket and comment if missing
177+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
178+
with:
179+
script: |
180+
const { owner, repo } = context.repo;
181+
const { number } = context.issue;
182+
183+
// Check for the presence of a comment and bail early.
184+
const comments = ( await github.rest.issues.listComments( { owner, repo, issue_number: number } ) ).data;
185+
186+
const hasMissingTicketComment = comments.some( comment =>
187+
comment.user.type === 'Bot' && comment.body.includes( 'Trac Ticket Missing' )
188+
);
189+
190+
if ( hasMissingTicketComment ) return;
191+
192+
// No comment was found. Create one.
193+
const pr = ( await github.rest.pulls.get( { owner, repo, pull_number: number } ) ).data;
194+
195+
const prBody = pr.body ?? '';
196+
const prTitle = pr.title ?? '';
197+
198+
const tracTicketRegex = new RegExp( 'https?://core.trac.wordpress.org/ticket/([0-9]+)', 'g' );
199+
const tracTicketMatches = prBody.match( tracTicketRegex ) || prTitle.match( tracTicketRegex );
200+
201+
if ( ! tracTicketMatches ) {
202+
github.rest.issues.createComment( {
203+
owner,
204+
repo,
205+
issue_number: number,
206+
body: `## Trac Ticket Missing
207+
This pull request is missing a link to a [Trac ticket](https://core.trac.wordpress.org/). For a contribution to be considered, there must be a corresponding ticket in Trac.
208+
209+
To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in [the Core Handbook](https://make.wordpress.org/core/handbook/contribute/git/github-pull-requests-for-code-review/).
210+
`,
211+
} );
212+
}

0 commit comments

Comments
 (0)