-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (82 loc) · 2.49 KB
/
Copy pathtest.yml
File metadata and controls
103 lines (82 loc) · 2.49 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
- name: Download dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Build
run: make build
- name: Run tests with race detector and coverage
run: make test
- name: Generate detailed coverage report
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Check coverage threshold (80% minimum for pkg/)
run: |
echo "Checking coverage for each package..."
for pkg in $(go list ./pkg/...); do
coverage=$(go test -coverprofile=/tmp/coverage.out $pkg 2>&1 | grep -oP 'coverage: \K[0-9.]+' || echo "0")
pkg_name=$(echo $pkg | sed 's/.*\///')
echo "$pkg_name: ${coverage}%"
# Verify minimum 80% coverage for all pkg/ packages
if (( $(echo "$coverage < 80" | bc -l) )); then
echo "::error::$pkg_name has ${coverage}% coverage, which is below 80% threshold"
exit 1
fi
done
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Run Linters
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
- name: Run linters
run: make lint
build:
name: Build Binaries
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
- name: Build server
run: go build -v -o sprinkler-server ./cmd/server
- name: Build client
run: go build -v -o sprinkler-client ./cmd/client
- name: Verify binaries
run: |
./sprinkler-server -h || true
./sprinkler-client -h || true