-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (85 loc) · 2.39 KB
/
Copy pathci.yml
File metadata and controls
103 lines (85 loc) · 2.39 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: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: ['1.25', '1.26']
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
cache: true
- name: Run tests
shell: bash
run: go test -v -short -race -coverprofile=coverage.out -covermode=atomic ./...
- name: Upload coverage
if: matrix.os == 'ubuntu-latest' && matrix.go == '1.26'
uses: codecov/codecov-action@v7
with:
files: ./coverage.out
flags: unittests
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
coverage:
name: Coverage Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Run tests with coverage
shell: bash
run: go test -short -race -coverprofile=coverage.out -covermode=atomic ./internal/...
- name: Check coverage threshold
run: |
coverage=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Coverage: ${coverage}%"
threshold=95.0
if (( $(echo "$coverage < $threshold" | bc -l) )); then
echo "❌ Coverage ${coverage}% below threshold ${threshold}%"
exit 1
fi
echo "✅ Coverage ${coverage}% meets threshold"
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.9.0
args: --timeout=5m
- name: go fmt
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "❌ Files need formatting:"
echo "$unformatted"
exit 1
fi
- name: go vet
run: go vet ./...