-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (90 loc) · 3.15 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
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
107
108
109
110
111
## GitHub Actions workflow that runs tests on the Go project.
name: Run Tests
on:
push:
branches: [ 'master' ]
pull_request:
branches: [ 'master' ]
schedule:
- cron: '19 15 * * 4'
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
# permissions:
# actions: read
# contents: read
# security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '>=1.19.0'
check-latest: true
cache: true
- name: Install Core Dependencies
run: |
go mod download
- name: Test Compilation
run: go build -v ./...
- name: Install Additional Dependencies
run: |
go install -v github.com/fzipp/gocyclo/cmd/gocyclo@latest
go install -v github.com/uudashr/gocognit/cmd/gocognit@latest
go install -v github.com/client9/misspell/cmd/misspell@latest
go install -v github.com/gordonklaus/ineffassign@latest
go install -v golang.org/x/tools/cmd/goimports@latest
go install -v github.com/go-critic/go-critic/cmd/gocritic@latest
- name: Run Tests
run: go test -v ./...
- name: Run Linter
uses: golangci/golangci-lint-action@v3
with:
# version: v1.29
version: 'latest'
- name: Run Security Checks
uses: securego/gosec@master
with:
args: -quiet ./...
# run: |
# gosec -quiet ./...
# trivy fs --exit-code 1 --severity HIGH,CRITICAL --no-progress /github/workspace
- name: Run Vulnerability Scan
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '/github/workspace'
# image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
# format: 'table'
exit-code: '1'
# ignore-unfixed: true
# vuln-type: 'os,library'
severity: 'HIGH,CRITICAL'
- name: Run Code Coverage
run: |
go test -coverprofile=coverage.txt -covermode=atomic ./...
bash <(curl -s https://codecov.io/bash) -f coverage.txt
## TODO: gocyclo and gocognit seem like very similar tools, so do we actually need both of them?
- name: Run Code Quality Checks
run: |
# Check for cyclomatic complexity
gocyclo -over 15 .
# Check for cognitive complexity
gocognit .
## TODO: This seems useless, considering we already lint above?
# Check for linting errors
golint ./...
# Check for spelling errors (English only)
misspell -error -locale US .
# Check for ineffectual assignments
ineffassign .
# Check for unused imports
go vet ./...
# Check for formatting errors
gofmt -s -l .
# Check for import formatting errors
goimports -l .
# Check for code style errors
gocritic check -enableAll -disable='#experimental,#opinionated' .