forked from alibaba/open-code-review
-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (39 loc) · 1.2 KB
/
Copy pathci.yml
File metadata and controls
48 lines (39 loc) · 1.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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
test:
runs-on: self-hosted
timeout-minutes: 15
container:
image: golang:1.26.5
steps:
- uses: actions/checkout@v4
- name: Trust workspace
run: git config --global --replace-all safe.directory '*'
- name: Vet
run: go vet ./...
- name: Govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
- name: Test with coverage
run: |
go test -v -race -count=1 -coverprofile=coverage.out ./...
go tool cover -func=coverage.out | grep total: | awk '{print $3}'
- name: Check coverage threshold
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total: | awk '{print $3}' | sed 's/%//')
echo "Total coverage: ${COVERAGE}%"
if awk "BEGIN {exit !($COVERAGE < 80)}"; then
echo "FAIL: Coverage ${COVERAGE}% is below 80% threshold"
exit 1
fi
echo "PASS: Coverage ${COVERAGE}% meets 80% threshold"
- name: Build
run: go build -o /dev/null ./cmd/opencodereview