-
Notifications
You must be signed in to change notification settings - Fork 105
66 lines (52 loc) · 1.87 KB
/
test.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
name: test
on:
push:
branches: [ master ]
pull_request:
paths:
- '**.go'
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.20.0"
- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# Here, we simply print the exact go version, to have it as part of the
# action's output, which might be convenient.
- name: Print Go version
run: go version
# This check makes sure that the `go.mod` and `go.sum` files for Go
# modules are always up-to-date.
- name: Verify Go modules
run: go mod tidy && git status && git --no-pager diff && git diff-index --quiet HEAD --
# This check makes sure that the source code is formatted according to the
# Go standard `go fmt` formatting.
- name: Verify source code formatting
run: go fmt ./... && git status && git --no-pager diff && git diff-index --quiet HEAD --
- name: Install nmap
run: sudo apt install -y nmap
- name: Test
run: go test -coverprofile=c.out ./...
- name: Install goveralls
run: go install github.com/mattn/goveralls@latest
- name: Create coverage report
run: go tool cover -func=c.out
- name: Send coverage report
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=c.out -service=github
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/[email protected]
- name: Run staticcheck for possible optimizations
run: staticcheck -tests=false