Skip to content

Commit

Permalink
Merge changes published in the Gutenberg plugin "release/15.3" branch
Browse files Browse the repository at this point in the history
  • Loading branch information
gutenbergplugin committed Mar 1, 2023
1 parent c25ff89 commit 145d8a3
Show file tree
Hide file tree
Showing 531 changed files with 14,093 additions and 9,093 deletions.
17 changes: 16 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const restrictedImports = [
'mapKeys',
'maxBy',
'memoize',
'merge',
'negate',
'noop',
'nth',
Expand Down Expand Up @@ -388,10 +389,21 @@ module.exports = {
'test/e2e/**/*.[tj]s',
'packages/e2e-test-utils-playwright/**/*.[tj]s',
],
extends: [ 'plugin:eslint-plugin-playwright/playwright-test' ],
extends: [
'plugin:eslint-plugin-playwright/playwright-test',
'plugin:@typescript-eslint/base',
],
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'./test/e2e/tsconfig.json',
'./packages/e2e-test-utils-playwright/tsconfig.json',
],
},
rules: {
'@wordpress/no-global-active-element': 'off',
'@wordpress/no-global-get-selection': 'off',
'playwright/no-page-pause': 'error',
'no-restricted-syntax': [
'error',
{
Expand All @@ -410,6 +422,9 @@ module.exports = {
message: 'Prefer page.locator instead.',
},
],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
},
},
{
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ on:
types: [published]
push:
branches: [trunk]
workflow_dispatch:
inputs:
branches:
description: 'branches or commits to compare (comma separated)'
required: true
wpversion:
description: 'The base WP version to use for the tests (latest or 6.0, 6.1...)'
required: false
default: 'latest'

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
Expand Down Expand Up @@ -86,6 +95,14 @@ jobs:
const commit_details = await github.rest.git.getCommit({owner: context.repo.owner, repo: context.repo.repo, commit_sha: context.sha});
return parseInt((new Date( commit_details.data.author.date ).getTime() / 1000).toFixed(0))
- name: Compare performance with custom branches
if: github.event_name == 'workflow_dispatch'
env:
BRANCHES: ${{ github.event.inputs.branches }}
WP_VERSION: ${{ github.event.inputs.wpversion }}
run: |
./bin/plugin/cli.js perf $(echo $BRANCHES | tr ',' ' ') --tests-branch $GITHUB_SHA --wp-version "$WP_VERSION"
- name: Publish performance results
if: github.event_name == 'push'
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
node-version: ${{ matrix.node }}

- name: Cache NPM packages
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3.2.5
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Use desired version of Java
uses: actions/setup-java@1df8dbefe2a8cbc99770194893dd902763bee34b # v3.9.0
uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 # v3.10.0
with:
distribution: 'temurin'
java-version: '11'
Expand All @@ -43,7 +43,7 @@ jobs:
uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # v2.3.3

- name: AVD cache
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3.2.5
id: avd-cache
with:
path: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ jobs:
run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt

- name: Restore build cache
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3.2.5
with:
path: |
packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app
packages/react-native-editor/ios/build/WDA
key: ${{ runner.os }}-ios-build-${{ matrix.xcode }}-${{ matrix.device }}-${{ hashFiles('ios-checksums.txt') }}

- name: Restore pods cache
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3.2.5
with:
path: |
packages/react-native-editor/ios/Pods
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT

- name: Cache PHPCS scan cache
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.0.11
uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3.0.11
with:
path: .cache/phpcs.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}
Expand Down
98 changes: 40 additions & 58 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const config = require( '../config' );
*
* @property {number[]} timeToFirstByte Represents the time since the browser started the request until it received a response.
* @property {number[]} largestContentfulPaint Represents the time when the main content of the page has likely loaded.
* @property {number[]} lcpMinusTtfb Represents the difference between LCP and TTFB.
* @property {number[]} serverResponse Represents the time the server takes to respond.
* @property {number[]} firstPaint Represents the time when the user agent first rendered after navigation.
* @property {number[]} domContentLoaded Represents the time immediately after the document's DOMContentLoaded event completes.
Expand All @@ -50,37 +51,36 @@ const config = require( '../config' );
/**
* @typedef WPPerformanceResults
*
* @property {number=} timeToFirstByteMedian Represents the time since the browser started the request until it received a response (median).
* @property {number=} timeToFirstByteP75 Represents the time since the browser started the request until it received a response (75th percentile).
* @property {number=} largestContentfulPaintMedian Represents the time when the main content of the page has likely loaded (median).
* @property {number=} largestContentfulPaintP75 Represents the time when the main content of the page has likely loaded (75th percentile).
* @property {number=} serverResponse Represents the time the server takes to respond.
* @property {number=} firstPaint Represents the time when the user agent first rendered after navigation.
* @property {number=} domContentLoaded Represents the time immediately after the document's DOMContentLoaded event completes.
* @property {number=} loaded Represents the time when the load event of the current document is completed.
* @property {number=} firstContentfulPaint Represents the time when the browser first renders any text or media.
* @property {number=} firstBlock Represents the time when Puppeteer first sees a block selector in the DOM.
* @property {number=} type Average type time.
* @property {number=} minType Minimum type time.
* @property {number=} maxType Maximum type time.
* @property {number=} typeContainer Average type time within a container.
* @property {number=} minTypeContainer Minimum type time within a container.
* @property {number=} maxTypeContainer Maximum type time within a container.
* @property {number=} focus Average block selection time.
* @property {number=} minFocus Min block selection time.
* @property {number=} maxFocus Max block selection time.
* @property {number=} inserterOpen Average time to open global inserter.
* @property {number=} minInserterOpen Min time to open global inserter.
* @property {number=} maxInserterOpen Max time to open global inserter.
* @property {number=} inserterSearch Average time to open global inserter.
* @property {number=} minInserterSearch Min time to open global inserter.
* @property {number=} maxInserterSearch Max time to open global inserter.
* @property {number=} inserterHover Average time to move mouse between two block item in the inserter.
* @property {number=} minInserterHover Min time to move mouse between two block item in the inserter.
* @property {number=} maxInserterHover Max time to move mouse between two block item in the inserter.
* @property {number=} listViewOpen Average time to open list view.
* @property {number=} minListViewOpen Min time to open list view.
* @property {number=} maxListViewOpen Max time to open list view.
* @property {number=} timeToFirstByte Represents the time since the browser started the request until it received a response.
* @property {number=} largestContentfulPaint Represents the time when the main content of the page has likely loaded.
* @property {number=} lcpMinusTtfb Represents the difference between LCP and TTFB.
* @property {number=} serverResponse Represents the time the server takes to respond.
* @property {number=} firstPaint Represents the time when the user agent first rendered after navigation.
* @property {number=} domContentLoaded Represents the time immediately after the document's DOMContentLoaded event completes.
* @property {number=} loaded Represents the time when the load event of the current document is completed.
* @property {number=} firstContentfulPaint Represents the time when the browser first renders any text or media.
* @property {number=} firstBlock Represents the time when Puppeteer first sees a block selector in the DOM.
* @property {number=} type Average type time.
* @property {number=} minType Minimum type time.
* @property {number=} maxType Maximum type time.
* @property {number=} typeContainer Average type time within a container.
* @property {number=} minTypeContainer Minimum type time within a container.
* @property {number=} maxTypeContainer Maximum type time within a container.
* @property {number=} focus Average block selection time.
* @property {number=} minFocus Min block selection time.
* @property {number=} maxFocus Max block selection time.
* @property {number=} inserterOpen Average time to open global inserter.
* @property {number=} minInserterOpen Min time to open global inserter.
* @property {number=} maxInserterOpen Max time to open global inserter.
* @property {number=} inserterSearch Average time to open global inserter.
* @property {number=} minInserterSearch Min time to open global inserter.
* @property {number=} maxInserterSearch Max time to open global inserter.
* @property {number=} inserterHover Average time to move mouse between two block item in the inserter.
* @property {number=} minInserterHover Min time to move mouse between two block item in the inserter.
* @property {number=} maxInserterHover Max time to move mouse between two block item in the inserter.
* @property {number=} listViewOpen Average time to open list view.
* @property {number=} minListViewOpen Min time to open list view.
* @property {number=} maxListViewOpen Max time to open list view.
*/

