-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing: Add verification for Create Block to Continues Integration (#…
…23195) * Create Block: Add control over @wordpress/scripts integration * Tests: Add CI integration for Create Block * Update create-block.yml * Update changelog file * Move test scenario for creating block to shell script * Stylistic fixes * Cleanup esnext-test directory after script is finished Co-authored-by: Dominik Schilling <dominikschilling+git@gmail.com>
- Loading branch information
Showing
10 changed files
with
147 additions
and
43 deletions.
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