Files
frank 5170ad633c
CI / Rust Format (pull_request) Successful in 18s
CI / Dependency-Track (BOM) (pull_request) Successful in 22s
CI / Rust Tests + Coverage (pull_request) Successful in 1m24s
CI / Clippy (SARIF) (pull_request) Successful in 1m41s
CI / TypeScript Lint + Typecheck (pull_request) Successful in 23s
CI / TypeScript Tests + Coverage (pull_request) Successful in 34s
CI / SonarQube (pull_request) Successful in 51s
CI / E2E Tests (Playwright + Electron) (pull_request) Successful in 1m42s
CI / Electron Release Build (pull_request) Successful in 2m5s
fix(sonar): use sonar.rust.lcov.reportPaths instead of generic coverage XML
Sonar job failed parsing target/sonar-rust-coverage.xml (Generic Coverage).
Official Rust import is LCOV via sonar.rust.lcov.reportPaths; drop XML
conversion in CI and keep target/lcov.info in the test-reports artifact.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 01:32:08 -04:00

96 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Local CI pre-flight — mirrors the split Gitea jobs: fmt, clippy, tests, (optional deny).
# CI scanning: SonarQube (scanner job) + Dependency-Track (BOM upload) are server-side;
# they are not run from this script.
#
# Usage:
# ./ci-check.sh [--fast] [--with-deny] [--with-e2e]
# --fast Skip llvm-cov; run plain nextest only.
# --with-deny Run cargo deny (not in CI by default; DT covers BOM/CVE workflow).
# --with-e2e After TS checks, run Playwright from e2e/ (needs dist-electron/main.js).
set -euo pipefail
FAST=0
WITH_DENY=0
WITH_E2E=0
for arg in "$@"; do
[[ "$arg" == "--fast" ]] && FAST=1
[[ "$arg" == "--with-deny" ]] && WITH_DENY=1
[[ "$arg" == "--with-e2e" ]] && WITH_E2E=1
done
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[0;33m'; BOLD='\033[1m'; NC='\033[0m'
ok() { echo -e "${GREEN}${BOLD} PASS${NC} $1"; }
fail() { echo -e "${RED}${BOLD} FAIL${NC} $1"; }
info() { echo -e "${YELLOW}${BOLD} ----${NC} $1"; }
ERRORS=0
run() {
local label="$1"; shift
info "$label"
if "$@"; then ok "$label"
else fail "$label"; ERRORS=$((ERRORS + 1))
fi
echo
}
echo -e "\n${BOLD}=== ByteDraft local CI ===${NC}\n"
# ── 1. Format ─────────────────────────────────────────────────────────────────
run "fmt" cargo fmt --all -- --check
# ── 2. Clippy ─────────────────────────────────────────────────────────────────
# CARGO_INCREMENTAL=0 forces a full re-check so cached artifacts can't hide warnings.
run "clippy" env CARGO_INCREMENTAL=0 cargo clippy --workspace -- -D warnings
# ── 3. Tests / Coverage ───────────────────────────────────────────────────────
if [[ "$FAST" -eq 1 ]]; then
run "tests (fast)" cargo nextest run --workspace
else
run "tests + coverage" cargo llvm-cov nextest --workspace --profile ci --lcov --output-path target/lcov.info
run "junit → Sonar test execution (Rust)" \
python3 scripts/junit_to_sonar_test_execution.py --flavor rust --repo-root . --strict
fi
# ── 4. Cargo Deny (optional) ────────────────────────────────────────────────────
if [[ "$WITH_DENY" -eq 1 ]]; then
run "deny" cargo deny check advisories licenses bans
fi
# ─── TypeScript frontend checks ───────────────────────────────────
if [ -d "ui" ]; then
echo ""
echo "=== TypeScript lint ==="
(cd ui && npm run lint)
echo ""
echo "=== TypeScript type-check ==="
(cd ui && npm run typecheck)
echo ""
run "TypeScript unit tests" bash -c "cd ui && npm run test:ci"
run "junit → Sonar test execution (Vitest)" \
python3 scripts/junit_to_sonar_test_execution.py --flavor vitest --repo-root . --strict
fi
# Optional: full E2E suite (Playwright browser + Electron projects)
if [[ "$WITH_E2E" -eq 1 ]]; then
if [ -f "dist-electron/main.js" ]; then
echo ""
echo "=== E2E tests (Playwright + Electron) ==="
( cd e2e && npm run test:e2e )
else
echo "WARNING: --with-e2e passed but dist-electron/main.js not found. Run npm run electron:compile from repo root first."
fi
fi
# ── Summary ───────────────────────────────────────────────────────────────────
echo -e "${BOLD}=== Summary ===${NC}"
if [[ "$ERRORS" -eq 0 ]]; then
echo -e "${GREEN}${BOLD}All checks passed.${NC}"
exit 0
else
echo -e "${RED}${BOLD}$ERRORS check(s) failed.${NC}"
exit 1
fi