-
Notifications
You must be signed in to change notification settings - Fork 55
43 lines (36 loc) · 1.19 KB
/
coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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