-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (62 loc) · 2 KB
/
ci.yml
File metadata and controls
73 lines (62 loc) · 2 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout iterate
uses: actions/checkout@v4
with:
path: iterate
# The go.mod has: replace github.com/GrayCodeAI/iteragent => ../iteragent
# Clone at specific tag v1.6.0 to match local replace
- name: Checkout iteragent
uses: actions/checkout@v4
with:
repository: GrayCodeAI/iteragent
ref: v1.6.0
path: iteragent
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache-dependency-path: iterate/go.sum
- name: Build
working-directory: iterate
run: |
go mod tidy
go build ./...
- name: Test with coverage
working-directory: iterate
run: go test -race -coverprofile=coverage.out -v ./...
- name: Coverage summary
working-directory: iterate
run: go tool cover -func=coverage.out | tail -1
- name: Coverage check (min 50%)
working-directory: iterate
run: |
COVERAGE=$(go tool cover -func=coverage.out | tail -1 | awk '{print $3}' | tr -d '%')
echo "Total coverage: ${COVERAGE}%"
MIN_COVERAGE=50
RESULT=$(echo "$COVERAGE >= $MIN_COVERAGE" | bc -l)
if [ "$RESULT" -ne 1 ]; then
echo "::error::Coverage ${COVERAGE}% is below minimum ${MIN_COVERAGE}%"
exit 1
fi
echo "::notice::Coverage ${COVERAGE}% meets minimum threshold ${MIN_COVERAGE}%"
- name: Vet
working-directory: iterate
run: go vet ./...
- name: Format check
working-directory: iterate
run: test -z "$(gofmt -l .)" || (echo "Files need gofmt:" && gofmt -l . && exit 1)
- name: Save coverage artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: iterate/coverage.out