-
Notifications
You must be signed in to change notification settings - Fork 421
274 lines (236 loc) · 8.48 KB
/
ci.yml
File metadata and controls
274 lines (236 loc) · 8.48 KB
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
name: CI
on:
pull_request:
branches:
- main
jobs:
unit-test:
runs-on: ubuntu-24.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: ./
# Make sure the latest changes from the pull request are used.
- name: Install
run: sudo ln -svf $PWD/bin/mkosi /usr/bin/mkosi
working-directory: ./
- name: Build tools tree
run: |
tee mkosi.local.conf <<EOF
[Build]
ToolsTreeDistribution=arch
EOF
mkosi -f box -- true
- name: Run ruff format
run: |
mkosi box -- ruff --version
if ! mkosi box -- ruff format --check --quiet mkosi/ tests/ kernel-install/*.install
then
echo "Please run 'ruff format' on the above files or apply the diffs below manually"
mkosi box -- ruff format --check --quiet --diff mkosi/ tests/ kernel-install/*.install
fi
- name: Run ruff check
run: |
mkosi box -- ruff --version
mkosi box -- ruff check --output-format=github mkosi/ tests/ kernel-install/*.install
- name: Check that tabs are not used in code
run: sh -c '! git grep -P "\\t" "*.py"'
- name: Spell Checking (codespell)
run: |
mkosi box -- codespell --version
mkosi box -- codespell $(git ls-files) --skip docs/style.css
- name: License Checking (reuse)
run: |
mkosi box -- reuse --version
if ! mkosi box -- reuse lint
then
echo "Hint: If the above output lists unlicensed files tracked in git you might need to adjust REUSE.toml"
exit 1
fi
- name: Type Checking (mypy)
run: |
mkosi box -- mypy --version
mkosi box -- mypy mkosi/ kernel-install/*.install
mkosi box -- mypy --python-version 3.10 mkosi/ tests/ kernel-install/*.install
- name: Type Checking (pyright)
run: |
mkosi box -- pyright --version
mkosi box -- pyright mkosi/ tests/ kernel-install/*.install
- name: Unit Tests
run: |
mkosi box -- python3 -m pytest --version
mkosi box -- python3 -m pytest -sv tests/
- name: Test execution from current working directory
run: python3 -m mkosi -h
- name: Test execution from current working directory (sudo call)
run: sudo python3 -m mkosi -h
- name: Test venv installation
run: |
python3 -m venv testvenv
testvenv/bin/python3 -m pip install --upgrade setuptools wheel pip
testvenv/bin/python3 -m pip install .
testvenv/bin/mkosi -h
rm -rf testvenv
- name: Test editable venv installation
run: |
python3 -m venv testvenv
testvenv/bin/python3 -m pip install --upgrade setuptools wheel pip
testvenv/bin/python3 -m pip install --editable .
testvenv/bin/mkosi -h
rm -rf testvenv
- name: Test zipapp creation
run: |
./tools/generate-zipapp.sh
./builddir/mkosi -h
./builddir/mkosi documentation
- name: Run shellcheck on scripts
run: |
bash -c 'shopt -s globstar; mkosi box -- shellcheck bin/mkosi tools/*.sh'
mkosi completion bash | mkosi box -- shellcheck -
- name: Test man page generation
run: mkosi box -- tools/make-man-page.sh
integration-test:
runs-on: ${{ matrix.runner }}
needs: unit-test
concurrency:
group: ${{ github.workflow }}-${{ matrix.distro }}-${{ matrix.tools }}-${{ matrix.runner }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
distro:
- arch
- centos
- debian
- fedora
- opensuse
- ubuntu
tools:
- arch
- centos
- debian
- fedora
- opensuse
- ubuntu
runner:
- ubuntu-24.04
exclude:
# pacman is not packaged in EPEL.
- distro: arch
tools: centos
# apt and debian-keyring are not packaged in EPEL.
- distro: debian
tools: centos
- distro: ubuntu
tools: centos
# pacman is not packaged in openSUSE.
- distro: arch
tools: opensuse
# apt, debian-keyring and ubuntu-keyring are not packaged in openSUSE.
- distro: debian
tools: opensuse
- distro: ubuntu
tools: opensuse
include:
# low rate limit on s390x/ppc64le/arm64 workers
- distro: debian
tools: debian
runner: ubuntu-24.04-arm
- distro: fedora
tools: fedora
runner: ubuntu-24.04-arm
- distro: opensuse
tools: opensuse
runner: ubuntu-24.04-arm
- distro: ubuntu
tools: ubuntu
runner: ubuntu-24.04-arm
- distro: fedora
tools: fedora
runner: ubuntu-24.04-ppc64le
- distro: debian
tools: debian
runner: ubuntu-24.04-ppc64le
- distro: debian
tools: debian
runner: ubuntu-24.04-s390x
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: ./
# Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space
# immediately, we remove the files in the background. However, we first move them to a different location so that
# nothing tries to use anything in these directories anymore while we're busy deleting them.
- name: Free disk space
run: |
sudo mv /usr/local /usr/local.trash
sudo mv /opt/hostedtoolcache /opt/hostedtoolcache.trash
sudo systemd-run rm -rf /usr/local.trash /opt/hostedtoolcache.trash
# Make sure the latest changes from the pull request are used.
- name: Install
run: sudo ln -svf $PWD/bin/mkosi /usr/bin/mkosi
working-directory: ./
- name: Configure
run: |
tee mkosi.local.conf <<EOF
[Distribution]
Distribution=${{ matrix.distro }}
[Output]
ManifestFormat=json
[Content]
KernelCommandLine=systemd.default_device_timeout_sec=180
[Build]
ToolsTreeDistribution=${{ matrix.tools }}
Environment=SYSTEMD_REPART_MKFS_OPTIONS_EROFS="--quiet"
[Runtime]
KVM=yes
EOF
# TODO: Remove once all distros have recent enough systemd that knows systemd.default_device_timeout_sec.
mkdir -p mkosi-initrd/mkosi.extra/usr/lib/systemd/system.conf.d
tee mkosi-initrd/mkosi.extra/usr/lib/systemd/system.conf.d/device-timeout.conf <<EOF
[Manager]
DefaultDeviceTimeoutSec=180
EOF
# TODO: Use $SYSTEMD_REPART_OVERRIDE_FSTYPE_ROOT once we drop support for Ubuntu Noble.
sed -i 's/return "btrfs"/return "ext4"/' mkosi/distribution/*.py
# fail if the script already exists, to avoid hard to debug CI errors
[[ -f mkosi.configure ]] && exit 1
tee mkosi.configure <<EOF
#!/bin/bash
echo "Hello from inside mkosi.configure!" >&2
cat
EOF
chmod +x mkosi.configure
# prepare and postinst are already used in CI
for script in sync build finalize postoutput clean
do
[[ -f "mkosi.${script}" ]] && exit 1
tee "mkosi.${script}" <<TOK
#!/bin/bash
echo "Hello from inside mkosi.${script}" >&2
TOK
chmod +x "mkosi.${script}"
done
- name: Generate key
run: sudo mkosi genkey
- name: Summary
run: sudo mkosi summary
- name: Build tools tree
run: sudo mkosi -f box -- true
- name: Build image
run: sudo mkosi -f
- name: Run integration tests
run: |
# Without KVM the tests are way too slow and time out
if [[ -e /dev/kvm ]]; then
sudo mkosi box -- \
timeout -k 30 1h \
python3 -m pytest \
--tb=no \
--capture=no \
--verbose \
-m integration \
--distribution ${{ matrix.distro }} \
tests/
fi