-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (85 loc) · 2.57 KB
/
CI.yaml
File metadata and controls
102 lines (85 loc) · 2.57 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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
defaults:
run:
shell: bash
permissions:
contents: read
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
# - name: Run go vet
# run: go vet ./...
# - name: Install staticcheck
# run: go install honnef.co/go/tools/cmd/staticcheck@latest
# - name: Run staticcheck
# run: staticcheck ./...
# - name: Install golint
# run: go install golang.org/x/lint/golint@latest
# - name: Run golint
# run: golint -set_exit_status ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.2.0
with:
version: v1.48.0
skip-cache: true
# args: --enable-all
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Run tests
run: go test $(go list ./... | grep -v /cmd/) -race -gcflags=-l -v -coverprofile=coverage.txt -covermode=atomic -vet=off
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
# - name: Quality Gate - Test coverage shall be above threshold
# env:
# TESTCOVERAGE_THRESHOLD: 80
# run: |
# echo "Quality Gate: checking test coverage is above threshold ..."
# echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
# totalCoverage=`go tool cover -func=coverage.txt | grep total | grep -Eo '[0-9]+\.[0-9]+'`
# echo "Current test coverage : $totalCoverage %"
# if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
# echo "OK"
# else
# echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
# echo "Failed"
# exit 1
# fi
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Verify dependencies
run: go mod verify
- name: Build
run: go build -v ./...