-
Notifications
You must be signed in to change notification settings - Fork 94
194 lines (160 loc) · 4.94 KB
/
Copy pathci.yml
File metadata and controls
194 lines (160 loc) · 4.94 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: ci
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
- name: Setup Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
- name: Lint
uses: golangci/golangci-lint-action@v9.3.0
with:
version: v2.12.2
- name: Install analyzers
run: |
go install honnef.co/go/tools/cmd/staticcheck@v0.7.0
go install mvdan.cc/gofumpt@v0.11.0
go install github.com/securego/gosec/v2/cmd/gosec@v2.28.0
go install golang.org/x/tools/cmd/deadcode@v0.48.0
- name: Vet
run: go vet ./...
- name: Staticcheck
run: '"$(go env GOPATH)/bin/staticcheck" ./...'
- name: Deadcode
run: |
output_file=$(mktemp)
"$(go env GOPATH)/bin/deadcode" -test ./... > "$output_file"
if [ -s "$output_file" ]; then
cat "$output_file"
exit 1
fi
- name: Gofumpt
run: |
changed="$("$(go env GOPATH)/bin/gofumpt" -l .)"
if [ -n "$changed" ]; then
printf 'gofumpt wants changes in:\n%s\n' "$changed"
exit 1
fi
- name: Gosec
run: |
"$(go env GOPATH)/bin/gosec" -exclude=G101,G115,G202,G301,G304 ./...
test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
- name: Setup Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
- name: Test with coverage
run: go test -count=1 ./... -coverprofile=coverage.out
- name: Exclude generated code from coverage
run: grep -v '^github.com/openclaw/discrawl/internal/store/storedb/' coverage.out > coverage.filtered.out
- name: Test with race detector
run: go test -count=1 -race ./...
- name: Enforce coverage floor
run: |
total="$(go tool cover -func=coverage.filtered.out | awk '/^total:/ { sub(/%$/, "", $3); print $3 }')"
awk -v total="$total" 'BEGIN {
if (total == "") {
print "missing coverage total"
exit 1
}
if (total + 0 < 85.0) {
printf("coverage %.1f%% is below 85%%\n", total + 0)
exit 1
}
printf("coverage %.1f%%\n", total + 0)
}'
- name: Build
run: go build -o bin/discrawl ./cmd/discrawl
- name: Smoke test CLI control surface
run: |
set -euo pipefail
output="$(./bin/discrawl help)"
printf '%s\n' "$output"
printf '%s' "$output" | grep -q "metadata"
printf '%s' "$output" | grep -q "tui"
test -n "$(./bin/discrawl --version)"
./bin/discrawl metadata --json | grep -q '"schema_version"'
./bin/discrawl status --json | grep -q '"databases"'
./bin/discrawl tui --json | grep -q '^\['
deps:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
- name: Setup Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
- name: Verify module cache
run: go mod verify
- name: Check go.mod tidy
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@v1.6.0
- name: Run govulncheck
run: '"$(go env GOPATH)/bin/govulncheck" ./...'
release-check:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
- name: Snapshot release build
uses: goreleaser/goreleaser-action@v7.2.3
with:
distribution: goreleaser
version: "~> v2"
args: release --snapshot --clean --skip=publish
secrets:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
- name: Install gitleaks
run: go install github.com/zricethezav/gitleaks/v8@v8.30.1
- name: Scan git history
run: |
"$(go env GOPATH)/bin/gitleaks" git --no-banner --redact
- name: Scan working tree
run: |
"$(go env GOPATH)/bin/gitleaks" dir . --no-banner --redact