Skip to content

Commit f6de05f

Browse files
author
Jake Wood
authored
ci: working CI flow
1 parent 680a5fd commit f6de05f

6 files changed

Lines changed: 11212 additions & 1783 deletions

File tree

.github/workflows/build.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: 'Test, build, publish'
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- ci-test
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
install-dependencies:
15+
name: Install Node.js dependencies
16+
runs-on: ubuntu-latest
17+
env:
18+
cache-name: cache-node-modules
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
- name: Set up Node
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: 16.14.0
26+
- name: Compute hash key
27+
id: hash-key
28+
run: echo "hash=${{ hashFiles('**/package-lock.json') }}" >> "$GITHUB_OUTPUT"
29+
- name: Cache Node modules
30+
id: cache-npm
31+
uses: actions/cache@v3
32+
with:
33+
path: node_modules
34+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.hash-key.outputs.hash }}
35+
restore-keys: |
36+
${{ runner.os }}-build-${{ env.cache-name }}-
37+
${{ runner.os }}-build-
38+
${{ runner.os }}-
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
outputs:
43+
cache-key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.hash-key.outputs.hash }}
44+
45+
check-prettier:
46+
name: Check Prettier formatting
47+
runs-on: ubuntu-latest
48+
needs: [install-dependencies]
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v3
52+
- name: Set up Node
53+
uses: actions/setup-node@v3
54+
with:
55+
node-version: 16.14.0
56+
- name: Restore dependencies
57+
uses: actions/cache@v3
58+
with:
59+
path: node_modules
60+
key: ${{ needs.install-dependencies.outputs.cache-key }}
61+
- name: Check prettier formatting
62+
run: npm run format:check
63+
64+
run-cypress:
65+
name: Run Cypress tests
66+
runs-on: ubuntu-latest
67+
needs: [install-dependencies]
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v3
71+
- name: Set up Node
72+
uses: actions/setup-node@v3
73+
with:
74+
node-version: 16.14.0
75+
- name: Restore dependencies
76+
uses: actions/cache@v3
77+
with:
78+
path: node_modules
79+
key: ${{ needs.install-dependencies.outputs.cache-key }}
80+
- name: Run Cypress tests
81+
uses: cypress-io/github-action@v4
82+
with:
83+
build: bash ./ci/build-for-test.sh
84+
start: npx --yes http-server static/
85+
86+
publish:
87+
name: Publish to npm
88+
if: github.event_name == 'push' && github.ref == 'refs/heads/ci-test'
89+
needs: [install-dependencies, check-prettier, run-cypress]
90+
runs-on: ubuntu-latest
91+
steps:
92+
- name: Checkout repository
93+
uses: actions/checkout@v3
94+
with:
95+
fetch-depth: 0
96+
- name: Set up Node
97+
uses: actions/setup-node@v3
98+
with:
99+
node-version: 16.14.0
100+
- name: Restore dependencies
101+
uses: actions/cache@v3
102+
with:
103+
path: node_modules
104+
key: ${{ needs.install-dependencies.outputs.cache-key }}
105+
- name: Build the package
106+
run: npm run build
107+
- name: Run semantic release bot
108+
run: npx semantic-release
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.releaserc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"branches": [
3+
{
4+
"name": "main"
5+
},
6+
{
7+
"name": "ci-test",
8+
"channel": "ci"
9+
}
10+
]
11+
}

ci/build-for-test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
npm run build
4+
cp lib/index.js static/index.js

0 commit comments

Comments
 (0)