diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-25 16:51:15 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-25 16:51:15 +0200 |
| commit | 8c27edc940bcf229596508536d49dac79b032bcf (patch) | |
| tree | 5390a5154e037cfaf16f7fd5d7e82aa235345b2b | |
| parent | d69b1b13c5027c3d6b316780a9ce6e2450ebac93 (diff) | |
ci: Add test coverage check to CI pipeline
- Updated .github/workflows/ci.yml to run tests with coverage
- Enforces minimum 60% coverage threshold
- Uploads coverage report as artifact for review
Coverage check command:
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out | grep total
| -rw-r--r-- | .github/workflows/ci.yml | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36b383e..8fd0031 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,8 +18,19 @@ jobs: with: go-version: '1.22' - - name: Run tests - run: go test ./... + - name: Run tests with coverage + run: | + go test -coverprofile=coverage.out ./... + if [ "$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%')" -lt 60 ]; then + echo "Coverage below 60%" + exit 1 + fi + + - name: Upload coverage to GitHub + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage.out lint: runs-on: ubuntu-latest |
