-
Notifications
You must be signed in to change notification settings - Fork 37
120 lines (102 loc) · 2.92 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Golang
on:
push:
branches:
- main
- "maint-*"
paths-ignore:
- 'docs/**'
pull_request:
branches:
- main
- "maint-*"
paths-ignore:
- 'docs/**'
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
go-version: [1.19.x]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Get Go dependencies
run: go get -v -t -d ./...
- name: Run tests
run: make test
- name: Build
run: |
make build
lint:
strategy:
matrix:
os: [ubuntu-latest]
go-version: [1.19.x]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Ensure go modules are tidy
run: |
go mod tidy
if [[ -n $(git status -s) ]] ; then
echo
echo -e "\e[31mRunning 'go mod tidy' changes the current setting"
echo -e "\e[31mEnsure to include updated go.mod and go.sum in this PR."
echo -e "\e[31mThis is usually done by running 'go mod tidy'\e[0m"
git status -s
git diff --color
exit 1
fi
- name: Ensure go fmt is clean
run: |
make fmt
if [[ -n $(git status -s) ]] ; then
echo
echo -e "\e[31mRunning 'make fmt' changes the current codebase"
echo -e "\e[31mEnsure to include updated codebase in this PR."
echo -e "\e[31mThis is usually done by running 'make fmt'\e[0m"
git status -s
git diff --color
exit 1
fi
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: "--out-${NO_FUTURE}format colored-line-number --timeout=5m12s"
skip-pkg-cache: true
skip-build-cache: true
gosec:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
GO111MODULE: on
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: "-exclude=G307 ./..."