-
Notifications
You must be signed in to change notification settings - Fork 148
106 lines (103 loc) · 3.13 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
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
name: Go
on:
push:
branches: [ main ]
pull_request:
schedule:
- cron: "0 0 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/[email protected]
with:
go-version: 1.19.x
- name: Cache
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ github.job }}-${{ runner.os }}-go-build-
- name: Build
run: go build -v ./...
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/[email protected]
with:
go-version: 1.19.x
- name: Cache
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ github.job }}-${{ runner.os }}-go-build-
# Dependency for Go module github.com/google/gopacket
- name: Install libpcap-dev
run: sudo apt-get -y install libpcap-dev
- run: go test -v -coverprofile=profile.cov $(go list ./... | grep -v /.*test.*)
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
static_analysis:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: '1.19'
- name: Checkout code
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/.cache/staticcheck
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ github.job }}-${{ runner.os }}-go-build-
# Dependency for Go module github.com/google/gopacket
- name: Install libpcap-dev
run: sudo apt-get -y install libpcap-dev
- name: Go vet
run: GOGC=30 go vet ./...
- name: Gofmt
run: |
# gofmt always returns true, so we use grep '^' which returns
# true on non-empty output, but will otherwise passthrough all
# output lines.
if gofmt -d -s . | grep '^'; then
exit 1
fi
- name: Get goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Goimports
run: |
# goimports always returns true, so we use grep '^' which returns
# true on non-empty output, but will otherwise passthrough all
# output lines.
#
# goimports does not support "gofmt -s" so both goimports and gofmt are
# required.
if goimports -d . | grep '^'; then
exit 1
fi
- name: Get revive
run: go install github.com/mgechev/revive@latest
- name: Run revive
run: revive ./...
- name: Get staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Run staticcheck
run: GOGC=30 staticcheck ./...