/**
Expand Down Expand Up @@ -109,19 +109,6 @@ function median( array ) {
: ( numbers[ mid - 1 ] + numbers[ mid ] ) / 2;
}

/**
* Computes the 75th percentile from an array of numbers.
*
* @param {number[]} array
*
* @return {number} 75th percentile of the given dataset.
*/
function percentile75( array ) {
const ascending = array.sort( ( a, b ) => a - b );
const position = Math.floor( ( 75 / 100 ) * array.length );
return ascending[ position ];
}

/**
* Rounds and format a time passed in milliseconds.
*
Expand All @@ -148,14 +135,9 @@ function curateResults( testSuite, results ) {
testSuite === 'front-end-block-theme'
) {
return {
timeToFirstByteMedian: median( results.timeToFirstByte ),
timeToFirstByteP75: percentile75( results.timeToFirstByte ),
largestContentfulPaintMedian: median(
results.largestContentfulPaint
),
largestContentfulPaintP75: percentile75(
results.largestContentfulPaint
),
timeToFirstByte: median( results.timeToFirstByte ),
largestContentfulPaint: median( results.largestContentfulPaint ),
lcpMinusTtfb: median( results.lcpMinusTtfb ),
};
}

Expand Down Expand Up @@ -323,14 +305,14 @@ async function runPerformanceTests( branches, options ) {
log( ` >> Fetching the ${ fancyBranch } branch` );
// @ts-ignore
await SimpleGit( buildPath ).reset( 'hard' ).checkout( branch );

log( ` >> Building the ${ fancyBranch } branch` );
await runShellScript(
'npm ci && npm run prebuild:packages && node ./bin/packages/build.js && npx wp-scripts build',
buildPath
);
}

log( ` >> Building the ${ fancyBranch } branch` );
await runShellScript(
'npm ci && npm run prebuild:packages && node ./bin/packages/build.js && npx wp-scripts build',
buildPath
);

await runShellScript(
'cp ' +
path.resolve(
Expand Down
2 changes: 1 addition & 1 deletion bin/plugin/commands/test/__snapshots__/changelog.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports[`getChangelog verify that the changelog is properly formatted 1`] = `
- Correct \`function_exists()\` check typo introduced in #33331. ([33513](https://github.com/WordPress/gutenberg/pull/33513))
- ESLint Plugin: Include .jsx extenstion when linting import statements. ([33746](https://github.com/WordPress/gutenberg/pull/33746))
- Fix block appender position in classic themes. ([33895](https://github.com/WordPress/gutenberg/pull/33895))
- Fix misspelling of \\"queries\\" in filter documentation. ([33799](https://github.com/WordPress/gutenberg/pull/33799))
- Fix misspelling of "queries" in filter documentation. ([33799](https://github.com/WordPress/gutenberg/pull/33799))
- Fix positioning discrepancy with draggable chip. ([33893](https://github.com/WordPress/gutenberg/pull/33893))
- Navigation Editor: Avoid React warning when creating a new menu. ([33843](https://github.com/WordPress/gutenberg/pull/33843))
Expand Down
Loading

1 comment on commit 145d8a3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 145d8a3.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4306404840
📝 Reported issues:

Please sign in to comment.