Skip to content

Commit 4bb2655

Browse files
Merge changes published in the Gutenberg plugin "release/13.2" branch
1 parent 1ba5231 commit 4bb2655

File tree

360 files changed

+8751
-5943
lines changed

Some content is hidden

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

360 files changed

+8751
-5943
lines changed

.eslintrc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const majorMinorRegExp =
2626
*/
2727
const developmentFiles = [
2828
'**/benchmark/**/*.js',
29-
'**/@(__mocks__|__tests__|test)/**/*.{js,ts,tsx}',
30-
'**/@(storybook|stories)/**/*.js',
29+
'**/@(__mocks__|__tests__|test)/**/*.[tj]s?(x)',
30+
'**/@(storybook|stories)/**/*.[tj]s?(x)',
3131
'packages/babel-preset-default/bin/**/*.js',
3232
];
3333

@@ -249,12 +249,12 @@ module.exports = {
249249
'no-restricted-syntax': [
250250
'error',
251251
{
252-
selector: 'CallExpression[callee.name="$"]',
252+
selector: 'CallExpression[callee.property.name="$"]',
253253
message:
254254
'`$` is discouraged, please use `locator` instead',
255255
},
256256
{
257-
selector: 'CallExpression[callee.name="$$"]',
257+
selector: 'CallExpression[callee.property.name="$$"]',
258258
message:
259259
'`$$` is discouraged, please use `locator` instead',
260260
},

.github/CODEOWNERS

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Documentation
2-
/docs @ajitbohra @mkaz @ryanwelcher @juanmaguitar
2+
/docs @ajitbohra @ryanwelcher @juanmaguitar
33

44
# Schemas
5-
/schemas @mkaz
6-
/schemas/json @ajlende @mkaz
5+
/schemas/json @ajlende
76

87
# Data
98
/packages/api-fetch @nerrad @mmtr
@@ -15,14 +14,12 @@
1514
# Blocks
1615
/packages/block-library @ajitbohra
1716
/packages/block-library/src/gallery @geriux
18-
/packages/block-library/src/social-links @mkaz
19-
/packages/block-library/src/social-link @mkaz
2017
/packages/block-library/src/navigation @tellthemachines
2118
/packages/block-library/src/navigation-link @tellthemachines
2219
/packages/block-library/src/navigation-submenu @tellthemachines
2320
/packages/block-library/src/page-list @tellthemachines
2421
/packages/block-library/src/comment-template @michalczaplinski
25-
/packages/block-library/src/comments-query-loop @michalczaplinski
22+
/packages/block-library/src/comments @michalczaplinski
2623

2724
# Duotone
2825
/lib/block-supports/duotone.php @ajlende
@@ -60,17 +57,17 @@
6057

6158
# Tooling
6259
/bin @ntwb @nerrad @ajitbohra
63-
/bin/api-docs @ntwb @nerrad @ajitbohra @oandregal
64-
/docs/tool @ajitbohra @oandregal
60+
/bin/api-docs @ntwb @nerrad @ajitbohra
61+
/docs/tool @ajitbohra
6562
/packages/babel-plugin-import-jsx-pragma @ntwb @nerrad @ajitbohra
6663
/packages/babel-plugin-makepot @ntwb @nerrad @ajitbohra
6764
/packages/babel-preset-default @gziolo @ntwb @nerrad @ajitbohra
6865
/packages/browserslist-config @ntwb @nerrad @ajitbohra
69-
/packages/create-block @gziolo @mkaz @ryanwelcher
70-
/packages/create-block-tutorial-template @gziolo @mkaz @ryanwelcher
66+
/packages/create-block @gziolo @ryanwelcher
67+
/packages/create-block-tutorial-template @gziolo @ryanwelcher
7168
/packages/custom-templated-path-webpack-plugin @ntwb @nerrad @ajitbohra
7269
/packages/dependency-extraction-webpack-plugin @gziolo
73-
/packages/docgen @oandregal
70+
/packages/docgen
7471
/packages/e2e-test-utils @ntwb @nerrad @ajitbohra
7572
/packages/e2e-tests @ntwb @nerrad @ajitbohra
7673
/packages/eslint-plugin @gziolo @ntwb @nerrad @ajitbohra
@@ -120,9 +117,9 @@
120117
/packages/plugins @gziolo @adamsilverstein
121118

122119
# Rich Text
123-
/packages/format-library @ellatrix @cameronvoell
124-
/packages/rich-text @ellatrix @cameronvoell
125-
/packages/block-editor/src/components/rich-text @ellatrix @cameronvoell
120+
/packages/format-library @ellatrix @fluiddot
121+
/packages/rich-text @ellatrix @fluiddot
122+
/packages/block-editor/src/components/rich-text @ellatrix @fluiddot
126123

127124
# Project Management
128125
/.github
@@ -133,18 +130,7 @@
133130

134131
# PHP
135132
/lib @timothybjacobs @spacedmonkey
136-
/lib/compat/wordpress-5.9/kses.php @timothybjacobs @spacedmonkey @oandregal
137-
/lib/compat/wordpress-5.9/theme.json @timothybjacobs @spacedmonkey @oandregal
138-
/lib/compat/wordpress-6.0/theme-i18n.json @timothybjacobs @spacedmonkey @oandregal
139-
/lib/compat/wordpress-5.9/class-wp-theme-json-gutenberg.php @timothybjacobs @spacedmonkey @oandregal
140-
/lib/compat/wordpress-5.9/class-wp-theme-json-resolver-gutenberg.php @timothybjacobs @spacedmonkey @oandregal
141133
/lib/experimental/class-wp-rest-block-editor-settings-controller.php @timothybjacobs @spacedmonkey @geriux
142-
/phpunit/class-wp-theme-json-test.php @oandregal
143-
144-
# Web App
145-
/packages/admin-manifest @ellatrix
146-
/lib/pwa.php @ellatrix
147-
/lib/service-worker.js @ellatrix
148134

149135
# Native
150136
/packages/components/src/mobile/global-styles-context @geriux

.github/report-flaky-tests/index.js

Lines changed: 58 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const metaData = {
6161
let issue;
6262

6363
if ( reportedIssue ) {
64-
let body = reportedIssue.body;
64+
const body = reportedIssue.body;
6565
const meta = metaData.get( body );
6666

6767
if ( isTrunk ) {
@@ -88,35 +88,39 @@ const metaData = {
8888
}
8989
}
9090

91-
let testResultsList = body
92-
.slice(
93-
body.indexOf( TEST_RESULTS_LIST.open ) +
94-
TEST_RESULTS_LIST.open.length,
95-
body.indexOf( TEST_RESULTS_LIST.close )
96-
)
97-
/**
98-
* Split the text from:
99-
* ```
100-
* <!-- __TEST_RESULT__ --> Test result 1 <!-- /__TEST_RESULT__ -->
101-
* ...
102-
* <!-- __TEST_RESULT__ --> Test result 2 <!-- /__TEST_RESULT__ -->
103-
* <!-- __TEST_RESULT__ --> Test result 3 <!-- /__TEST_RESULT__ -->
104-
* ```
105-
*
106-
* into:
107-
* ```
108-
* [
109-
* '<!-- __TEST_RESULT__ --> Test result 1 <!-- /__TEST_RESULT__ -->',
110-
* '<!-- __TEST_RESULT__ --> Test result 2 <!-- /__TEST_RESULT__ -->',
111-
* '<!-- __TEST_RESULT__ --> Test result 3 <!-- /__TEST_RESULT__ -->',
112-
* ]
113-
* ```
114-
*/
115-
.split(
116-
new RegExp(
117-
`(?<=${ TEST_RESULT.close })\n(?:\.\.\.\n)?(?=${ TEST_RESULT.open })`
118-
)
119-
);
91+
let testResultsList =
92+
body.includes( TEST_RESULTS_LIST.open ) &&
93+
body.includes( TEST_RESULTS_LIST.close )
94+
? body
95+
.slice(
96+
body.indexOf( TEST_RESULTS_LIST.open ) +
97+
TEST_RESULTS_LIST.open.length,
98+
body.indexOf( TEST_RESULTS_LIST.close )
99+
)
100+
/**
101+
* Split the text from:
102+
* ```
103+
* <!-- __TEST_RESULT__ --> Test result 1 <!-- /__TEST_RESULT__ -->
104+
* ...
105+
* <!-- __TEST_RESULT__ --> Test result 2 <!-- /__TEST_RESULT__ -->
106+
* <!-- __TEST_RESULT__ --> Test result 3 <!-- /__TEST_RESULT__ -->
107+
* ```
108+
*
109+
* into:
110+
* ```
111+
* [
112+
* '<!-- __TEST_RESULT__ --> Test result 1 <!-- /__TEST_RESULT__ -->',
113+
* '<!-- __TEST_RESULT__ --> Test result 2 <!-- /__TEST_RESULT__ -->',
114+
* '<!-- __TEST_RESULT__ --> Test result 3 <!-- /__TEST_RESULT__ -->',
115+
* ]
116+
* ```
117+
*/
118+
.split(
119+
new RegExp(
120+
`(?<=${ TEST_RESULT.close })\n+(?:\.\.\.\n+)?(?=${ TEST_RESULT.open })`
121+
)
122+
)
123+
: [];
120124
// GitHub issues has character limits on issue's body,
121125
// so we only preserve the first and the 9 latest results.
122126
if ( testResultsList.length > 10 ) {
@@ -127,25 +131,26 @@ const metaData = {
127131
];
128132
}
129133

130-
// Reconstruct the body with the description + previous errors + new error.
131-
body =
132-
renderIssueDescription( { meta, testTitle, testPath } ) +
133-
[
134-
TEST_RESULTS_LIST.open,
135-
...testResultsList,
136-
renderTestErrorMessage( {
137-
testRunner,
138-
testPath,
139-
testResults,
140-
} ),
141-
TEST_RESULTS_LIST.close,
142-
].join( '\n' );
134+
// Concat the test results list with the latest test results.
135+
const formattedTestResults = [
136+
...testResultsList,
137+
formatTestResults( {
138+
testRunner,
139+
testPath,
140+
testResults,
141+
} ),
142+
].join( '\n' );
143143

144144
const response = await octokit.rest.issues.update( {
145145
...github.context.repo,
146146
issue_number: reportedIssue.number,
147147
state: 'open',
148-
body,
148+
body: renderIssueBody( {
149+
meta,
150+
testTitle,
151+
testPath,
152+
formattedTestResults,
153+
} ),
149154
} );
150155

151156
issue = response.data;
@@ -166,10 +171,9 @@ const metaData = {
166171
title: issueTitle,
167172
body: renderIssueBody( {
168173
meta,
169-
testRunner,
170174
testTitle,
171175
testPath,
172-
testResults,
176+
formattedTestResults: formatTestResults( testResults ),
173177
} ),
174178
labels: [ label ],
175179
} );
@@ -235,18 +239,10 @@ function getIssueTitle( testTitle ) {
235239

236240
function renderIssueBody( {
237241
meta,
238-
testRunner,
239242
testTitle,
240243
testPath,
241-
testResults,
244+
formattedTestResults,
242245
} ) {
243-
return (
244-
renderIssueDescription( { meta, testTitle, testPath } ) +
245-
renderTestResults( { testRunner, testPath, testResults } )
246-
);
247-
}
248-
249-
function renderIssueDescription( { meta, testTitle, testPath } ) {
250246
return `${ metaData.render( meta ) }
251247
**Flaky test detected. This is an auto-generated issue by GitHub Actions. Please do NOT edit this manually.**
252248
@@ -260,17 +256,13 @@ ${ testTitle }
260256
\`${ meta.failedTimes } / ${ meta.totalCommits + meta.failedTimes }\` runs
261257
262258
## Errors
263-
`;
264-
}
265-
266-
function renderTestResults( { testRunner, testPath, testResults } ) {
267-
return `${ TEST_RESULTS_LIST.open }
268-
${ renderTestErrorMessage( { testRunner, testPath, testResults } ) }
259+
${ TEST_RESULTS_LIST.open }
260+
${ formattedTestResults }
269261
${ TEST_RESULTS_LIST.close }
270262
`;
271263
}
272264

273-
function renderTestResults( { testRunner, testResults, testPath } ) {
265+
function formatTestErrorMessage( { testRunner, testResults, testPath } ) {
274266
switch ( testRunner ) {
275267
case '@playwright/test': {
276268
// Could do a slightly better formatting than this.
@@ -297,7 +289,7 @@ function renderTestResults( { testRunner, testResults, testPath } ) {
297289
}
298290
}
299291

300-
function renderTestErrorMessage( { testRunner, testPath, testResults } ) {
292+
function formatTestResults( { testRunner, testPath, testResults } ) {
301293
const date = new Date().toISOString();
302294
// It will look something like this without formatting:
303295
// ▶ [2021-08-31T16:15:19.875Z] Test passed after 2 failed attempts on trunk
@@ -310,7 +302,7 @@ function renderTestErrorMessage( { testRunner, testPath, testResults } ) {
310302
</summary>
311303
312304
\`\`\`
313-
${ renderTestResults( { testRunner, testPath, testResults } ) }
305+
${ formatTestErrorMessage( { testRunner, testPath, testResults } ) }
314306
\`\`\`
315307
</details>${ TEST_RESULT.close }`;
316308
}
@@ -336,6 +328,7 @@ function stripAnsi( string ) {
336328
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))',
337329
].join( '|' ),
338330
'g'
339-
)
331+
),
332+
''
340333
);
341334
}

bin/packages/watch.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ function isDirectory( pathname ) {
5959
function isSourceFile( filename ) {
6060
// Only run this regex on the relative path, otherwise we might run
6161
// into some false positives when eg. the project directory contains `src`
62-
const relativePath = path.relative( process.cwd(), filename );
62+
const relativePath = path
63+
.relative( process.cwd(), filename )
64+
.replace( /\\/g, '/' );
6365

6466
return (
6567
/\/src\/.+\.(js|json|scss|ts|tsx)$/.test( relativePath ) &&
@@ -98,6 +100,7 @@ function isWatchableFile( filename, skip ) {
98100
// Recursive file watching is not available on a Linux-based OS. If this is the case,
99101
// the watcher library falls back to watching changes in the subdirectories
100102
// and passes the directories to this filter callback instead.
103+
101104
if ( isDirectory( filename ) ) {
102105
return true;
103106
}
@@ -117,8 +120,9 @@ function isWatchableFile( filename, skip ) {
117120
function getBuildFile( srcFile ) {
118121
// Could just use string.replace, but the user might have the project
119122
// checked out and nested under another src folder.
120-
const packageDir = srcFile.substr( 0, srcFile.lastIndexOf( '/src/' ) );
121-
const filePath = srcFile.substr( srcFile.lastIndexOf( '/src/' ) + 5 );
123+
const srcDir = `${ path.sep }src${ path.sep }`;
124+
const packageDir = srcFile.substr( 0, srcFile.lastIndexOf( srcDir ) );
125+
const filePath = srcFile.substr( srcFile.lastIndexOf( srcDir ) + 5 );
122126
return path.resolve( packageDir, 'build', filePath );
123127
}
124128

0 commit comments

Comments
 (0)