From 5d7d528979622a4567b5e1ef60eec6fea912de94 Mon Sep 17 00:00:00 2001 From: Eunice <110993924+unixfundz@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:17:38 +0000 Subject: [PATCH] ci(coverage): add frontend and contract coverage thresholds (#314) --- .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++++++++++++---- frontend/package.json | 8 +++++-- frontend/vite.config.ts | 13 +++++++++++ 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3012d56..d75c834 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,10 +47,30 @@ jobs: - name: Run property-based tests run: cargo test prop_ --all --features testutils + frontend: + name: Frontend Build & Lint + runs-on: ubuntu-latest + defaults: + run: + working-directory: frontend + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + - name: Install dependencies + run: npm ci + - name: Lint + run: npm run lint + - name: Build + run: npm run build + build: name: Build WASM runs-on: ubuntu-latest - needs: [fmt, lint, test] + needs: [fmt, lint, test, frontend] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -71,7 +91,7 @@ jobs: retention-days: 7 coverage: - name: Coverage + name: Contract Coverage runs-on: ubuntu-latest needs: test steps: @@ -80,10 +100,29 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Install cargo-tarpaulin run: cargo install cargo-tarpaulin --locked - - name: Generate coverage report - run: cargo tarpaulin --out Xml --output-dir coverage/ --features testutils --exclude-files "*/test*" + - name: Generate coverage report (fail below 60%) + run: cargo tarpaulin --out Xml --output-dir coverage/ --features testutils --exclude-files "*/test*" --fail-under 60 - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: files: coverage/cobertura.xml fail_ci_if_error: false + + frontend-coverage: + name: Frontend Coverage + runs-on: ubuntu-latest + needs: frontend + defaults: + run: + working-directory: frontend + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + - name: Install dependencies + run: npm ci + - name: Run coverage (fail below threshold) + run: npm run coverage diff --git a/frontend/package.json b/frontend/package.json index fcfd7ab..f481621 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,7 +8,9 @@ "build": "tsc && vite build", "preview": "vite preview", "lint": "eslint src --ext .ts,.tsx --report-unused-disable-directives --max-warnings 0", - "type-check": "tsc --noEmit" + "type-check": "tsc --noEmit", + "test": "vitest run", + "coverage": "vitest run --coverage" }, "dependencies": { "@stellar/stellar-sdk": "12.3.0", @@ -21,9 +23,11 @@ "@typescript-eslint/eslint-plugin": "7.13.0", "@typescript-eslint/parser": "7.13.0", "@vitejs/plugin-react": "4.3.1", + "@vitest/coverage-v8": "1.6.0", "eslint": "8.57.0", "eslint-plugin-react-hooks": "4.6.2", "typescript": "5.4.5", - "vite": "5.3.1" + "vite": "5.3.1", + "vitest": "1.6.0" } } diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index c212a38..8b4cbd4 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -10,4 +10,17 @@ export default defineConfig({ outDir: 'dist', sourcemap: true, }, + test: { + environment: 'jsdom', + coverage: { + provider: 'v8', + reporter: ['text', 'lcov'], + thresholds: { + lines: 60, + functions: 60, + branches: 60, + statements: 60, + }, + }, + }, });