Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,30 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run Tests
shell: bash
run: |
if timeout 30s pnpm run test; then
echo "Tests completed within the 30-second limit."
else
status=$?
if [ "$status" -eq 124 ]; then
echo "Tests exceeded the 30-second limit; skipping the test check."
exit 0
fi
exit "$status"
fi
- name: Run Tests with Coverage
# Generates: coverage/lcov.info (→ Codecov)
# coverage/coverage-final.json (→ tooling)
# Exits non-zero when any configured threshold is breached.
run: pnpm vitest run --coverage --reporter=json --reporter=lcov

- name: Upload coverage reports to Codecov
# Requires a repository secret named CODECOV_TOKEN.
# Add it at: GitHub → Settings → Secrets → Actions → New repository secret.
# Obtain the token from https://codecov.io after connecting the repository.
# continue-on-error keeps the workflow green while the secret is absent.
uses: codecov/codecov-action@v4
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
fail_ci_if_error: false

- name: Upload coverage artefact
# Preserves the full coverage directory for offline inspection regardless
# of whether Codecov upload succeeds.
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 14

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ node_modules/
.env
dist/
build/
coverage/node_modules/
coverage/
.env.local
package-lock.json

Expand Down
56 changes: 56 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,59 @@ Use the PR template (auto-applied). Ensure it includes:
## Security

Do not commit secrets. Use `.env.local` for local environment variables.

---

## Code Coverage

### Minimum thresholds

CI enforces the following coverage thresholds (configured in
[`vitest.config.ts`](./vitest.config.ts)):

| Metric | Minimum |
|------------|---------|
| Lines | 60 % |
| Functions | 60 % |
| Branches | 50 % |
| Statements | 60 % |

**Do not lower these thresholds** to make a failing build pass.
If new code genuinely cannot be covered, discuss with the team first.

### Run coverage locally

```bash
pnpm run test:coverage
```

This writes the following files to `./coverage/`:

| File | Used by |
|-----------------------------|-------------------|
| `coverage/lcov.info` | Codecov / IDE |
| `coverage/coverage-final.json` | Tooling |
| `coverage/index.html` | Local HTML report |

Open `coverage/index.html` in a browser for a line-by-line breakdown.

### CI enforcement

The **Frontend CI** workflow (`ci.yml`) runs `vitest run --coverage` on every
PR targeting `main` or `develop`. The job fails — and blocks merge — when any
threshold is breached.

### Interpreting a failure

When thresholds are violated Vitest prints a table like:

```
ERROR: Coverage for lines (42.5 %) does not meet global threshold (60 %)
```

To resolve:

1. Add or improve tests for the uncovered code.
2. Re-run `pnpm run test:coverage` locally until the output shows no threshold
errors.
3. Push — CI will re-run automatically.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@
"tsx": "^4.20.3",
"typescript": "^5.8.3",
"vite": "^5.4.19",
"vitest": "^2.1.9"
"vitest": "^2.1.9",
"@vitest/coverage-v8": "^2.1.9"
},
"pnpm": {
"overrides": {
Expand Down
Loading
Loading