diff --git a/.github/workflows/create-block.yml b/.github/workflows/create-block.yml index dc50bc74a7b59..5ca64c5e7ed91 100644 --- a/.github/workflows/create-block.yml +++ b/.github/workflows/create-block.yml @@ -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 diff --git a/bin/test-create-block.sh b/bin/test-create-block.sh new file mode 100755 index 0000000000000..5294db1bfe3a2 --- /dev/null +++ b/bin/test-create-block.sh @@ -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 diff --git a/package.json b/package.json index 382bd3756fd8b..7aa809b901375 100644 --- a/package.json +++ b/package.json @@ -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",