-
Notifications
You must be signed in to change notification settings - Fork 15
212 lines (187 loc) · 7.55 KB
/
tests.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
name: Tests
on:
push:
pull_request:
paths:
- '.github/**'
- 'bin/**'
- 'tests/**'
schedule:
- cron: '38 6 * * *'
workflow_dispatch:
inputs:
ubuntu-releases:
description: List of Ubuntu releases to run the tests against. In JSON format, i.e. '["22.04", "24.04"]'.
type: string
default: '["20.04", "22.04", "24.04"]'
snap-tracks:
description: List of snap tracks to run the tests. In JSON format, i.e. '["latest/stable", "5.0/candidate"]'.
type: string
default: '["latest/edge"]'
self-hosted-runner:
type: boolean
description: Whether to use self-hosted runners to run the jobs.
default: false
tmate-debug:
description: Use tmate debugging session on integration test failure.
type: boolean
default: false
tmate-timeout:
description: Timeout in minutes to keep tmate debugging session.
type: number
default: 30
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
# XXX: scheduled runs should not cancel manually triggered ones
cancel-in-progress: ${{ !contains(github.event_name, 'schedule')}}
defaults:
run:
# Make sure bash is always invoked with `-eo pipefail`
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
shell: bash
jobs:
code-tests:
name: Code
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# A non-shallow clone is needed for the Differential ShellCheck
fetch-depth: 0
- name: yamllint
uses: ibiqlik/action-yamllint@v3
with:
file_or_dir: .github/workflows/
- id: ShellCheck
name: Differential ShellCheck
uses: redhat-plumbers-in-action/differential-shellcheck@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
strict-check-on-push: true
if: github.event_name == 'pull_request'
- name: Upload artifact with ShellCheck defects in SARIF format
uses: actions/upload-artifact@v4
with:
name: Differential ShellCheck SARIF
path: ${{ steps.ShellCheck.outputs.sarif }}
if: github.event_name == 'pull_request'
system-tests:
env:
PURGE_LXD: "1"
name: ${{ matrix.test }} (${{ matrix.track }} - ${{ matrix.os }})
runs-on: ubuntu-${{ matrix.os }}
permissions:
# need that to manipulate caches
actions: write
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(inputs.ubuntu-releases || '["24.04"]') }}
track: ${{ fromJSON(inputs.snap-tracks || '["latest/edge"]') }}
test:
- "storage-vm ceph"
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}" || cat /proc/self/mountinfo
done
# disable dpkg from calling sync()
echo "force-unsafe-io" | sudo tee /etc/dpkg/dpkg.cfg.d/force-unsafe-io
- name: Reclaim some space (storage tests only)
if: ${{ startsWith(matrix.test, 'storage') || matrix.test == 'vm-nesting' || matrix.test == 'conversion' }}
run: |
set -eux
df -h
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$ ]] && sudo snap remove "${name}" --revision "${rev}" --purge
done || true
# Remove leftover home directories
sudo rm -rf /home/linuxbrew /home/runneradmin
# Remove unneeded directories
sudo rm -rf /opt/google/chrome
sudo rm -rf /opt/hostedtoolcache/CodeQL /opt/hostedtoolcache/PyPy /opt/hostedtoolcache/Python
sudo rm -rf /opt/microsoft/msedge /opt/microsoft/msodbcsql* /opt/microsoft/powershell
sudo rm -rf /root/.sbt
# 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 containerd.io docker-ce podman uidmap
sudo ip link delete docker0
sudo nft flush ruleset || sudo iptables -I DOCKER-USER -j ACCEPT
- name: Checkout
uses: actions/checkout@v4
# needed for cache key
- name: Get Date
id: get-date
if: ${{ matrix.test == 'qemu-external-vm' }}
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
shell: bash
# for simplicity, just use one cache directory
# and make it valid for one day
- uses: actions/cache/restore@v4
id: cache-restore
if: ${{ matrix.test == 'qemu-external-vm' }}
with:
path: /home/runner/work/cache
key: cache-${{ steps.get-date.outputs.date }}
- name: Setup MicroCeph
if: ${{ matrix.test == 'storage-vm ceph' || matrix.test == 'storage-volumes-vm' }}
uses: simondeziel/lxd/.github/actions/setup-microceph@microceph-action-tweaks
with:
install-ceph-common: false
- name: ${{ matrix.test }} (${{ matrix.track }})
run: |
set -eux
# XXX: prevent accidental usage of `images:` in CI test jobs.
# All tests should be done using officially supported images.
echo '127.0.0.1 images.lxd.canonical.com' | sudo tee /etc/hosts
TEST_SCRIPT="$(echo ${{ matrix.test }} | cut -d " " -f 1)"
EXTRA_ARGS="$(echo ${{ matrix.test }} | cut -d " " -f 2- --only-delimited)"
if [ "${TEST_SCRIPT}" = "cluster" ]; then
dst_track="${{ matrix.track }}"
src_track="$(echo "${dst_track}" | cut -d/ -f1)/stable"
EXTRA_ARGS="${EXTRA_ARGS:-3} ${src_track} ${{ matrix.track }}"
fi
sudo --preserve-env=PURGE_LXD,TEST_IMG ./bin/local-run "tests/${TEST_SCRIPT}" ${{ matrix.track }} ${EXTRA_ARGS:-}
# always update cache as we have our own logic of
# cache invalidation and updates in addition to a date check
- name: Delete previous cache
if: ${{ steps.cache-restore.outputs.cache-hit }}
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "cache-${{ steps.get-date.outputs.date }}" --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/cache/save@v4
if: ${{ matrix.test == 'qemu-external-vm' }}
with:
path: /home/runner/work/cache
key: cache-${{ steps.get-date.outputs.date }}
- name: Tmate debugging session (self-hosted)
if: ${{ failure() && inputs.tmate-debug && inputs.self-hosted-runner }}
uses: canonical/action-tmate@main
timeout-minutes: ${{ inputs.tmate-timeout }}
- name: Tmate debugging session (gh-hosted)
if: ${{ failure() && inputs.tmate-debug && !inputs.self-hosted-runner }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: ${{ inputs.tmate-timeout }}