-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (41 loc) · 1.36 KB
/
go-tests.yml
File metadata and controls
49 lines (41 loc) · 1.36 KB
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
44
45
46
47
48
49
name: Go Tests
on:
push:
branches: [main, feature/*, develop]
pull_request:
branches: [main, develop]
jobs:
test:
name: Run Go Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: true
- name: Install dependencies
run: go mod download
- name: Run tests
run: go test -v ./...
- name: Check test coverage
run: |
# Run tests with coverage, excluding main package
go test -coverprofile=coverage.out ./pkg/...
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | tr -d '%')
echo "Total coverage (excluding main package): $COVERAGE%"
if (( $(echo "$COVERAGE < 55" | bc -l) )); then
echo "Code coverage is below 55%. Please add more tests."
echo "Target coverage goal: 70% (gradually increasing)"
exit 1
fi
echo "✅ Coverage check passed! Current: $COVERAGE%, Target: 70%"
- name: Generate coverage report
run: go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.html