-
Notifications
You must be signed in to change notification settings - Fork 74
48 lines (39 loc) · 1.14 KB
/
go.yml
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: Go
on:
push:
branches: master
pull_request:
branches: master
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go 1.20
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.51
- name: Test
run: go test -v ./...
- name: Coverage
id: coverage
run: |
go test -v -coverpkg=./... -coverprofile=cov.out ./...
go tool cover -html=cov.out -o coverage.html
COV=$(go tool cover -func=cov.out | awk '/total/ { gsub("%", "", $3); print $3 }')
echo "Total coverage: ${COV} (Required ${MIN_COV})"
(( $(echo "${COV} > ${MIN_COV}" | bc -l) )) && echo "Min coverage passed" || exit 1
env:
MIN_COV: 60
- uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage.html
retention-days: 7