-
Notifications
You must be signed in to change notification settings - Fork 38
190 lines (181 loc) · 5.91 KB
/
repo-quality.yaml
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Checks codes
# We don't run tests here but on travis as we need to modprobe zfs, and so, needs a VM with the same version
# then our libzfs.
name: CI
on:
push:
branches:
- master
pull_request:
paths-ignore:
- '.github/workflows/commands.yaml'
- 'po/*'
jobs:
quality:
name: Code quality and mod files up to date
runs-on: ubuntu-latest
steps:
# Checkout code
- uses: actions/checkout@v3
# Install go
- uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Code formatting
run: |
FMT=`go fmt ./...`
echo "$FMT"
[ -z "$FMT" ]
- name: Check mod files
run: ./.github/ci/check-modules
build:
name: Build
runs-on: ubuntu-latest
container: ubuntu:devel
steps:
- uses: actions/checkout@v3
# Add dependencies
- name: Enable proposed
run: |
sed 's/updates/proposed/' /etc/apt/sources.list > /etc/apt/sources.list.d/proposed.list
cat <<EOF >/etc/apt/preferences.d/proposed.pref
Package: *
Pin: release a=*-proposed
Pin-Priority: 500
EOF
- name: Install dependencies
run: |
apt update
apt install -y ca-certificates gcc libzfslinux-dev
# Install go
- uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Building
run: go build ./...
generators:
name: Generated files are up to date
runs-on: ubuntu-latest
container: ubuntu:devel
steps:
# Add dependencies
- name: Enable proposed
run: |
sed 's/updates/proposed/' /etc/apt/sources.list > /etc/apt/sources.list.d/proposed.list
cat <<EOF >/etc/apt/preferences.d/proposed.pref
Package: *
Pin: release a=*-proposed
Pin-Priority: 500
EOF
- name: Install dependencies
run: |
apt update
DEBIAN_FRONTEND=noninteractive apt install -y ca-certificates gcc libzfslinux-dev protobuf-compiler gettext git
# Checkout code (using git that we just installed)
- uses: actions/checkout@v3
# Install go
- uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Install go grpc protoc generator
run: |
cd ..
GOPATH=`pwd` go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
cd -
extended-quality:
name: Extended quality checks
runs-on: ubuntu-latest
container: ubuntu:devel
steps:
# Checkout code
- uses: actions/checkout@v3
- name: Enable proposed
run: |
sed 's/updates/proposed/' /etc/apt/sources.list > /etc/apt/sources.list.d/proposed.list
cat <<EOF >/etc/apt/preferences.d/proposed.pref
Package: *
Pin: release a=*-proposed
Pin-Priority: 500
EOF
# Add dependencies
- name: Install dependencies
run: |
apt update
apt install -y ca-certificates gcc libzfslinux-dev # go vet needs libzfs headers (for cgo analysis)
# Install go
- uses: actions/setup-go@v4
with:
go-version: '1.20.x'
- name: Report suspicious constructs
run: go vet ./...
# TODO: add statichecks and others?
local-tests:
name: Tests with mocks
runs-on: ubuntu-latest
container: ubuntu:devel
steps:
- uses: actions/checkout@v3
# Install go
- uses: actions/setup-go@v4
with:
go-version: '1.20.x'
# Add dependencies
- name: Enable proposed
run: |
sed 's/updates/proposed/' /etc/apt/sources.list > /etc/apt/sources.list.d/proposed.list
cat <<EOF >/etc/apt/preferences.d/proposed.pref
Package: *
Pin: release a=*-proposed
Pin-Priority: 500
EOF
- name: Install dependencies
run: |
apt update
DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install ca-certificates gcc libzfslinux-dev dbus gettext
- name: Run tests with mock
run: |
go test -coverprofile=coverage.txt -covermode=atomic ./...
- name: Run tests (with race detector)
run: |
go test -race ./...
integration-tests:
name: Tests with system zfs
runs-on: ubuntu-latest
steps:
# Checkout code
- uses: actions/checkout@v3
# Reset env so that apt install golang-go then reads GOROOT with uncompatible local version installed by github
- name: Reset environment without GOROOT
run: sudo sed -i "/GOROOT/d" /etc/environment
# Add dependencies
- name: Install dependencies
continue-on-error: true
run: |
sudo add-apt-repository -y ppa:xnox/ubuntu/scratch
sudo apt install -y ca-certificates gcc libzfslinux-dev gettext golang-go
sudo sync
sudo modprobe zfs
- name: Run tests
continue-on-error: true
run: |
sudo go test -coverprofile=coverage.txt -covermode=atomic ./... -with-system-zfs
- name: Run tests (with race detector)
continue-on-error: true
run: |
sudo go test -race ./... -with-system-zfs
- name: Run benchkmarks
continue-on-error: true
run: |
sudo go test -bench -run=Benchmark ./... -with-system-zfs
- name: Upload coverage
continue-on-error: true
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
token: ${{secrets.CODECOV_TOKEN}}
# TODO: create a container on a schedule, with the following matrix:
# - ubuntu (rolling) | ubuntu (devel)
# - go X | go master
# every tests with ubuntu devel and go master aren't required (can be transitive failures)
# tests (race without race) -> travis