Skip to content

Commit afec3b1

Browse files
Merge pull request #331 from Harkiratcodess/feat/add-ci-typecheck-lint-workflow
feat: add GitHub Actions CI workflow for typecheck and lint
2 parents 84379b9 + e4a551d commit afec3b1

1 file changed

Lines changed: 30 additions & 125 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -2,168 +2,73 @@ name: CI
22

33
on:
44
pull_request:
5-
push:
65
branches:
76
- main
8-
- dev
9-
10-
# Least-privilege token — CI only needs to read code
11-
permissions:
12-
contents: read
13-
14-
# Cancel in-progress runs for the same branch/PR to save CI minutes
15-
concurrency:
16-
group: ci-${{ github.ref }}
17-
cancel-in-progress: true
187

198
jobs:
20-
# ─── Client ────────────────────────────────────────────────────────────────
21-
22-
lint-client:
23-
name: Lint — Client
24-
runs-on: ubuntu-latest
25-
# Only run when client-side files actually changed
26-
if: |
27-
github.event_name == 'push' ||
28-
contains(github.event.pull_request.changed_files_url, 'client') ||
29-
true
30-
defaults:
31-
run:
32-
working-directory: client
33-
34-
steps:
35-
- name: Checkout
36-
uses: actions/checkout@v4
37-
38-
- name: Setup Node.js 20
39-
uses: actions/setup-node@v4
40-
with:
41-
node-version: 20
42-
cache: npm
43-
cache-dependency-path: client/package-lock.json
44-
45-
- name: Install dependencies
46-
run: npm ci
47-
48-
- name: Run ESLint
49-
run: npm run lint
50-
519
typecheck-client:
52-
name: Typecheck Client
10+
name: Typecheck Client
5311
runs-on: ubuntu-latest
54-
defaults:
55-
run:
56-
working-directory: client
57-
5812
steps:
59-
- name: Checkout
60-
uses: actions/checkout@v4
13+
- uses: actions/checkout@v4
6114

62-
- name: Setup Node.js 20
15+
- name: Setup Node.js
6316
uses: actions/setup-node@v4
6417
with:
6518
node-version: 20
66-
cache: npm
19+
cache: "npm"
6720
cache-dependency-path: client/package-lock.json
6821

6922
- name: Install dependencies
7023
run: npm ci
24+
working-directory: client
7125

72-
- name: Run TypeScript type-check
73-
# The client is a composite project: tsconfig.json references
74-
# tsconfig.app.json and tsconfig.node.json, both of which set
75-
# "noEmit": true — so `tsc -b` type-checks without emitting any files.
76-
# Plain `tsc --noEmit` is not used here because it does not understand
77-
# project references.
78-
run: npm run typecheck
79-
80-
# ─── Server ────────────────────────────────────────────────────────────────
26+
- name: Run TypeScript check
27+
run: npx tsc --noEmit
28+
working-directory: client
8129

82-
lint-server:
83-
name: Lint — Server
30+
typecheck-server:
31+
name: Typecheck Server
8432
runs-on: ubuntu-latest
85-
defaults:
86-
run:
87-
working-directory: server
88-
8933
steps:
90-
- name: Checkout
91-
uses: actions/checkout@v4
34+
- uses: actions/checkout@v4
9235

93-
- name: Setup Node.js 20
36+
- name: Setup Node.js
9437
uses: actions/setup-node@v4
9538
with:
9639
node-version: 20
97-
cache: npm
40+
cache: "npm"
9841
cache-dependency-path: server/package-lock.json
9942

10043
- name: Install dependencies
10144
run: npm ci
45+
working-directory: server
10246

103-
- name: Run ESLint
104-
# Non-blocking until an eslint.config.js is added to /server.
105-
# Once added, remove `continue-on-error` to enforce it as a hard gate.
106-
continue-on-error: true
107-
run: |
108-
if [ -f eslint.config.js ] || [ -f eslint.config.mjs ] || [ -f eslint.config.cjs ] || [ -f .eslintrc.json ] || [ -f .eslintrc.js ]; then
109-
echo "ESLint config found — running lint."
110-
npx eslint .
111-
else
112-
echo "::warning::No ESLint config in /server. Add eslint.config.js to enforce server-side linting."
113-
fi
47+
- name: Generate Prisma client
48+
run: npx prisma generate --schema=src/database/prisma/schema
49+
working-directory: server
11450

115-
typecheck-server:
116-
name: Typecheck — Server
117-
runs-on: ubuntu-latest
118-
defaults:
119-
run:
51+
- name: Run TypeScript check
52+
run: npx tsc --noEmit
12053
working-directory: server
12154

55+
lint-client:
56+
name: Lint Client
57+
runs-on: ubuntu-latest
12258
steps:
123-
- name: Checkout
124-
uses: actions/checkout@v4
59+
- uses: actions/checkout@v4
12560

126-
- name: Setup Node.js 20
61+
- name: Setup Node.js
12762
uses: actions/setup-node@v4
12863
with:
12964
node-version: 20
130-
cache: npm
131-
cache-dependency-path: server/package-lock.json
65+
cache: "npm"
66+
cache-dependency-path: client/package-lock.json
13267

13368
- name: Install dependencies
13469
run: npm ci
70+
working-directory: client
13571

136-
- name: Run TypeScript type-check
137-
# `tsc --noEmit` validates types without writing build output.
138-
# Defined as `npm run typecheck` in server/package.json so contributors
139-
# can run the same check locally.
140-
run: npm run typecheck
141-
142-
# ─── Gate ──────────────────────────────────────────────────────────────────
143-
# Single required status check to configure in branch protection rules.
144-
# Add this job name to Settings → Branches → Require status checks:
145-
# "CI / All checks passed"
146-
# This way you only need one rule regardless of how many jobs are added later.
147-
148-
ci-status:
149-
name: All checks passed
150-
runs-on: ubuntu-latest
151-
needs:
152-
- lint-client
153-
- typecheck-client
154-
- lint-server
155-
- typecheck-server
156-
# Run even if upstream jobs were skipped (e.g. path-filtered out)
157-
if: always()
158-
steps:
159-
- name: Check all jobs passed
160-
run: |
161-
results="${{ join(needs.*.result, ' ') }}"
162-
echo "Job results: $results"
163-
for result in $results; do
164-
if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
165-
echo "::error::One or more CI jobs failed. See above for details."
166-
exit 1
167-
fi
168-
done
169-
echo "All CI checks passed."
72+
- name: Run ESLint
73+
run: npx eslint . --ext .ts,.tsx || true
74+
working-directory: client

0 commit comments

Comments
 (0)