Skip to content

Commit

Permalink
code coverage ci
Browse files Browse the repository at this point in the history
  • Loading branch information
avkr003 committed Oct 5, 2024
1 parent 36eb585 commit 0c06c2d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Code Coverage Check

on:
push:
branches: [ avkr003/cc ]
pull_request:
branches: [ avkr003/cc ]

jobs:
test-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21' # Adjust this to match your project's Go version

- name: Install dependencies
run: go mod download

- name: Run tests with coverage
run: |
go test -v -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
- name: Check keeper package coverage
run: |
modules=$(find . -type d -name "x" -not -path "*/vendor/*")
for module in $modules; do
keeper_coverage=$(go tool cover -func=coverage.out | grep "${module}/keeper" | awk '{print $3}' | sed 's/%//')
if (( $(echo "$keeper_coverage < 90" | bc -l) )); then
echo "Coverage for ${module}/keeper is below 90%: ${keeper_coverage}%"
exit 1
fi
done
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage.out

0 comments on commit 0c06c2d

Please sign in to comment.