-
Notifications
You must be signed in to change notification settings - Fork 7
76 lines (73 loc) · 2.35 KB
/
main.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
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
name: Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
tests:
runs-on: ubuntu-latest
name: Tests
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.*'
- name: Get dependencies
run: go get -v -t -d ./...
- name: Test
run: |
CGO_ENABLED=1 go run gotest.tools/[email protected] --junitfile test.xml --format testname -- -coverprofile coverage.txt -race ./...
go run github.com/boumenot/[email protected] -ignore-gen-files -by-files < coverage.txt > coverage.xml
- name: Code Coverage Summary Report
uses: irongut/[email protected]
with:
filename: coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: true
hide_complexity: true
indicators: true
output: both
thresholds: '50 75'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
static-checks:
runs-on: ubuntu-latest
name: Static checks
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.*'
- name: Get dependencies
run: go get -v -t -d ./...
- name: Go Vet
run: go vet ./...
- name: Go Fmt
run: |
fmt=$(gofmt -l .)
test -z $fmt || (echo "please run gofmt" ; echo $fmt ; exit 1)
- name: Go Staticcheck
run: go run honnef.co/go/tools/cmd/staticcheck@latest ./...
- name: Spelling
run: go run github.com/client9/misspell/cmd/[email protected] -error .
- name: Ineffective assignments
run: go run github.com/gordonklaus/ineffassign@4cc7213 .
- name: Goimports
run: |
go run golang.org/x/tools/cmd/goimports@latest -w .
git diff --quiet || (echo 'goimports requires code cleanup:' ; git diff ; exit 1)
- name: Go Generate
run: |
go generate ./...
git diff --quiet || (echo 'generated go files are not up-to-date, check go generate, go.sum and go.mod:' ; git diff ; exit 1)