Skip to content

Commit 18d4d5e

Browse files
authored
Merge branch 'trunk' into add/code_coverage_auto_sizes
2 parents 15a5c85 + 8856a14 commit 18d4d5e

File tree

325 files changed

+11533
-3496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+11533
-3496
lines changed

.eslintrc.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,19 @@ const config = {
2323
'/node_modules',
2424
'/build',
2525
'/dist',
26-
'/*.min.js',
26+
'/**/*.min.js',
27+
],
28+
overrides: [
29+
...( wpConfig?.overrides || [] ),
30+
{
31+
files: [ 'plugins/view-transitions/js/**/*.js' ],
32+
rules: {
33+
'jsdoc/no-undefined-types': [
34+
'error',
35+
{ definedTypes: [ 'PageSwapEvent', 'PageRevealEvent' ] },
36+
],
37+
},
38+
},
2739
],
2840
};
2941

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@
3232

3333
# Plugin: Speculative Loading
3434
/plugins/speculation-rules @felixarntz
35+
36+
# Plugin: View Transitions
37+
/plugins/view-transitions @felixarntz
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Bump WordPress Tested up to
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
plugin:
7+
type: string
8+
description: 'Plugin slug (leave empty for all plugins)'
9+
required: false
10+
11+
jobs:
12+
prepare-matrix:
13+
name: Prepare plugins matrix
14+
runs-on: ubuntu-latest
15+
outputs:
16+
matrix: ${{ steps.set-matrix.outputs.plugins }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Configure plugin matrix
22+
id: set-matrix
23+
env:
24+
PLUGIN_SLUG: ${{ inputs.plugin }}
25+
run: |
26+
PLUGINS=$(jq -r '.plugins' plugins.json)
27+
if [[ -n "$PLUGIN_SLUG" ]]; then
28+
if echo $PLUGINS | jq -e '.[] | select(. == "'$PLUGIN_SLUG'")' > /dev/null; then
29+
PLUGINS="[ \"$PLUGIN_SLUG\" ]"
30+
else
31+
echo "::error::Plugin '$PLUGIN_SLUG' not found in plugins.json"
32+
exit 1
33+
fi
34+
fi
35+
echo "::notice::Updating plugins: $(echo ${PLUGINS[@]})"
36+
echo "plugins=$(echo $PLUGINS | jq -c .)" >> $GITHUB_OUTPUT
37+
38+
update-compatibility:
39+
name: Update "Tested up to" value for ${{ matrix.plugin }}
40+
needs: prepare-matrix
41+
runs-on: ubuntu-latest
42+
env:
43+
PLUGIN_SLUG: ${{ matrix.plugin }}
44+
strategy:
45+
matrix:
46+
plugin: ${{ fromJSON(needs.prepare-matrix.outputs.matrix) }}
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
51+
- name: Download WordPress.org readme
52+
run: |
53+
# Download the current readme.txt from WordPress.org
54+
curl -sSL --retry 3 --retry-delay 5 --retry-all-errors --fail -o /tmp/wp-org-readme.txt "https://plugins.svn.wordpress.org/$PLUGIN_SLUG/trunk/readme.txt"
55+
if [ $? -ne 0 ]; then
56+
echo "::error::Could not fetch readme.txt from WordPress.org for $PLUGIN_SLUG"
57+
exit 1
58+
fi
59+
60+
- name: Extract "Tested up to" version from repository
61+
id: extract-tested-up-to
62+
run: |
63+
LOCAL_TESTED_UP_TO=$(grep -E "^Tested up to:" "./plugins/$PLUGIN_SLUG/readme.txt" | awk -F ': +' '{print $2}')
64+
if [ -z "$LOCAL_TESTED_UP_TO" ]; then
65+
echo "::error::Unable to parse Tested up to version from repository readme.txt"
66+
exit 1
67+
fi
68+
69+
echo "version=$LOCAL_TESTED_UP_TO" >> $GITHUB_OUTPUT
70+
71+
- name: Prepare and update readme.txt
72+
env:
73+
LOCAL_TESTED_UP_TO: ${{ steps.extract-tested-up-to.outputs.version }}
74+
run: |
75+
# Replace local readme.txt with WordPress.org version, updating only the "Tested up to" line.
76+
cp /tmp/wp-org-readme.txt "./plugins/$PLUGIN_SLUG/readme.txt"
77+
sed -i -E 's/^(Tested up to:[[:space:]]*).+/\1'"$LOCAL_TESTED_UP_TO"'/' "./plugins/$PLUGIN_SLUG/readme.txt"
78+
79+
# Show the diff of what's being updated.
80+
echo "Changes made to readme.txt:"
81+
diff -u /tmp/wp-org-readme.txt "./plugins/$PLUGIN_SLUG/readme.txt" || true
82+
83+
- name: Copy readme.txt to workspace root for SVN upload
84+
run: cp "./plugins/$PLUGIN_SLUG/readme.txt" "$GITHUB_WORKSPACE/readme.txt"
85+
86+
- name: Push to WordPress.org
87+
uses: 10up/action-wordpress-plugin-asset-update@stable
88+
env:
89+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
90+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
91+
SLUG: ${{ matrix.plugin }}
92+
SKIP_ASSETS: true
93+
IGNORE_OTHER_FILES: true

.github/workflows/e2e-test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: End-to-End Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- trunk
7+
- 'release/**'
8+
- 'add/setup-e2e-tests'
9+
paths:
10+
- '.github/workflows/e2e-test.yml'
11+
- 'plugins/auto-sizes/**'
12+
- '**/package.json'
13+
- 'package-lock.json'
14+
- 'composer.json'
15+
- 'composer.lock'
16+
pull_request:
17+
paths:
18+
- '.github/workflows/e2e-test.yml'
19+
- 'plugins/auto-sizes/**'
20+
- '**/package.json'
21+
- 'package-lock.json'
22+
- 'composer.json'
23+
- 'composer.lock'
24+
types:
25+
- opened
26+
- reopened
27+
- synchronize
28+
29+
jobs:
30+
e2e-test:
31+
name: E2E Tests
32+
runs-on: ubuntu-latest
33+
timeout-minutes: 20
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Setup Node.js (.nvmrc)
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version-file: '.nvmrc'
42+
cache: npm
43+
44+
- name: Install npm dependencies
45+
run: npm ci
46+
47+
- name: Build assets
48+
run: npm run build
49+
50+
- name: Install Playwright dependencies
51+
run: npx playwright install chromium --with-deps
52+
53+
- name: Install WordPress
54+
run: npm run wp-env start
55+
56+
- name: Run tests
57+
env:
58+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
59+
run: npm run test-e2e

.github/workflows/php-test-plugins.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ jobs:
9595
npm run test-php:image-prioritizer -- -- -- --coverage-clover=./single-site-reports/coverage-image-prioritizer.xml
9696
npm run test-php:optimization-detective -- -- -- --coverage-clover=./single-site-reports/coverage-optimization-detective.xml
9797
npm run test-php:speculation-rules -- -- -- --coverage-clover=./single-site-reports/coverage-speculation-rules.xml
98+
npm run test-php:view-transitions -- -- -- --coverage-clover=./single-site-reports/coverage-view-transitions.xml
9899
npm run test-php:web-worker-offloading -- -- -- --coverage-clover=./single-site-reports/coverage-web-worker-offloading.xml
99100
npm run test-php:webp-uploads -- -- -- --coverage-clover=./single-site-reports/coverage-webp-uploads.xml
100101
else
@@ -110,6 +111,7 @@ jobs:
110111
npm run test-php-multisite:image-prioritizer -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-image-prioritizer.xml
111112
npm run test-php-multisite:optimization-detective -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-optimization-detective.xml
112113
npm run test-php-multisite:speculation-rules -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-speculation-rules.xml
114+
npm run test-php-multisite:view-transitions -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-view-transitions.xml
113115
npm run test-php-multisite:web-worker-offloading -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-web-worker-offloading.xml
114116
npm run test-php-multisite:webp-uploads -- -- -- --coverage-clover=./multisite-reports/coverage-multisite-webp-uploads.xml
115117
else

.github/workflows/pr-validation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
types:
1010
- labeled
1111
- unlabeled
12+
- milestoned
13+
- demilestoned
1214
- opened
1315
- reopened
1416
- synchronize

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
############
44

55
plugins/*/tests/**/actual.html
6+
artifacts
7+
test-results
68

79
############
810
## IDEs

.wp-env.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
23
"core": null,
34
"plugins": [
45
"./plugins/optimization-detective",
@@ -8,6 +9,7 @@
89
"./plugins/image-prioritizer",
910
"./plugins/performance-lab",
1011
"./plugins/speculation-rules",
12+
"./plugins/view-transitions",
1113
"./plugins/web-worker-offloading",
1214
"./plugins/webp-uploads"
1315
],

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Performance Lab
22
![Performance Lab plugin banner with icon](https://github.com/WordPress/performance/assets/10103365/99d37ba5-27e3-47ea-8ab8-48de75ee69bf)
33

4+
[![codecov](https://codecov.io/gh/WordPress/performance/graph/badge.svg?token=zQv52K2LWz)](https://codecov.io/gh/WordPress/performance)
5+
46
Monorepo for the [WordPress Performance Team](https://make.wordpress.org/performance/), primarily for the Performance Lab plugin, which is a collection of standalone performance features.
57

68
Details about the Performance Lab plugin, including instructions for getting started and contributing, are available in the [Performance Team Handbook here](https://make.wordpress.org/performance/handbook/performance-lab/).
@@ -19,6 +21,7 @@ Plugin | Slug | Experimental | Lin
1921
[Performant Translations][3] | `performant-translations` | No | [Source][11], [Issues][19], [PRs][27]
2022
[Speculative Loading][4] | `speculation-rules` | No | [Source][12], [Issues][20], [PRs][28]
2123
[Enhanced Responsive Images][6] | `auto-sizes` | Yes | [Source][14], [Issues][22], [PRs][30]
24+
[View Transitions][37] | `view-transitions` | Yes | [Source][38], [Issues][39], [PRs][40]
2225
[Web Worker Offloading][8] | `web-worker-offloading` | Yes | [Source][16], [Issues][24], [PRs][32]
2326

2427
[1]: https://wordpress.org/plugins/dominant-color-images/
@@ -30,6 +33,7 @@ Plugin | Slug | Experimental | Lin
3033
[7]: https://wordpress.org/plugins/image-prioritizer/
3134
[8]: https://wordpress.org/plugins/web-worker-offloading/
3235
[33]: https://wordpress.org/plugins/optimization-detective/
36+
[37]: https://wordpress.org/plugins/view-transitions/
3337

3438
[9]: https://github.com/WordPress/performance/tree/trunk/plugins/dominant-color-images
3539
[10]: https://github.com/WordPress/performance/tree/trunk/plugins/webp-uploads
@@ -40,6 +44,7 @@ Plugin | Slug | Experimental | Lin
4044
[15]: https://github.com/WordPress/performance/tree/trunk/plugins/image-prioritizer
4145
[16]: https://github.com/WordPress/performance/tree/trunk/plugins/web-worker-offloading
4246
[34]: https://github.com/WordPress/performance/tree/trunk/plugins/optimization-detective
47+
[38]: https://github.com/WordPress/performance/tree/trunk/plugins/view-transitions
4348

4449
[17]: https://github.com/WordPress/performance/issues?q=is%3Aopen+label%3A%22%5BPlugin%5D+Image+Placeholders%22
4550
[18]: https://github.com/WordPress/performance/issues?q=is%3Aopen+label%3A%22%5BPlugin%5D+Modern+Image+Formats%22
@@ -50,6 +55,7 @@ Plugin | Slug | Experimental | Lin
5055
[23]: https://github.com/WordPress/performance/issues?q=is%3Aopen+label%3A%22%5BPlugin%5D+Image+Prioritizer%22
5156
[24]: https://github.com/WordPress/performance/issues?q=is%3Aopen%20label%3A%22%5BPlugin%5D%20Web%20Worker%20Offloading%22
5257
[35]: https://github.com/WordPress/performance/issues?q=is%3Aopen%20label%3A%22%5BPlugin%5D%20Optimization%20Detective%22
58+
[39]: https://github.com/WordPress/performance/issues?q=is%3Aopen%20label%3A%22%5BPlugin%5D%20View%20Transitions%22
5359

5460
[25]: https://github.com/WordPress/performance/pulls?q=is%3Apr+is%3Aopen+label%3A%22%5BPlugin%5D+Image+Placeholders%22
5561
[26]: https://github.com/WordPress/performance/pulls?q=is%3Apr+is%3Aopen+label%3A%22%5BPlugin%5D+Modern+Image+Formats%22
@@ -60,5 +66,6 @@ Plugin | Slug | Experimental | Lin
6066
[31]: https://github.com/WordPress/performance/pulls?q=is%3Apr+is%3Aopen+label%3A%22%5BPlugin%5D+Image+Prioritizer%22
6167
[32]: https://github.com/WordPress/performance/pulls?q=is%3Apr+is%3Aopen+label%3A%22%5BPlugin%5D+Web%20Worker%20Offloading%22
6268
[36]: https://github.com/WordPress/performance/pulls?q=is%3Apr+is%3Aopen+label%3A%22%5BPlugin%5D+Optimization%20Detective%22
69+
[40]: https://github.com/WordPress/performance/pulls?q=is%3Apr+is%3Aopen+label%3A%22%5BPlugin%5D+View%20Transitions%22
6370

6471
Note that the plugin names sometimes diverge from the plugin slugs due to scope changes. For example, a plugin's purpose may change as some of its features are merged into WordPress core.

bin/plugin/commands/changelog.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const PRIMARY_TYPE_LABELS = {
2323
const PRIMARY_TYPE_ORDER = Object.values( PRIMARY_TYPE_LABELS );
2424
const SKIP_CHANGELOG_LABEL = 'skip changelog';
2525

26-
/** @typedef {import('@octokit/rest')} GitHub */
27-
/** @typedef {import('@octokit/rest').IssuesListForRepoResponseItem} IssuesListForRepoResponseItem */
26+
/** @typedef {import('@octokit/rest').Octokit} GitHub */
27+
/** @typedef {import('@octokit/rest').RestEndpointMethodTypes['issues']['listForRepo']['response']['data'][0]} IssuesListForRepoResponseItem */
2828

2929
/**
3030
* @typedef WPChangelogCommandOptions
@@ -115,7 +115,7 @@ async function fetchAllPullRequests( octokit, settings ) {
115115
*/
116116
function getIssueType( issue ) {
117117
const typeLabels = issue.labels
118-
.map( ( { name } ) => name )
118+
.map( ( label ) => ( typeof label === 'string' ? label : label.name ) )
119119
.filter( ( label ) => label.startsWith( TYPE_PREFIX ) );
120120

121121
if ( ! typeLabels.length ) {
@@ -141,7 +141,10 @@ function formatChangelog( milestone, pullRequests ) {
141141
let changelog = '';
142142

143143
// Group PRs by type.
144-
const typeGroups = groupBy( pullRequests, getIssueType );
144+
const typeGroups =
145+
/** @type {Object<string, IssuesListForRepoResponseItem[]>} */ (
146+
groupBy( pullRequests, getIssueType )
147+
);
145148
if ( typeGroups[ MISSING_TYPE ] ) {
146149
const prURLs = typeGroups[ MISSING_TYPE ].map(
147150
( { html_url } ) => html_url // eslint-disable-line camelcase
@@ -161,7 +164,7 @@ function formatChangelog( milestone, pullRequests ) {
161164
return aIndex - bIndex;
162165
}
163166
if ( aIndex === -1 && bIndex === -1 ) {
164-
return a - b;
167+
return a.localeCompare( b );
165168
}
166169
return aIndex > -1 ? -1 : 1;
167170
} );
@@ -219,9 +222,11 @@ async function getChangelog( settings ) {
219222

220223
const nonSkippedPullRequests = pullRequests.filter(
221224
( pullRequest ) =>
222-
! pullRequest.labels.find(
223-
( { name } ) => name === SKIP_CHANGELOG_LABEL
224-
)
225+
! pullRequest.labels
226+
.map( ( label ) =>
227+
typeof label === 'string' ? label : label.name
228+
)
229+
.find( ( name ) => name === SKIP_CHANGELOG_LABEL )
225230
);
226231
if ( ! nonSkippedPullRequests.length ) {
227232
throw new Error(

0 commit comments

Comments
 (0)