99 lines
3.7 KiB
YAML
99 lines
3.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, experiment/*]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
name: Tests & Quality Checks
|
|
runs-on: macos-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Full history for CodeScene
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy, llvm-tools-preview
|
|
|
|
- name: Install cargo-llvm-cov
|
|
uses: taiki-e/install-action@cargo-llvm-cov
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
# ── 1. Tests ──────────────────────────────────────────────────────────
|
|
- name: Run frontend tests
|
|
run: pnpm test
|
|
|
|
- name: Run Rust tests
|
|
run: cargo test --manifest-path=src-tauri/Cargo.toml
|
|
|
|
# ── 2. Coverage (enforced — fails build if thresholds not met) ────────
|
|
- name: Frontend coverage (≥70% lines/functions/branches/statements)
|
|
run: pnpm test:coverage
|
|
# Thresholds configured in vite.config.ts — exits non-zero if coverage drops
|
|
|
|
- name: Rust coverage (≥85% lines)
|
|
run: |
|
|
cargo llvm-cov \
|
|
--manifest-path src-tauri/Cargo.toml \
|
|
--fail-under-lines 85
|
|
# cargo-llvm-cov exits non-zero if line coverage drops below 85%
|
|
|
|
# ── 3. Code Health (CodeScene delta analysis) ─────────────────────────
|
|
- name: CodeScene Delta Analysis
|
|
uses: codescene-oss/codescene-delta-analysis-action@v1
|
|
with:
|
|
codescene-hostname: https://codescene.io
|
|
api-token: ${{ secrets.CODESCENE_TOKEN }}
|
|
project-id: ${{ secrets.CODESCENE_PROJECT_ID }}
|
|
fail-on-declining-code-health: true
|
|
# Requires CODESCENE_TOKEN + CODESCENE_PROJECT_ID in GitHub Secrets
|
|
# See .github/SETUP.md for setup instructions
|
|
continue-on-error: ${{ secrets.CODESCENE_TOKEN == '' }}
|
|
# Gracefully skip if secrets not configured yet
|
|
|
|
# ── 4. Documentation check (warning only — does not fail build) ───────
|
|
- name: Check docs are updated
|
|
continue-on-error: true
|
|
run: |
|
|
if git log -1 --pretty=%B | grep -i '\[skip docs\]' > /dev/null; then
|
|
echo "⏭️ Documentation check skipped"
|
|
exit 0
|
|
fi
|
|
if git diff --name-only origin/main | grep -E '^(src/|src-tauri/)' > /dev/null; then
|
|
if ! git diff --name-only origin/main | grep -E '^docs/' > /dev/null; then
|
|
echo "⚠️ Code files changed but docs/ not updated"
|
|
git diff --name-only origin/main | grep -E '^(src/|src-tauri/)'
|
|
echo "If this change affects architecture/abstractions/theme documented in docs/, update them."
|
|
echo "To suppress: include [skip docs] in your commit message."
|
|
fi
|
|
fi
|
|
echo "✅ Documentation check passed"
|
|
|
|
# ── 5. Lint & format ──────────────────────────────────────────────────
|
|
- name: Lint frontend
|
|
run: pnpm lint
|
|
|
|
- name: Clippy (Rust)
|
|
run: cargo clippy --manifest-path=src-tauri/Cargo.toml -- -D warnings
|
|
|
|
- name: Format check (Rust)
|
|
run: cargo fmt --manifest-path=src-tauri/Cargo.toml -- --check
|