-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (86 loc) · 2.55 KB
/
test.yml
File metadata and controls
107 lines (86 loc) · 2.55 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
104
105
106
107
name: Tests and Code Quality
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
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.25'
cache: true
- name: Download dependencies
run: go mod download
- name: Run tests with race detection
run: go test -race -coverprofile=coverage.out ./...
- name: Generate coverage report
run: go tool cover -html=coverage.out -o coverage.html
- name: Check coverage threshold
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Total coverage: ${COVERAGE}%"
if (( $(echo "$COVERAGE < 70.0" | bc -l) )); then
echo "Coverage ${COVERAGE}% is below 70% threshold"
exit 1
fi
echo "Coverage ${COVERAGE}% meets threshold"
- name: Upload coverage to artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: |
coverage.out
coverage.html
lint:
name: Lint Code
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.25'
cache: true
- name: Run go fmt
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Code is not formatted. Run 'go fmt ./...'"
gofmt -d .
exit 1
fi
- name: Run go vet
run: go vet ./...
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
- name: Run golangci-lint
run: golangci-lint run --timeout=5m
build:
name: Build Examples
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.25'
cache: true
- name: Build framework
run: go build ./...
- name: Build example services
run: |
for example in examples/*/; do
echo "Building ${example}..."
(cd "$example" && go build .) || exit 1
done
echo "All examples built successfully"