-
Notifications
You must be signed in to change notification settings - Fork 87
293 lines (279 loc) · 9.3 KB
/
ci.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
name: CI
on:
push:
branches:
- main
pull_request:
merge_group:
env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
defaults:
run:
shell: bash
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@cargo-hack
- uses: mkroening/rust-toolchain-toml@main
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check each feature
run: cargo hack check --package hermit-kernel --each-feature --no-dev-deps --target x86_64-unknown-none
env:
RUSTFLAGS:
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mkroening/rust-toolchain-toml@main
- run: rustup component add clippy
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
workspaces: |
.
hermit-builtins
- run: cargo xtask clippy
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mkroening/rust-toolchain-toml@main
- run: rustup component add rustfmt
- run: cargo fmt -- --check
check-docs:
name: Check docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mkroening/rust-toolchain-toml@main
- run: rustup target add aarch64-unknown-none-softfloat
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check docs
run: |
cargo doc --package hermit-kernel --no-deps --document-private-items --target x86_64-unknown-none
cargo doc --package hermit-kernel --no-deps --document-private-items --target aarch64-unknown-none-softfloat --no-default-features
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mkroening/rust-toolchain-toml@main
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
workspaces: |
.
hermit-builtins
- name: Build minimal kernel
run: |
cargo xtask build --arch x86_64 --no-default-features
cargo xtask build --arch aarch64 --no-default-features
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install QEMU
run: |
sudo apt-get update
sudo apt-get install qemu-system-x86
- uses: mkroening/rust-toolchain-toml@main
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
workspaces: |
.
hermit-builtins
- name: Unit tests
run: cargo test --lib
env:
RUSTFLAGS: -Awarnings
- name: Download loader
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: hermit-os/loader
file: rusty-loader-x86_64
- name: Integration tests
run: cargo test --tests --no-fail-fast --target x86_64-unknown-none -- --bootloader_path=rusty-loader-x86_64
env:
RUSTFLAGS:
run-hermit:
name: Run
runs-on: ubuntu-latest
defaults:
run:
working-directory: kernel
strategy:
matrix:
arch: [x86_64, aarch64]
package: [rusty_demo, httpd, testudp, hello_world]
netdev: [none, virtio-net-pci, rtl8139]
profile: [dev, release]
exclude:
# microvm (Firecracker) test does not run on aarch64
- package: hello_world
arch: aarch64
# rtl8139 support does not build on aarch64
- arch: aarch64
netdev: rtl8139
# Following packages do not depend on the netdev
- package: rusty_demo
netdev: virtio-net-pci
- package: rusty_demo
netdev: rtl8139
- package: hello_world
netdev: virtio-net-pci
- package: hello_world
netdev: rtl8139
# Following packages require a netdev
- package: httpd
netdev: none
- package: testudp
netdev: none
include:
- arch: x86_64
packages: qemu-system-x86 libcap-ng-dev libseccomp-dev socat
- arch: aarch64
packages: qemu-system-aarch64
- arch: x86_64
package: rusty_demo
flags: --features pci-ids --virtiofsd
- arch: aarch64
package: rusty_demo
flags: --features pci-ids
- package: httpd
flags: --features ci,dhcpv4
- package: testudp
flags: --features udp,dhcpv4
- package: hello_world
flags: --no-default-features --microvm
steps:
- name: Checkout hermit-rs
uses: actions/checkout@v4
with:
repository: hermit-os/hermit-rs
submodules: true
- name: Remove hermit-kernel submodule
run: git rm -r kernel
working-directory: .
- name: Checkout hermit-kernel
uses: actions/checkout@v4
with:
path: kernel
- name: Install QEMU
run: |
sudo apt-get update
sudo apt-get install ${{ matrix.packages }}
- uses: mkroening/rust-toolchain-toml@main
- uses: mkroening/rust-toolchain-toml@main
with:
toolchain-file: 'kernel/rust-toolchain.toml'
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.arch }}-${{ matrix.profile }}
save-if: ${{ github.ref == 'refs/heads/main' && matrix.package == 'rusty_demo' }}
workspaces: |
.
kernel
kernel/hermit-builtins
- name: Download loader
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: hermit-os/loader
file: rusty-loader-${{ matrix.arch }}
- name: Install virtiofsd
if: ${{ matrix.arch == 'x86_64' && matrix.package == 'rusty_demo' }}
run: cargo install virtiofsd
- name: Run VM
# cargo accepts multiple 'features' flags
# The '… && … || …' expression is like a ternary operator
run: >
cargo xtask ci qemu
--arch ${{ matrix.arch }}
--package ${{ matrix.package }}
${{ matrix.flags }}
${{ matrix.netdev == 'rtl8139' && '--features rtl8139' || '' }}
${{ matrix.netdev != 'none' && format('--netdev {0}', matrix.netdev) || '' }}
--profile ${{ matrix.profile }}
run-x86_64-kvm:
name: Run Hermit for Rust (x86_64 + kvm)
runs-on: [self-hosted]
defaults:
run:
working-directory: kernel
steps:
- name: Checkout hermit-rs
uses: actions/checkout@v4
with:
repository: hermit-os/hermit-rs
submodules: true
- name: Remove hermit-kernel submodule
run: git rm -r kernel
working-directory: .
- name: Checkout hermit-kernel
uses: actions/checkout@v4
with:
path: kernel
- name: Install QEMU
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends qemu-system-x86
- name: Check KVM availability
shell: bash
run: |
lscpu
kvm-ok
- name: Download loader (x86_64)
uses: dsaltares/fetch-gh-release-asset@master
with:
file: rusty-loader-x86_64
repo: hermit-os/loader
- name: Download loader (x86_64-fc)
uses: dsaltares/fetch-gh-release-asset@master
with:
file: rusty-loader-x86_64-fc
repo: hermit-os/loader
- name: Install firecracker
run: |
# https://github.com/firecracker-microvm/firecracker/blob/7c5fc8707f26c4244d48a747631ab0fb31fc4c39/docs/getting-started.md#getting-a-firecracker-binary
ARCH="$(uname -m)"
release_url="https://github.com/firecracker-microvm/firecracker/releases"
latest=$(basename $(curl -fsSLI -o /dev/null -w %{url_effective} ${release_url}/latest))
curl -L ${release_url}/download/${latest}/firecracker-${latest}-${ARCH}.tgz \
| tar -xz
# Rename the binary to "firecracker"
mv release-${latest}-$(uname -m)/firecracker-${latest}-${ARCH} firecracker
echo "$PWD" >> $GITHUB_PATH
- uses: dtolnay/rust-toolchain@stable
- run: cargo install uhyve
- uses: mkroening/rust-toolchain-toml@main
- uses: mkroening/rust-toolchain-toml@main
with:
toolchain-file: 'kernel/rust-toolchain.toml'
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
workspaces: |
.
kernel
kernel/hermit-builtins
- name: rusty_demo on Uhyve
run: cargo xtask ci uhyve --arch x86_64 --package rusty_demo
- name: rusty_demo on Uhyve (release)
run: cargo xtask ci uhyve --arch x86_64 --package rusty_demo --release
- name: rusty_demo on QEMU (with KVM)
run: cargo xtask ci qemu --arch x86_64 --package rusty_demo --accel
- name: rusty_demo on QEMU (with KVM, release)
run: cargo xtask ci qemu --arch x86_64 --package rusty_demo --accel --release
- name: hello_world on Firecracker
run: cargo xtask ci firecracker --arch x86_64 --package hello_world --no-default-features