Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/31662
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Apr 29, 2022
2 parents 1cc15de + e86188d commit 5357ad2
Show file tree
Hide file tree
Showing 219 changed files with 5,934 additions and 3,249 deletions.
23 changes: 7 additions & 16 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Documentation
/docs @ajitbohra @mkaz @ryanwelcher @juanmaguitar
/docs @ajitbohra @ryanwelcher @juanmaguitar

# Schemas
/schemas @mkaz
/schemas/json @ajlende @mkaz
/schemas/json @ajlende

# Data
/packages/api-fetch @nerrad @mmtr
Expand All @@ -15,8 +14,6 @@
# Blocks
/packages/block-library @ajitbohra
/packages/block-library/src/gallery @geriux
/packages/block-library/src/social-links @mkaz
/packages/block-library/src/social-link @mkaz
/packages/block-library/src/navigation @tellthemachines
/packages/block-library/src/navigation-link @tellthemachines
/packages/block-library/src/navigation-submenu @tellthemachines
Expand Down Expand Up @@ -60,17 +57,17 @@

# Tooling
/bin @ntwb @nerrad @ajitbohra
/bin/api-docs @ntwb @nerrad @ajitbohra @oandregal
/docs/tool @ajitbohra @oandregal
/bin/api-docs @ntwb @nerrad @ajitbohra
/docs/tool @ajitbohra
/packages/babel-plugin-import-jsx-pragma @ntwb @nerrad @ajitbohra
/packages/babel-plugin-makepot @ntwb @nerrad @ajitbohra
/packages/babel-preset-default @gziolo @ntwb @nerrad @ajitbohra
/packages/browserslist-config @ntwb @nerrad @ajitbohra
/packages/create-block @gziolo @mkaz @ryanwelcher
/packages/create-block-tutorial-template @gziolo @mkaz @ryanwelcher
/packages/create-block @gziolo @ryanwelcher
/packages/create-block-tutorial-template @gziolo @ryanwelcher
/packages/custom-templated-path-webpack-plugin @ntwb @nerrad @ajitbohra
/packages/dependency-extraction-webpack-plugin @gziolo
/packages/docgen @oandregal
/packages/docgen
/packages/e2e-test-utils @ntwb @nerrad @ajitbohra
/packages/e2e-tests @ntwb @nerrad @ajitbohra
/packages/eslint-plugin @gziolo @ntwb @nerrad @ajitbohra
Expand Down Expand Up @@ -133,13 +130,7 @@

# PHP
/lib @timothybjacobs @spacedmonkey
/lib/compat/wordpress-5.9/kses.php @timothybjacobs @spacedmonkey @oandregal
/lib/compat/wordpress-5.9/theme.json @timothybjacobs @spacedmonkey @oandregal
/lib/compat/wordpress-6.0/theme-i18n.json @timothybjacobs @spacedmonkey @oandregal
/lib/compat/wordpress-5.9/class-wp-theme-json-gutenberg.php @timothybjacobs @spacedmonkey @oandregal
/lib/compat/wordpress-5.9/class-wp-theme-json-resolver-gutenberg.php @timothybjacobs @spacedmonkey @oandregal
/lib/experimental/class-wp-rest-block-editor-settings-controller.php @timothybjacobs @spacedmonkey @geriux
/phpunit/class-wp-theme-json-test.php @oandregal

