Skip to content

Commit ad26ac1

Browse files
committed
fix: update CI workflow to exclude main package from coverage calculation
1 parent adefb86 commit ad26ac1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

.github/workflows/go-tests.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,18 @@ jobs:
2424
run: go mod download
2525

2626
- name: Run tests
27-
run: go test -v ./... -coverprofile=coverage.out
27+
run: go test -v ./...
28+
29+
- name: Check test coverage
30+
run: |
31+
# Run tests with coverage, excluding main package
32+
go test -coverprofile=coverage.out ./pkg/...
33+
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%')
34+
echo "Total coverage (excluding main package): $COVERAGE%"
35+
if (( $(echo "$COVERAGE < 70" | bc -l) )); then
36+
echo "Code coverage is below 70%. Please add more tests."
37+
exit 1
38+
fi
2839
2940
- name: Generate coverage report
3041
run: go tool cover -html=coverage.out -o coverage.html
@@ -34,12 +45,3 @@ jobs:
3445
with:
3546
name: coverage-report
3647
path: coverage.html
37-
38-
- name: Check test coverage
39-
run: |
40-
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%')
41-
echo "Total coverage: $COVERAGE%"
42-
if (( $(echo "$COVERAGE < 70" | bc -l) )); then
43-
echo "Code coverage is below 70%. Please add more tests."
44-
exit 1
45-
fi

0 commit comments

Comments
 (0)