Skip to content

Commit

Permalink
Move test scenario for creating block to shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jun 17, 2020
1 parent c7293c0 commit 4edffab
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/create-block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: npm install, build, and test
- name: npm install, build, format and lint
run: |
npm ci
npx wp-create-block esnext-test --no-wp-scripts
cd esnext-test
../node_modules/.bin/wp-scripts format-js
../node_modules/.bin/wp-scripts build
../node_modules/.bin/wp-scripts lint-style
../node_modules/.bin/wp-scripts lint-js
npm run test:create-block
env:
CI: true
31 changes: 31 additions & 0 deletions bin/test-create-block.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# This script validates whether `npm init @wordpress/block` works properly
# with the latest changes applied to the `master` branch. It purpousfuly
# 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

status () {
echo -e "\n\033[1;34m$1\033[0m\n"
}

status "Scaffolding block..."
rm -rf esnext-test
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
"publish:patch": "npm run clean:package-types && npm run build:packages && lerna publish --dist-tag patch",
"publish:prod": "npm run clean:package-types && npm run build:packages && lerna publish",
"test": "npm run lint && npm run test-unit",
"test:create-block": "./bin/test-create-block.sh",
"test-e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js",
"test-e2e:debug": "wp-scripts --inspect-brk test-e2e --config packages/e2e-tests/jest.config.js --puppeteer-devtools",
"test-e2e:watch": "npm run test-e2e -- --watch",
Expand Down

0 comments on commit 4edffab

Please sign in to comment.