forked from lxc/incus
-
Notifications
You must be signed in to change notification settings - Fork 0
385 lines (338 loc) · 11.8 KB
/
build.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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
name: Build
on:
push:
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
shellcheck:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Differential ShellCheck
id: ShellCheck
uses: redhat-plumbers-in-action/differential-shellcheck@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact with ShellCheck defects in SARIF format
uses: actions/upload-artifact@v4
with:
name: Differential ShellCheck SARIF
path: ${{ steps.ShellCheck.outputs.sarif }}
build:
strategy:
fail-fast: false
matrix:
go:
- oldstable
- stable
- tip
runs-on: ubuntu-22.04
steps:
- name: Install Dependencies
run: |
sudo add-apt-repository ppa:cowsql/stable -y --no-update
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
autoconf \
automake \
libcowsql-dev \
libacl1-dev \
libcap-dev \
liblxc1 \
liblz4-dev \
libsqlite3-dev \
libudev-dev \
libuv1-dev \
lxc-dev \
make \
pkg-config
- name: Checkout
uses: actions/checkout@v4
- name: Install Go (${{ matrix.go != 'tip' && matrix.go || 'stable' }})
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go != 'tip' && matrix.go || 'stable' }}
- name: Install Go (tip)
if: matrix.go == 'tip'
run: |
go install golang.org/dl/gotip@latest
gotip download
~/sdk/gotip/bin/go version
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
- name: Save Go env
id: go-env
run: |
echo GOPATH=$(go env GOPATH) >> $GITHUB_OUTPUT
echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_OUTPUT
- name: Check compatible min Go version
run: |
go mod tidy
- name: Download go dependencies
run: |
go mod download
- name: Run Incus build
run: |
make
ls -aR $(go env GOPATH)
- name: Upload artifact (bin)
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.go }}-incus-bin
path: |
${{ steps.go-env.outputs.GOBIN }}
- name: Upload artifact (src)
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.go }}-incus-src
path: |
./
static-analysis:
name: Static Analysis
runs-on: ubuntu-22.04
needs: build
strategy:
fail-fast: false
matrix:
go:
- oldstable
- stable
- tip
steps:
- name: Install Dependencies
run: |
sudo add-apt-repository ppa:cowsql/stable -y --no-update
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
make
python3 -m pip install flake8
- name: Get source
uses: actions/download-artifact@v4
with:
name: ${{ matrix.go }}-incus-src
- name: Install Go (${{ matrix.go != 'tip' && matrix.go || 'stable' }})
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go != 'tip' && matrix.go || 'stable' }}
- name: Install Go (tip)
if: matrix.go == 'tip'
run: |
go install golang.org/dl/gotip@latest
gotip download
~/sdk/gotip/bin/go version
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
- name: Save Go env
id: go-env
run: |
echo GOPATH=$(go env GOPATH) >> $GITHUB_OUTPUT
echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_OUTPUT
- name: Get binaries
uses: actions/download-artifact@v4
with:
name: ${{ matrix.go }}-incus-bin
path: ${{ steps.go-env.outputs.GOBIN }}
- name: Run static analysis
env:
GITHUB_BEFORE: ${{ github.event.before }}
run: |
make static-analysis
unit-tests:
name: Unit Tests
runs-on: ubuntu-22.04
needs: build
strategy:
fail-fast: false
matrix:
go:
- oldstable
- stable
- tip
steps:
- name: Install Dependencies
run: |
sudo add-apt-repository ppa:cowsql/stable -y --no-update
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
libacl1-dev \
liblxc-dev \
libcap-dev \
libcowsql-dev \
libudev-dev
- name: Get source
uses: actions/download-artifact@v4
with:
name: ${{ matrix.go }}-incus-src
- name: Install Go (${{ matrix.go != 'tip' && matrix.go || 'stable' }})
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go != 'tip' && matrix.go || 'stable' }}
- name: Install Go (tip)
if: matrix.go == 'tip'
run: |
go install golang.org/dl/gotip@latest
gotip download
~/sdk/gotip/bin/go version
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
- name: Save Go env
id: go-env
run: |
echo GOPATH=$(go env GOPATH) >> $GITHUB_OUTPUT
echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_OUTPUT
- name: Get binaries
uses: actions/download-artifact@v4
with:
name: ${{ matrix.go }}-incus-bin
path: ${{ steps.go-env.outputs.GOBIN }}
- name: Unit tests (all)
run: |
sudo --preserve-env=CGO_CFLAGS,CGO_LDFLAGS,CGO_LDFLAGS_ALLOW,LD_LIBRARY_PATH LD_LIBRARY_PATH=${LD_LIBRARY_PATH} env "PATH=${PATH}" go test ./...
system-tests:
needs: build
env:
CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
INCUS_CEPH_CLUSTER: "ceph"
INCUS_CEPH_CEPHFS: "cephfs"
INCUS_CEPH_CEPHOBJECT_RADOSGW: "http://127.0.0.1"
INCUS_CONCURRENT: "1"
INCUS_VERBOSE: "1"
INCUS_OFFLINE: "1"
INCUS_TMPFS: "1"
INCUS_REQUIRED_TESTS: "test_storage_buckets"
name: System Tests
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
go:
- stable
suite:
- cluster
- standalone
backend:
- dir
- btrfs
- lvm
- zfs
- ceph
- random
include:
- go: oldstable
suite: cluster
backend: dir
- go: oldstable
suite: standalone
backend: dir
- go: tip
suite: cluster
backend: dir
- go: tip
suite: standalone
backend: dir
steps:
- name: Performance tuning
run: |
set -eux
# optimize ext4 FSes for performance, not reliability
for fs in $(findmnt --noheading --type ext4 --list --uniq | awk '{print $1}'); do
# nombcache and data=writeback cannot be changed on remount
sudo mount -o remount,noatime,barrier=0,commit=6000 "${fs}" || true
done
# disable dpkg from calling sync()
echo "force-unsafe-io" | sudo tee /etc/dpkg/dpkg.cfg.d/force-unsafe-io
- name: Reclaim some space
run: |
set -eux
sudo snap remove lxd --purge
# Purge older snap revisions that are disabled/superseded by newer revisions of the same snap
snap list --all | while read -r name _ rev _ _ notes _; do
[ "${notes}" = "disabled" ] && snap remove "${name}" --revision "${rev}" --purge
done || true
# This was inspired from https://github.com/easimon/maximize-build-space
df -h /
# dotnet
sudo rm -rf /usr/share/dotnet
# android
sudo rm -rf /usr/local/lib/android
# haskell
sudo rm -rf /opt/ghc
df -h /
- name: Remove docker
run: |
set -eux
sudo apt-get autopurge -y moby-containerd docker uidmap
sudo ip link delete docker0
sudo nft flush ruleset
- name: Get source
uses: actions/download-artifact@v4
with:
name: ${{ matrix.go }}-incus-src
- name: Get binaries
uses: actions/download-artifact@v4
with:
name: ${{ matrix.go }}-incus-bin
path: /home/runner/go/bin
- name: Setup MicroCeph
if: ${{ matrix.backend == 'ceph' }}
run: |
set -x
# If the rootfs and the ephemeral part are on the same physical disk, giving the whole
# disk to microceph would wipe our rootfs. Since it is pretty rare for GitHub Action
# runners to have a single disk, we immediately bail rather than trying to gracefully
# handle it. Once snapd releases with https://github.com/snapcore/snapd/pull/13150,
# we will be able to stop worrying about that special case.
if [ "$(stat -c '%d' /)" = "$(stat -c '%d' /mnt)" ]; then
echo "FAIL: rootfs and ephemeral part on the same disk, aborting"
exit 1
fi
sudo snap install microceph --channel=quincy/stable
sudo apt-get install --no-install-recommends -y ceph-common
sudo microceph cluster bootstrap
sudo microceph.ceph config set global osd_pool_default_size 1
sudo microceph.ceph config set global mon_allow_pool_delete true
sudo microceph.ceph config set global osd_memory_target 939524096
sudo microceph.ceph osd crush rule rm replicated_rule
sudo microceph.ceph osd crush rule create-replicated replicated default osd
for flag in nosnaptrim noscrub nobackfill norebalance norecover noscrub nodeep-scrub; do
sudo microceph.ceph osd set $flag
done
# Repurpose the ephemeral disk for ceph OSD.
sudo swapoff /mnt/swapfile
ephemeral_disk="$(findmnt --noheadings --output SOURCE --target /mnt | sed 's/[0-9]\+$//')"
sudo umount /mnt
sudo microceph disk add --wipe "${ephemeral_disk}"
sudo rm -rf /etc/ceph
sudo ln -s /var/snap/microceph/current/conf/ /etc/ceph
sudo microceph enable rgw
sudo microceph.ceph osd pool create cephfs_meta 32
sudo microceph.ceph osd pool create cephfs_data 32
sudo microceph.ceph fs new cephfs cephfs_meta cephfs_data
sudo microceph.ceph fs ls
sleep 30
sudo microceph.ceph status
# Wait until there are no more "unkowns" pgs
for _ in $(seq 60); do
if sudo microceph.ceph pg stat | grep -wF unknown; then
sleep 1
else
break
fi
done
sudo microceph.ceph status
sudo rm -f /snap/bin/rbd
- name: "Ensure offline mode (block image server)"
run: |
sudo nft add table inet filter
sudo nft add chain 'inet filter output { type filter hook output priority 10 ; }'
sudo nft add rule inet filter output ip daddr 45.45.148.8 reject
sudo nft add rule inet filter output ip6 daddr 2602:fc62:a:1::8 reject
- name: "Run system tests (${{ matrix.go }}, ${{ matrix.suite }}, ${{ matrix.backend }})"
run: |
chmod +x ~
echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid
cd $GITHUB_WORKSPACE/test
export PATH=/home/runner/go/bin:$PATH
sudo --preserve-env=PATH,GOPATH,GITHUB_ACTIONS,INCUS_VERBOSE,INCUS_BACKEND,INCUS_CEPH_CLUSTER,INCUS_CEPH_CEPHFS,INCUS_CEPH_CEPHOBJECT_RADOSGW,INCUS_OFFLINE,INCUS_SKIP_TESTS,INCUS_REQUIRED_TESTS, INCUS_BACKEND=${{ matrix.backend }} ./main.sh ${{ matrix.suite }}