Skip to content

Commit 2b0a6a8

Browse files
refactor: CI workflow to use node-matrix for backend, frontend, and analytics jobs
1 parent 33a67ab commit 2b0a6a8

2 files changed

Lines changed: 66 additions & 84 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ on:
2525
- LICENSE
2626
- CODE_OF_CONDUCT.md
2727
- CONTRIBUTING.md
28+
schedule:
29+
# Nightly full CI run keeps the app checks fresh even without pushes.
30+
- cron: "30 2 * * *"
2831

2932
# Cancel any previous in-progress run for the same ref so we don't burn
3033
# runner minutes on superseded pushes while a PR is iterating.
@@ -80,94 +83,25 @@ jobs:
8083
run: cargo build --workspace --target wasm32-unknown-unknown --release
8184

8285
backend:
83-
name: Backend (NestJS)
84-
runs-on: ubuntu-latest
85-
defaults:
86-
run:
87-
working-directory: Backend
88-
steps:
89-
- name: Checkout
90-
uses: actions/checkout@v4
91-
92-
- name: Setup Node.js
93-
uses: actions/setup-node@v4
94-
with:
95-
node-version-file: .nvmrc
96-
cache: npm
97-
cache-dependency-path: package-lock.json
98-
99-
- name: Install dependencies
100-
run: npm ci
101-
102-
- name: Lint
103-
run: npm run lint
104-
105-
- name: Unit tests
106-
run: npm test -- --runInBand
107-
108-
# `nest build` invokes tsc, so this doubles as the typecheck step.
109-
- name: Build
110-
run: npm run build
86+
uses: ./.github/workflows/node-matrix.yml
87+
with:
88+
app-name: Backend (NestJS)
89+
working-directory: Backend
90+
verification-command: npm test -- --runInBand
11191

11292
frontend:
113-
name: Frontend (Next.js)
114-
runs-on: ubuntu-latest
115-
defaults:
116-
run:
117-
working-directory: Frontend
118-
steps:
119-
- name: Checkout
120-
uses: actions/checkout@v4
121-
122-
- name: Setup Node.js
123-
uses: actions/setup-node@v4
124-
with:
125-
node-version-file: .nvmrc
126-
cache: npm
127-
cache-dependency-path: package-lock.json
128-
129-
- name: Install dependencies
130-
run: npm ci
131-
132-
- name: Lint
133-
run: npm run lint
134-
135-
- name: Unit tests
136-
run: npm run test
137-
138-
# Next.js's `build` runs the TypeScript compiler end-to-end, so this
139-
# doubles as the typecheck step.
140-
- name: Build
141-
run: npm run build
93+
uses: ./.github/workflows/node-matrix.yml
94+
with:
95+
app-name: Frontend (Next.js)
96+
working-directory: Frontend
97+
verification-command: npm run test
14298

14399
analytics:
144-
name: Analytics (Next.js)
145-
runs-on: ubuntu-latest
146-
defaults:
147-
run:
148-
working-directory: analytics
149-
steps:
150-
- name: Checkout
151-
uses: actions/checkout@v4
152-
153-
- name: Setup Node.js
154-
uses: actions/setup-node@v4
155-
with:
156-
node-version-file: .nvmrc
157-
cache: npm
158-
cache-dependency-path: package-lock.json
159-
160-
- name: Install dependencies
161-
run: npm ci
162-
163-
- name: Lint
164-
run: npm run lint
165-
166-
- name: Typecheck
167-
run: npm run typecheck
168-
169-
- name: Build
170-
run: npm run build
100+
uses: ./.github/workflows/node-matrix.yml
101+
with:
102+
app-name: Analytics (Next.js)
103+
working-directory: analytics
104+
verification-command: npm run typecheck
171105

172106
terraform-fmt:
173107
name: Terraform fmt

.github/workflows/node-matrix.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Node Matrix
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
app-name:
7+
required: true
8+
type: string
9+
working-directory:
10+
required: true
11+
type: string
12+
verification-command:
13+
required: true
14+
type: string
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
node:
21+
name: ${{ inputs.app-name }}
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version-file: ${{ inputs.working-directory }}/.nvmrc
31+
cache: npm
32+
cache-dependency-path: ${{ inputs.working-directory }}/package-lock.json
33+
34+
- name: Install dependencies
35+
working-directory: ${{ inputs.working-directory }}
36+
run: npm ci
37+
38+
- name: Lint
39+
working-directory: ${{ inputs.working-directory }}
40+
run: npm run lint
41+
42+
- name: Verify
43+
working-directory: ${{ inputs.working-directory }}
44+
run: ${{ inputs.verification-command }}
45+
46+
- name: Build
47+
working-directory: ${{ inputs.working-directory }}
48+
run: npm run build

0 commit comments

Comments
 (0)