-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing: Add verification for Create Block to Continues Integration #23195
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d9f27a7
Create Block: Add control over @wordpress/scripts integration
gziolo 7eec2fe
Tests: Add CI integration for Create Block
gziolo d1e7aa8
Update create-block.yml
gziolo c7293c0
Update changelog file
gziolo 4edffab
Move test scenario for creating block to shell script
gziolo 2dcfc7c
Stylistic fixes
gziolo 041ab1d
Cleanup esnext-test directory after script is finished
ocean90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Create Block | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'packages/**' | ||
- '!packages/**/test/**' | ||
- '!packages/**/*.md' | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js 12.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12.x | ||
- name: npm install, build, format and lint | ||
run: | | ||
npm ci | ||
npm run test:create-block | ||
env: | ||
CI: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# This script validates whether `npm init @wordpress/block` works properly | ||
# with the latest changes applied to the `master` branch. It purposefully | ||
# avoids installing `@wordpress/scripts` package from npm when scaffolding | ||
# a test block and uses the local package by executing everything from the | ||
# root of the project. | ||
|
||
# Exit if any command fails. | ||
set -e | ||
|
||
DIRECTORY="$PWD" | ||
|
||
status () { | ||
echo -e "\n\033[1;34m$1\033[0m\n" | ||
} | ||
|
||
cleanup() { | ||
rm -rf "$DIRECTORY/esnext-test" | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
status "Scaffolding block..." | ||
npx wp-create-block esnext-test --no-wp-scripts | ||
cd esnext-test | ||
|
||
status "Formatting JavaScript files..." | ||
../node_modules/.bin/wp-scripts format-js | ||
|
||
status "Building block..." | ||
../node_modules/.bin/wp-scripts build | ||
|
||
status "Lintig CSS files..." | ||
../node_modules/.bin/wp-scripts lint-style | ||
|
||
status "Linting JavaScript files..." | ||
../node_modules/.bin/wp-scripts lint-js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
const { isEmpty, omitBy } = require( 'lodash' ); | ||
const { join } = require( 'path' ); | ||
const writePkg = require( 'write-pkg' ); | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
const { info } = require( './log' ); | ||
|
||
module.exports = async ( { | ||
author, | ||
description, | ||
license, | ||
slug, | ||
version, | ||
wpScripts, | ||
} ) => { | ||
const cwd = join( process.cwd(), slug ); | ||
|
||
info( '' ); | ||
info( 'Creating a "package.json" file.' ); | ||
await writePkg( | ||
cwd, | ||
omitBy( | ||
{ | ||
name: slug, | ||
version, | ||
description, | ||
author, | ||
license, | ||
main: wpScripts && 'build/index.js', | ||
scripts: wpScripts && { | ||
build: 'wp-scripts build', | ||
'format:js': 'wp-scripts format-js', | ||
'lint:css': 'wp-scripts lint-style', | ||
'lint:js': 'wp-scripts lint-js', | ||
start: 'wp-scripts start', | ||
'packages-update': 'wp-scripts packages-update', | ||
}, | ||
}, | ||
isEmpty | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still unsure of what would be important here, maybe
package*.json
to cover the case when dependencies change. Although it would probably mean that one of the packages changed as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially thought about only adding @WordPress dependencies for create-block but it has none. 🙈
In this case probably all of
gutenberg/packages/scripts/package.json
Lines 36 to 42 in cb10e2d
packages/scripts/package.json
andpackages/create-block
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also
@wordpress/browserlist-config
or@wordpress/element
that is used by Babel. I said, it might be tricky to identify all dependencies used :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we add new configs, like
@wordpress/styleling-config
as proposed by @ntwb in #22777, we would have to update this list. I would personally prefer to extend the list of excluded files rather than allow list.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the current list and see how it goes.