Skip to content

Commit 3b8b6b4

Browse files
committed
add tests
1 parent 9cfb50a commit 3b8b6b4

26 files changed

+5675
-1
lines changed

.claude/settings.local.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"permissions": {
33
"allow": [
4-
"Bash(go mod:*)"
4+
"Bash(go mod:*)",
5+
"Bash(go test:*)",
6+
"Bash(go tool:*)"
57
]
68
}
79
}

.github/workflows/test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
go-version: ['1.22', '1.23']
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
24+
- name: Download dependencies
25+
run: go mod download
26+
27+
- name: Build
28+
run: go build ./...
29+
30+
- name: Run tests
31+
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
32+
33+
- name: Check coverage
34+
run: |
35+
total=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
36+
echo "Total coverage: ${total}%"
37+
threshold=80
38+
if [ "$(echo "$total < $threshold" | bc -l)" -eq 1 ]; then
39+
echo "::error::Coverage ${total}% is below ${threshold}% threshold"
40+
exit 1
41+
fi
42+
43+
- name: Vet
44+
run: go vet ./...

0 commit comments

Comments
 (0)