Skip to content

Commit 434c655

Browse files
Dimitar Fenerskiclaude
andcommitted
ci: add prebuild script and CI test pipeline
Add scripts/prebuild.sh that gates releases behind lint, typecheck, and tests before committing and tagging. Add CI workflow that runs lint, typecheck, and tests on every push/PR. Add test steps to release workflow so tagged builds can't publish broken artifacts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8184897 commit 434c655

File tree

4 files changed

+157
-1
lines changed

4 files changed

+157
-1
lines changed

.github/workflows/ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
lint-and-typecheck:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 20
19+
cache: npm
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Lint
25+
run: npm run lint
26+
27+
- name: Type-check
28+
run: npx tsc -b
29+
30+
test-frontend:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: 20
39+
cache: npm
40+
41+
- name: Install dependencies
42+
run: npm ci
43+
44+
- name: Test
45+
run: npm run test
46+
47+
test-rust:
48+
runs-on: ubuntu-22.04
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Install system dependencies
53+
run: |
54+
sudo apt-get update
55+
sudo apt-get install -y \
56+
libwebkit2gtk-4.1-dev \
57+
libayatana-appindicator3-dev \
58+
librsvg2-dev \
59+
patchelf \
60+
libssl-dev \
61+
libgtk-3-dev
62+
63+
- name: Install Rust stable
64+
uses: dtolnay/rust-toolchain@stable
65+
66+
- name: Rust cache
67+
uses: swatinem/rust-cache@v2
68+
with:
69+
workspaces: src-tauri
70+
71+
- name: Run Rust tests
72+
working-directory: src-tauri
73+
run: cargo test --lib

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ jobs:
4343
- name: Install frontend dependencies
4444
run: npm ci
4545

46+
- name: Lint
47+
run: npm run lint
48+
49+
- name: Type-check
50+
run: npx tsc -b
51+
52+
- name: Frontend tests
53+
run: npm run test
54+
55+
- name: Rust tests
56+
working-directory: src-tauri
57+
run: cargo test --lib
58+
4659
- name: Build Tauri app
4760
uses: tauri-apps/tauri-action@v0
4861
env:

CLAUDE.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,25 @@ Panel toggle commands dispatch `CustomEvent` on `window` (e.g. `axiomatic:toggle
107107
- No component library — all UI is hand-written
108108
- PDFs rendered via `pdfium://` custom protocol (native PDFium, JPEG output)
109109
- **Test-before-modify rule**: Before changing any logic, verify it has test coverage. If not, extract into a testable unit and write tests FIRST. This applies to all logic — component wiring, command lists, state assembly — not just leaf components. Tests must assert desired behavior, not mirror current implementation.
110+
- **Pre-release gate**: Always run `./scripts/prebuild.sh <version>` before pushing a release tag. Never tag manually. The script runs the full lint → typecheck → test pipeline and only tags if everything passes.
110111

111112
## Commands
112113

113114
```bash
114115
npm run dev # tauri dev (vite + rust)
115116
npm run build # tauri build
116117
npm run vite:dev # vite only (no tauri)
117-
npx tsc --noEmit # type-check
118+
npx tsc -b # type-check (same as build uses)
119+
npm run lint # eslint
120+
npm run test # vitest unit tests
121+
cargo test --lib # rust unit tests (from src-tauri/)
122+
```
123+
124+
## Release workflow
125+
126+
```bash
127+
./scripts/prebuild.sh <version> # bump, lint, fix, test, commit, tag
128+
git push origin master --tags # push commit + tag → triggers CI release
118129
```
119130

120131
## Known gotchas

scripts/prebuild.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ $# -ne 1 ]; then
5+
echo "Usage: $0 <version>"
6+
echo "Example: $0 0.1.0"
7+
exit 1
8+
fi
9+
10+
VERSION="$1"
11+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
12+
cd "$ROOT"
13+
14+
echo "=== Prebuild pipeline for v${VERSION} ==="
15+
echo ""
16+
17+
# 1. Version bump
18+
echo ">> Bumping version..."
19+
bash scripts/bump-version.sh "$VERSION"
20+
echo ""
21+
22+
# 2. ESLint fix
23+
echo ">> Running ESLint with --fix..."
24+
npm run lint -- --fix
25+
echo ""
26+
27+
# 3. Type-check (same as vite:build uses — NOT --noEmit)
28+
echo ">> Type-checking (tsc -b)..."
29+
npx tsc -b
30+
echo ""
31+
32+
# 4. Frontend tests
33+
echo ">> Running Vitest..."
34+
npm run test
35+
echo ""
36+
37+
# 5. Rust check
38+
echo ">> Running cargo check..."
39+
(cd src-tauri && cargo check)
40+
echo ""
41+
42+
# 6. Rust tests
43+
echo ">> Running cargo test --lib..."
44+
(cd src-tauri && cargo test --lib)
45+
echo ""
46+
47+
# 7. Stage, commit, and tag
48+
echo ">> Committing and tagging..."
49+
git add -A
50+
git commit -m "chore: bump version to v${VERSION}"
51+
git tag "v${VERSION}"
52+
echo ""
53+
54+
echo "=== Done ==="
55+
echo " Commit: chore: bump version to v${VERSION}"
56+
echo " Tag: v${VERSION}"
57+
echo ""
58+
echo "Review the commit, then push:"
59+
echo " git push origin master --tags"

0 commit comments

Comments
 (0)