Skip to content

Commit

Permalink
Merge branch 'trunk' into update/gen-block-lib-list
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinan committed May 21, 2023
2 parents 1aadf65 + d42095c commit 0a59cc7
Show file tree
Hide file tree
Showing 1,242 changed files with 36,762 additions and 20,040 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const restrictedImports = [
'flowRight',
'forEach',
'fromPairs',
'groupBy',
'has',
'identity',
'includes',
Expand All @@ -104,6 +105,7 @@ const restrictedImports = [
'lowerCase',
'map',
'mapKeys',
'mapValues',
'maxBy',
'memoize',
'merge',
Expand Down
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Documentation
/docs @ajitbohra @ryanwelcher @juanmaguitar @fabiankaegy
/docs @ajitbohra @ryanwelcher @juanmaguitar @fabiankaegy @ndiego

# Schemas
/schemas/json @ajlende
Expand Down Expand Up @@ -57,7 +57,7 @@
# Tooling
/bin @ntwb @nerrad @ajitbohra
/bin/api-docs @ntwb @nerrad @ajitbohra
/docs/tool @ajitbohra
/docs/tool @ajitbohra @ndiego
/packages/babel-plugin-import-jsx-pragma @ntwb @nerrad @ajitbohra
/packages/babel-plugin-makepot @ntwb @nerrad @ajitbohra
/packages/babel-preset-default @gziolo @ntwb @nerrad @ajitbohra
Expand Down Expand Up @@ -125,7 +125,7 @@
/packages/report-flaky-tests @kevin940726

# wp-env
/packages/env @noahtallen
/packages/env @noahtallen @ObliviousHarmony @t-hamano

# PHP
/lib @spacedmonkey
Expand Down
7 changes: 5 additions & 2 deletions .github/ISSUE_TEMPLATE/New_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,27 @@ This issue is to provide visibility on the progress of the release process of Gu
- [ ] Organize and Label PRs on the relevant milestone
- [ ] Start the release process by triggering the `rc` [workflow](https://developer.wordpress.org/block-editor/contributors/code/release/#running-workflow)
- [ ] [Update the created Draft Release accordingly](https://developer.wordpress.org/block-editor/contributors/code/release/#view-the-release-draft)
- [ ] [Curate the changelog](https://developer.wordpress.org/block-editor/contributors/code/release/#1-curating-the-changelog) before publishing
- [ ] Publish Release
- [ ] Announce in `#core-editor` channel that RC1 has been released and is ready for testing
- [ ] Ping any other relevant channels announcing that the RC is available
- [ ] Create Draft of Release post on Make Core blog _(initial draft in [Google doc](https://docs.google.com/document/d/1D-MTOCmL9eMlP9TDTXqlzuKVOg_ghCPm9_whHFViqMk/edit))_

### Between RC and Release

- [ ] Post a reminder in #core-editor for backporting PRs to RC (~Label Backport to Gutenberg RC)
- [ ] If there are any PRs marked as [Backport to RC](https://github.com/WordPress/gutenberg/pulls?q=is%3Apr+label%3A%22Backport+to+Gutenberg+RC%22+is%3Aclosed), run the [cherry-pick command to apply them](https://developer.wordpress.org/block-editor/contributors/code/release/auto-cherry-picking/#how-can-i-use-it-for-a-gutenberg-plugin-release) to the release branch. **This needs to be run locally**
- [ ] [Draft Release Post Highlights and Change Log](https://docs.google.com/document/d/1D-MTOCmL9eMlP9TDTXqlzuKVOg_ghCPm9_whHFViqMk/edit)
- [ ] Get assets from [Design Team](https://make.wordpress.org/design/) for the post
- [ ] Reach out to Highlight Authors to draft sections (if necessary)

### Release Day - {Weekday, Month, Date}

- [ ] If there are any PRs marked as [Backport to RC](https://github.com/WordPress/gutenberg/pulls?q=is%3Apr+label%3A%22Backport+to+Gutenberg+RC%22+is%3Aclosed), run the [cherry-pick command to apply them](https://developer.wordpress.org/block-editor/contributors/code/release/auto-cherry-picking/#how-can-i-use-it-for-a-gutenberg-plugin-release) to the release branch. **This needs to be run locally**
- [ ] Post a message in `#core-editor` channel to let folks know you are starting the release process
- [ ] Start the release process by triggering the `stable` [workflow](https://developer.wordpress.org/block-editor/contributors/code/release/#running-workflow)
- [ ] Update the created Draft Release accordingly. Typically by copy/pasting the last RC release notes and add any changes/updates as needed.
- [ ] Publish Release
- [ ] Trigger the update to the plugin directory - SVN _(get approval from member of Core team if necessary)_
- [ ] Trigger the update to the plugin directory. _(Get approval from a member of [Gutenberg Release team](https://github.com/orgs/WordPress/teams/gutenberg-release/members) if necessary)_
- [ ] Announce in `#core-editor` channel that the plugin has been released
- [ ] Reach out to other contributors to help get the post reviewed
- [ ] Publish Release post on Make Core blog
34 changes: 32 additions & 2 deletions .github/workflows/check-components-changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Verify @wordpress/components CHANGELOG update
name: OPTIONAL - Verify @wordpress/components CHANGELOG update

on:
pull_request:
Expand All @@ -23,13 +23,43 @@ jobs:
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: ${{ env.PR_COMMIT_COUNT }}
- name: 'Fetch relevant history from origin'
run: git fetch origin ${{ github.event.pull_request.base.ref }}
- name: Run git diff
- name: Check CHANGELOG status
env:
PR_NUMBER: ${{ github.event.number }}
run: |
changelog_path="packages/components/CHANGELOG.md"
optional_check_notice="This isn't a required check, so if you think your changes are small enough that they don't warrant a CHANGELOG entry, please go ahead and merge without one."
# Fail if the PR doesn't touch the changelog
if git diff --quiet ${{ github.event.pull_request.base.sha }} HEAD -- "$changelog_path"; then
echo "Please add a CHANGELOG entry to $changelog_path"
echo
echo "${optional_check_notice}"
exit 1
fi
pr_link_pattern="\[#${PR_NUMBER}\]\(https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER}\)"
pr_link_grep_pattern="\[#${PR_NUMBER}\](https://github\.com/WordPress/gutenberg/pull/${PR_NUMBER})"
unreleased_section=$(sed -n '/^## Unreleased$/,/^## /p' "${changelog_path}")
# Confirm that the CHANGELOG has an entry for the current PR
if ! grep -nq -e "${pr_link_grep_pattern}" "${changelog_path}"; then
echo "Please add a CHANGELOG entry to $changelog_path, and make sure your CHANGELOG entry has a link to the current PR."
echo
echo "${optional_check_notice}"
exit 1
fi
# Confirm that there is an 'Unreleased' section and that the relevant entry is in that section
if ! grep -nq -e '^## Unreleased' "${changelog_path}" || \
! [[ $unreleased_section = *${pr_link_pattern}* ]]; then
echo "Please make sure your CHANGELOG entry is in the \`## Unreleased\` section"
echo
echo "${optional_check_notice}"
exit 1
fi
2 changes: 1 addition & 1 deletion .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
WP_VERSION=$(awk -F ': ' '/^Tested up to/{print $2}' readme.txt)
IFS=. read -ra WP_VERSION_ARRAY <<< "$WP_VERSION"
WP_MAJOR="${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}"
./bin/plugin/cli.js perf "wp/$WP_MAJOR" "$PREVIOUS_RELEASE_BRANCH" "$CURRENT_RELEASE_BRANCH" --wp-version "$WP_MAJOR"
./bin/plugin/cli.js perf "wp/$WP_MAJOR" "$PREVIOUS_RELEASE_BRANCH" "$CURRENT_RELEASE_BRANCH" --tests-branch $GITHUB_SHA --wp-version "$WP_MAJOR"
- name: Compare performance with base branch
if: github.event_name == 'push'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ concurrency:

jobs:
test:
runs-on: macos-11
runs-on: macos-12
if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }}
strategy:
matrix:
xcode: ['13.2.1']
xcode: ['13.3.1']
device: ['iPhone 13']
native-test-name: [gutenberg-editor-rendering]

Expand Down Expand Up @@ -61,8 +61,8 @@ jobs:
- name: Build Web Driver Agent (if needed)
run: test -d packages/react-native-editor/ios/build/WDA || npm run native test:e2e:build-wda

- name: Force update Launch Database to prevent issues when opening the Simulator app
run: /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer/Applications/Simulator.app
- name: Launch simulator
run: open -a Simulator && xcrun simctl boot '${{ matrix.device }}'

- name: Run iOS Device Tests
run: TEST_RN_PLATFORM=ios npm run native device-tests:local ${{ matrix.native-test-name }}
Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,35 @@ jobs:
- name: Running single site unit tests
if: ${{ ! matrix.multisite }}
run: npm run test:unit:php
run: |
set -o pipefail
npm run test:unit:php | tee phpunit.log
- name: Running multisite unit tests
if: ${{ matrix.multisite }}
run: npm run test:unit:php:multisite
run: |
set -o pipefail
npm run test:unit:php:multisite | tee phpunit.log
# Verifies that PHPUnit actually runs in the first place. We want visibility
# into issues which can cause it to fail silently, so we check the output
# to verify that at least 500 tests have passed. This is an arbitrary
# number, but makes sure a drastic change doesn't happen without us noticing.
- name: Check number of passed tests
run: |
# Note: relies on PHPUnit execution to fail on test failure.
# Extract the number of executed tests from the log file.
if ! num_tests=$(grep -Eo 'OK \([0-9]+ tests' phpunit.log) ; then
if ! num_tests=$(grep -Eo 'Tests: [0-9]+, Assertions:' phpunit.log) ; then
echo "PHPUnit failed or did not run. Check the PHPUnit output in the previous step to debug." && exit 1
fi
fi
# Extract just the number of tests from the string.
num_tests=$(echo "$num_tests" | grep -Eo '[0-9]+')
if [ $num_tests -lt 500 ] ; then
echo "Only $num_tests tests passed, which is much fewer than expected." && exit 1
fi
echo "$num_tests tests passed."
phpcs:
name: PHP coding standards
Expand Down
29 changes: 29 additions & 0 deletions bin/api-docs/gen-theme-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,35 @@ styleSections.forEach( ( section ) => {
autogen += getSectionMarkup( section, styles[ section ], 'styles' );
} );

const templateTableGeneration = ( themeJson, context ) => {
let content = '';
content += '## ' + context + '\n\n';
content += themeJson.properties[ context ].description + '\n\n';
content +=
'Type: `' + themeJson.properties[ context ].items.type + '`.\n\n';
content += '| Property | Description | Type |\n';
content += '| --- | --- | --- |\n';
keys( themeJson.properties[ context ].items.properties ).forEach(
( key ) => {
content += `| ${ key } | ${ themeJson.properties[ context ].items.properties[ key ].description } | ${ themeJson.properties[ context ].items.properties[ key ].type } |\n`;
}
);
content += '\n\n';

return content;
};

// customTemplates
autogen += templateTableGeneration( themejson, 'customTemplates' );

// templateParts
autogen += templateTableGeneration( themejson, 'templateParts' );

// Patterns
autogen += '## Patterns' + '\n\n';
autogen += themejson.properties.patterns.description + '\n';
autogen += 'Type: `' + themejson.properties.patterns.type + '`.\n\n';

// Read existing file to wrap auto generated content.
let docsContent = fs.readFileSync( THEME_JSON_REF_DOC, {
encoding: 'utf8',
Expand Down
1 change: 1 addition & 0 deletions bin/build-plugin-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ build_files=$(
build/block-library/blocks/*.php \
build/block-library/blocks/*/block.json \
build/block-library/blocks/*/*.{js,js.map,css,asset.php} \
build/block-library/interactivity/*.{js,js.map,asset.php} \
build/edit-widgets/blocks/*/block.json \
build/widgets/blocks/*.php \
build/widgets/blocks/*/block.json \
Expand Down
8 changes: 6 additions & 2 deletions bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ async function buildCSS( file ) {
'animations',
'z-index',
]
// Editor styles should be excluded from the default CSS vars output.
// Editor and component styles should be excluded from the default CSS vars output.
.concat(
file.includes( 'common.scss' ) || ! file.includes( 'block-library' )
file.includes( 'common.scss' ) ||
! (
file.includes( 'block-library' ) ||
file.includes( 'components' )
)
? [ 'default-custom-properties' ]
: []
)
Expand Down
121 changes: 121 additions & 0 deletions bin/packages/check-build-type-declaration-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/**
* This script verifies the published index.d.ts file for every package which both
* builds types and also sets checkJs to false in its tsconfig.json. (This scenario
* can cause unchecked errors in JS files to be included in the compiled types.)
*
* We do so by running `tsc --noEmit` on the $package/build-types/index.d.ts file.
* This also verifies everything index.d.ts references, so it checks the entire
* public api of the type declarations for that package.
*
* @see https://github.com/WordPress/gutenberg/pull/49650 for more discussion.
*/

/**
* External dependencies
*/
const fs = require( 'fs' ).promises;
const path = require( 'path' );
const { exec } = require( 'child_process' );
const chalk = require( 'chalk' );

/**
* Returns whether a package needs its compiled types to be double-checked. This
* needs to happen when both of these are true:
* 1. The package compiles types. (It has a tsconfig file.)
* 2. The tsconfig sets checkJs to false.
*
* NOTE: In the future, if we run into issues parsing JSON, we should migrate to
* a proper json5 parser, such as the json5 npm package. The current regex just
* handles comments, which at the time is the only thing we use from JSON5.
*
* @param {string} packagePath Path to the package.
* @return {boolean} whether or not the package checksJs.
*/
async function packageNeedsExtraCheck( packagePath ) {
const configPath = path.join( packagePath, 'tsconfig.json' );

try {
const tsconfigRaw = await fs.readFile( configPath, 'utf-8' );
// Removes comments from the JSON5 string to convert it to plain JSON.
const jsonString = tsconfigRaw.replace( /\s+\/\/.*$/gm, '' );
const config = JSON.parse( jsonString );

// If checkJs both exists and is false, then we need the extra check.
return config.compilerOptions?.checkJs === false;
} catch ( e ) {
if ( e.code !== 'ENOENT' ) {
throw e;
}

// No tsconfig means no checkJs
return false;
}
}

// Returns the path to the build-types declaration file for a package if it exists.
// Throws an error and exits the script otherwise.
async function getDecFile( packagePath ) {
const decFile = path.join( packagePath, 'build-types', 'index.d.ts' );
try {
await fs.access( decFile );
return decFile;
} catch ( err ) {
console.error(
`Cannot access this declaration file. You may need to run tsc again: ${ decFile }`
);
process.exit( 1 );
}
}

async function typecheckDeclarations( file ) {
return new Promise( ( resolve, reject ) => {
exec( `npx tsc --noEmit ${ file }`, ( error, stdout, stderr ) => {
if ( error ) {
reject( { file, error, stderr, stdout } );
} else {
resolve( { file, stdout } );
}
} );
} );
}

async function checkUnverifiedDeclarationFiles() {
const packageDir = path.resolve( 'packages' );
const packageDirs = (
await fs.readdir( packageDir, { withFileTypes: true } )
)
.filter( ( dirent ) => dirent.isDirectory() )
.map( ( dirent ) => path.join( packageDir, dirent.name ) );

// Finds the compiled type declarations for each package which both checks
// types and has checkJs disabled.
const declarations = (
await Promise.all(
packageDirs.map( async ( pkg ) =>
( await packageNeedsExtraCheck( pkg ) )
? getDecFile( pkg )
: null
)
)
).filter( Boolean );

const tscResults = await Promise.allSettled(
declarations.map( typecheckDeclarations )
);

tscResults.forEach( ( { status, reason } ) => {
if ( status !== 'fulfilled' ) {
console.error(
chalk.red(
`Incorrect published types for ${ reason.file }:\n`
),
reason.stdout
);
}
} );

if ( tscResults.some( ( { status } ) => status !== 'fulfilled' ) ) {
process.exit( 1 );
}
}
checkUnverifiedDeclarationFiles();
Loading

0 comments on commit 0a59cc7

Please sign in to comment.