-
Notifications
You must be signed in to change notification settings - Fork 5
98 lines (85 loc) · 3.16 KB
/
Copy pathhost-checks.yml
File metadata and controls
98 lines (85 loc) · 3.16 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
name: Host checks (fmt, clippy, tests)
on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]
paths:
- 'host/**'
- '.github/workflows/host-checks.yml'
# Pushing a new commit to the same ref cancels any in-flight run on
# the previous commit — don't waste CI on stale code.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Fast per-PR gate: runs unit + integration tests, rustfmt check, and
# clippy with warnings-as-errors on the host crate. Matches the style
# upstream hyperlight uses. The integration tests in host/tests/ boot
# a Unikraft kernel via KVM, so this job requires /dev/kvm on the
# runner (same udev trick as test-examples.yml).
jobs:
checks:
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 25
defaults:
run:
working-directory: host
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
workspaces: host -> target
- name: Install Rust components for pinned toolchain
# The repo pins 1.89.0 via rust-toolchain.toml at the repo root.
# cargo fmt / clippy use the pinned channel, so install their
# components there. (working-directory is host/, so read from
# ../rust-toolchain.toml.)
working-directory: .
run: |
channel=$(grep '^channel' rust-toolchain.toml | awk -F'"' '{print $2}')
if [ -z "$channel" ]; then
echo "::error::could not parse channel from rust-toolchain.toml"
cat rust-toolchain.toml
exit 1
fi
echo "Installing rustfmt + clippy on channel $channel"
rustup component add --toolchain "$channel" rustfmt clippy
- name: Cargo fmt (check only)
run: cargo fmt --all -- --check
- name: Cargo clippy (warnings are errors)
run: cargo clippy --all-targets --locked -- -D warnings
- name: Cargo clippy with Wasm host tools
run: cargo clippy --bin hyperlight-unikraft --tests --locked --features wasm-host-fns -- -D warnings
- name: Enable KVM permissions
working-directory: .
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm || true
- name: Cargo test
env:
# Fewer integration-test iterations in CI — the test bodies
# skip themselves if /dev/kvm isn't available.
RUST_BACKTRACE: '1'
run: cargo test --all-targets --locked
- name: Cargo test with Wasm host tools
env:
RUST_BACKTRACE: '1'
run: cargo test --bin hyperlight-unikraft --locked --features wasm-host-fns wasm_host_fns::tests
host-checks-passed:
if: always()
needs: [checks]
runs-on: ubuntu-latest
permissions: {}
steps:
- run: |
r="${{ needs.checks.result }}"
if [[ "$r" != "success" ]]; then
echo "FAIL: checks = $r"
exit 1
fi
echo "All checks passed"