Skip to content

Commit 108acb7

Browse files
authored
chore: Add support for running tests & prettier in CI (#441)
* chore: add support for running tests in CI * chore: don't fail fast for test matrix * chore: add lint:fix and format:check scripts * chore: run eslint & prettier in CI * chore: remove redundant lint check & clean up workflow a bit * chore: adjust name for build/lint workflow * fix: remove extra '-' that breaks build job step * chore: try to build against latest v12 instead * fix: remove caching when setting up node (it shouldn't be needed) * fix: correct plugin checkout directory * feat: run wdio tests against latest v12 core * fix: run tests in the plugin directory * feat: add build tests for non-PRs that rely on pinned v12 * feat: add support for WebdriverIO tests with pinned v12 (non-PRs) * fix: remove extra tip-of-tree stuff from pinned v12 build job * chore: rename tests workflow for less redundancy * chore: capitalization consistency * chore: empty commit to re-trigger CI
1 parent 5a6a74a commit 108acb7

File tree

3 files changed

+197
-10
lines changed

3 files changed

+197
-10
lines changed

.github/workflows/build.yml

Lines changed: 102 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,114 @@
1-
# Build workflow
2-
name: Build
1+
# Build & lint checks workflow
2+
name: Build & Lint Checks
33

4-
on: [pull_request, workflow_dispatch]
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
push:
8+
branches:
9+
- main
510

611
permissions:
712
contents: read
813

914
jobs:
15+
build_tip_of_tree_v12:
16+
name: Build test (against tip-of-tree core v12)
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout experimentation plugin
20+
uses: actions/checkout@v4
21+
with:
22+
path: main
23+
24+
- name: Checkout core Blockly
25+
uses: actions/checkout@v4
26+
with:
27+
repository: 'google/blockly'
28+
ref: 'rc/v12.0.0'
29+
path: core-blockly
30+
31+
- name: Use Node.js 20.x
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: 20.x
35+
36+
- name: NPM install
37+
run: |
38+
cd main
39+
npm install
40+
cd ..
41+
cd core-blockly
42+
npm install
43+
cd ..
44+
45+
- name: Link latest Blockly v12
46+
run: |
47+
cd core-blockly
48+
npm run package
49+
cd dist
50+
npm link
51+
cd ../../main
52+
npm link blockly
53+
cd ..
54+
55+
- name: Verify build
56+
run: |
57+
cd main
58+
npm run build
59+
1060
build:
61+
name: Build test (against pinned v12)
62+
# Don't run pinned version checks for PRs.
63+
if: ${{ !github.base_ref }}
1164
runs-on: ubuntu-latest
1265
steps:
13-
- name: Checkout
66+
- name: Checkout experimentation plugin
1467
uses: actions/checkout@v4
15-
- name: Setup Node
68+
69+
- name: Use Node.js 20.x
1670
uses: actions/setup-node@v4
1771
with:
18-
node-version: latest
19-
cache: 'npm'
20-
- run: npm ci
21-
- run: npm run build
22-
- run: npm run lint
72+
node-version: 20.x
73+
74+
- name: NPM install
75+
run: npm install
76+
77+
- name: Verify build
78+
run: npm run build
79+
80+
lint:
81+
name: Eslint check
82+
timeout-minutes: 5
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v4
86+
87+
- name: Use Node.js 20.x
88+
uses: actions/setup-node@v4
89+
with:
90+
node-version: 20.x
91+
92+
- name: NPM install
93+
run: npm install
94+
95+
- name: Eslint check format
96+
run: npm run lint
97+
98+
format:
99+
name: Prettier check
100+
timeout-minutes: 5
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- name: Use Node.js 20.x
106+
uses: actions/setup-node@v4
107+
with:
108+
node-version: 20.x
109+
110+
- name: NPM install
111+
run: npm install
112+
113+
- name: Prettier check format
114+
run: npm run format:check

.github/workflows/test.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Workflow for running automated tests.
2+
3+
name: Automated Tests
4+
5+
on:
6+
workflow_dispatch:
7+
pull_request:
8+
push:
9+
branches:
10+
- main
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
webdriverio_tests_tip_of_tree_v12:
17+
name: WebdriverIO tests (against tip-of-tree core v12)
18+
timeout-minutes: 10
19+
runs-on: ${{ matrix.os }}
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: [ubuntu-latest, macos-latest]
25+
26+
steps:
27+
- name: Checkout experimentation plugin
28+
uses: actions/checkout@v4
29+
with:
30+
path: main
31+
32+
- name: Checkout core Blockly
33+
uses: actions/checkout@v4
34+
with:
35+
repository: 'google/blockly'
36+
ref: 'rc/v12.0.0'
37+
path: core-blockly
38+
39+
- name: Use Node.js 20.x
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: 20.x
43+
44+
- name: NPM install
45+
run: |
46+
cd main
47+
npm install
48+
cd ..
49+
cd core-blockly
50+
npm install
51+
cd ..
52+
53+
- name: Link latest Blockly v12
54+
run: |
55+
cd core-blockly
56+
npm run package
57+
cd dist
58+
npm link
59+
cd ../../main
60+
npm link blockly
61+
cd ..
62+
63+
- name: Run tests
64+
run: |
65+
cd main
66+
npm run test
67+
68+
webdriverio_tests:
69+
name: WebdriverIO tests (against pinned v12)
70+
# Don't run pinned version checks for PRs.
71+
if: ${{ !github.base_ref }}
72+
timeout-minutes: 10
73+
runs-on: ${{ matrix.os }}
74+
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
os: [ubuntu-latest, macos-latest]
79+
80+
steps:
81+
- name: Checkout experimentation plugin
82+
uses: actions/checkout@v4
83+
84+
- name: Use Node.js 20.x
85+
uses: actions/setup-node@v4
86+
with:
87+
node-version: 20.x
88+
89+
- name: NPM install
90+
run: npm install
91+
92+
- name: Run tests
93+
run: npm run test

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"ghpages": "webpack",
99
"clean": "blockly-scripts clean",
1010
"lint": "eslint .",
11+
"lint:fix": "eslint . --fix",
1112
"format": "prettier --write .",
13+
"format:check": "prettier --check .",
1214
"predeploy": "blockly-scripts predeploy",
1315
"prepublishOnly": "npm login --registry https://wombat-dressing-room.appspot.com",
1416
"start": "blockly-scripts start",

0 commit comments

Comments
 (0)