# Native
/packages/components/src/mobile/global-styles-context @geriux
Expand Down
120 changes: 56 additions & 64 deletions .github/report-flaky-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const metaData = {
let issue;

if ( reportedIssue ) {
let body = reportedIssue.body;
const body = reportedIssue.body;
const meta = metaData.get( body );

if ( isTrunk ) {
Expand All @@ -88,35 +88,39 @@ const metaData = {
}
}

let testResultsList = body
.slice(
body.indexOf( TEST_RESULTS_LIST.open ) +
TEST_RESULTS_LIST.open.length,
body.indexOf( TEST_RESULTS_LIST.close )
)
/**
* Split the text from:
* ```
* <!-- __TEST_RESULT__ --> Test result 1 <!-- /__TEST_RESULT__ -->
* ...
* <!-- __TEST_RESULT__ --> Test result 2 <!-- /__TEST_RESULT__ -->
* <!-- __TEST_RESULT__ --> Test result 3 <!-- /__TEST_RESULT__ -->
* ```
*
* into:
* ```
* [
* '<!-- __TEST_RESULT__ --> Test result 1 <!-- /__TEST_RESULT__ -->',
* '<!-- __TEST_RESULT__ --> Test result 2 <!-- /__TEST_RESULT__ -->',
* '<!-- __TEST_RESULT__ --> Test result 3 <!-- /__TEST_RESULT__ -->',
* ]
* ```
*/
.split(
new RegExp(
`(?<=${ TEST_RESULT.close })\n(?:\.\.\.\n)?(?=${ TEST_RESULT.open })`
)
);
let testResultsList =
body.includes( TEST_RESULTS_LIST.open ) &&
body.includes( TEST_RESULTS_LIST.close )
? body
.slice(
body.indexOf( TEST_RESULTS_LIST.open ) +
TEST_RESULTS_LIST.open.length,
body.indexOf( TEST_RESULTS_LIST.close )
)
/**
* Split the text from:
* ```
* <!-- __TEST_RESULT__ --> Test result 1 <!-- /__TEST_RESULT__ -->
* ...
* <!-- __TEST_RESULT__ --> Test result 2 <!-- /__TEST_RESULT__ -->
* <!-- __TEST_RESULT__ --> Test result 3 <!-- /__TEST_RESULT__ -->
* ```
*
* into:
* ```
* [
* '<!-- __TEST_RESULT__ --> Test result 1 <!-- /__TEST_RESULT__ -->',
* '<!-- __TEST_RESULT__ --> Test result 2 <!-- /__TEST_RESULT__ -->',
* '<!-- __TEST_RESULT__ --> Test result 3 <!-- /__TEST_RESULT__ -->',
* ]
* ```
*/
.split(
new RegExp(
`(?<=${ TEST_RESULT.close })\n+(?:\.\.\.\n+)?(?=${ TEST_RESULT.open })`
)
)
: [];
// GitHub issues has character limits on issue's body,
// so we only preserve the first and the 9 latest results.
if ( testResultsList.length > 10 ) {
Expand All @@ -127,25 +131,26 @@ const metaData = {
];
}

// Reconstruct the body with the description + previous errors + new error.
body =
renderIssueDescription( { meta, testTitle, testPath } ) +
[
TEST_RESULTS_LIST.open,
...testResultsList,
renderTestErrorMessage( {
testRunner,
testPath,
testResults,
} ),
TEST_RESULTS_LIST.close,
].join( '\n' );
// Concat the test results list with the latest test results.
const formattedTestResults = [
...testResultsList,
formatTestResults( {
testRunner,
testPath,
testResults,
} ),
].join( '\n' );

const response = await octokit.rest.issues.update( {
...github.context.repo,
issue_number: reportedIssue.number,
state: 'open',
body,
body: renderIssueBody( {
meta,
testTitle,
testPath,
formattedTestResults,
} ),
} );

issue = response.data;
Expand All @@ -166,10 +171,9 @@ const metaData = {
title: issueTitle,
body: renderIssueBody( {
meta,
testRunner,
testTitle,
testPath,
testResults,
formattedTestResults: formatTestResults( testResults ),
} ),
labels: [ label ],
} );
Expand Down Expand Up @@ -235,18 +239,10 @@ function getIssueTitle( testTitle ) {

function renderIssueBody( {
meta,
testRunner,
testTitle,
testPath,
testResults,
formattedTestResults,
} ) {
return (
renderIssueDescription( { meta, testTitle, testPath } ) +
renderTestResults( { testRunner, testPath, testResults } )
);
}

function renderIssueDescription( { meta, testTitle, testPath } ) {
return `${ metaData.render( meta ) }
**Flaky test detected. This is an auto-generated issue by GitHub Actions. Please do NOT edit this manually.**
Expand All @@ -260,17 +256,13 @@ ${ testTitle }
\`${ meta.failedTimes } / ${ meta.totalCommits + meta.failedTimes }\` runs
## Errors
`;
}

function renderTestResults( { testRunner, testPath, testResults } ) {
return `${ TEST_RESULTS_LIST.open }
${ renderTestErrorMessage( { testRunner, testPath, testResults } ) }
${ TEST_RESULTS_LIST.open }
${ formattedTestResults }
${ TEST_RESULTS_LIST.close }
`;
}

function renderTestResults( { testRunner, testResults, testPath } ) {
function formatTestErrorMessage( { testRunner, testResults, testPath } ) {
switch ( testRunner ) {
case '@playwright/test': {
// Could do a slightly better formatting than this.
Expand All @@ -297,7 +289,7 @@ function renderTestResults( { testRunner, testResults, testPath } ) {
}
}

function renderTestErrorMessage( { testRunner, testPath, testResults } ) {
function formatTestResults( { testRunner, testPath, testResults } ) {
const date = new Date().toISOString();
// It will look something like this without formatting:
// ▶ [2021-08-31T16:15:19.875Z] Test passed after 2 failed attempts on trunk
Expand All @@ -310,7 +302,7 @@ function renderTestErrorMessage( { testRunner, testPath, testResults } ) {
</summary>
\`\`\`
${ renderTestResults( { testRunner, testPath, testResults } ) }
${ formatTestErrorMessage( { testRunner, testPath, testResults } ) }
\`\`\`
</details>${ TEST_RESULT.close }`;
}
Expand Down
10 changes: 7 additions & 3 deletions bin/packages/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ function isDirectory( pathname ) {
function isSourceFile( filename ) {
// Only run this regex on the relative path, otherwise we might run
// into some false positives when eg. the project directory contains `src`
const relativePath = path.relative( process.cwd(), filename );
const relativePath = path
.relative( process.cwd(), filename )
.replace( /\\/g, '/' );

return (
/\/src\/.+\.(js|json|scss|ts|tsx)$/.test( relativePath ) &&
Expand Down Expand Up @@ -98,6 +100,7 @@ function isWatchableFile( filename, skip ) {
// Recursive file watching is not available on a Linux-based OS. If this is the case,
// the watcher library falls back to watching changes in the subdirectories
// and passes the directories to this filter callback instead.

if ( isDirectory( filename ) ) {
return true;
}
Expand All @@ -117,8 +120,9 @@ function isWatchableFile( filename, skip ) {
function getBuildFile( srcFile ) {
// Could just use string.replace, but the user might have the project
// checked out and nested under another src folder.
const packageDir = srcFile.substr( 0, srcFile.lastIndexOf( '/src/' ) );
const filePath = srcFile.substr( srcFile.lastIndexOf( '/src/' ) + 5 );
const srcDir = `${ path.sep }src${ path.sep }`;
const packageDir = srcFile.substr( 0, srcFile.lastIndexOf( srcDir ) );
const filePath = srcFile.substr( srcFile.lastIndexOf( srcDir ) + 5 );
return path.resolve( packageDir, 'build', filePath );
}

Expand Down
Loading

0 comments on commit 5357ad2

Please sign in to comment.