Skip to content

Commit 02b4c21

Browse files
committed
initial commit
Signed-off-by: danbugs <danilochiarlone@gmail.com>
0 parents  commit 02b4c21

106 files changed

Lines changed: 14990 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/host-checks.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Host checks (fmt, clippy, tests)
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main]
7+
paths:
8+
- 'host/**'
9+
- '.github/workflows/host-checks.yml'
10+
push:
11+
branches: [main]
12+
paths:
13+
- 'host/**'
14+
- '.github/workflows/host-checks.yml'
15+
16+
# Pushing a new commit to the same ref cancels any in-flight run on
17+
# the previous commit — don't waste CI on stale code.
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
# Fast per-PR gate: runs unit + integration tests, rustfmt check, and
23+
# clippy with warnings-as-errors on the host crate. Matches the style
24+
# upstream hyperlight uses. The integration tests in host/tests/ boot
25+
# a Unikraft kernel via KVM, so this job requires /dev/kvm on the
26+
# runner (same udev trick as test-examples.yml).
27+
28+
jobs:
29+
checks:
30+
runs-on: ubuntu-latest
31+
timeout-minutes: 25
32+
defaults:
33+
run:
34+
working-directory: host
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Install Rust components for pinned toolchain
39+
# The repo pins 1.89.0 via rust-toolchain.toml at the repo root.
40+
# cargo fmt / clippy use the pinned channel, so install their
41+
# components there. (working-directory is host/, so read from
42+
# ../rust-toolchain.toml.)
43+
working-directory: .
44+
run: |
45+
channel=$(grep '^channel' rust-toolchain.toml | awk -F'"' '{print $2}')
46+
if [ -z "$channel" ]; then
47+
echo "::error::could not parse channel from rust-toolchain.toml"
48+
cat rust-toolchain.toml
49+
exit 1
50+
fi
51+
echo "Installing rustfmt + clippy on channel $channel"
52+
rustup component add --toolchain "$channel" rustfmt clippy
53+
54+
- name: Cargo fmt (check only)
55+
run: cargo fmt --all -- --check
56+
57+
- name: Cargo clippy (warnings are errors)
58+
run: cargo clippy --all-targets --locked -- -D warnings
59+
60+
- name: Enable KVM permissions
61+
working-directory: .
62+
run: |
63+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
64+
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
65+
sudo udevadm control --reload-rules
66+
sudo udevadm trigger --name-match=kvm || true
67+
68+
- name: Cargo test
69+
env:
70+
# Fewer integration-test iterations in CI — the test bodies
71+
# skip themselves if /dev/kvm isn't available.
72+
RUST_BACKTRACE: '1'
73+
run: cargo test --all-targets --locked
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: Publish kernels and runtime bases to GHCR
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
paths:
8+
- 'examples/**'
9+
- 'runtimes/**'
10+
- '.github/workflows/publish-examples.yml'
11+
12+
# Only one publish run per ref at a time. cancel-in-progress ensures a
13+
# newer commit supersedes an older publish cleanly; GHCR tags are
14+
# idempotent so the latest push always wins.
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
env:
20+
REGISTRY: ghcr.io
21+
IMAGE_BASE: ghcr.io/${{ github.repository }}
22+
23+
jobs:
24+
# Publish base runtime images (interpreted languages)
25+
publish-bases:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
packages: write
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
runtime: [python, nodejs, powershell, shell]
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Log in to GHCR
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ${{ env.REGISTRY }}
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Build and push base image
45+
run: |
46+
IMAGE=${{ env.IMAGE_BASE }}/${{ matrix.runtime }}-base:latest
47+
docker build --platform linux/amd64 \
48+
-f runtimes/${{ matrix.runtime }}.Dockerfile \
49+
-t $IMAGE runtimes/
50+
docker push $IMAGE
51+
52+
# Build and publish kernels for each example
53+
publish-kernels:
54+
runs-on: ubuntu-latest
55+
permissions:
56+
contents: read
57+
packages: write
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
example:
62+
- name: helloworld-c
63+
kernel: helloworld-hyperlight_hyperlight-x86_64
64+
- name: hostfs-posix-c
65+
kernel: hostfs-posix-c-hyperlight_hyperlight-x86_64
66+
- name: hostfs-posix-py
67+
kernel: hostfs-posix-py-hyperlight_hyperlight-x86_64
68+
- name: python-agent
69+
kernel: python-agent-hyperlight_hyperlight-x86_64
70+
- name: rust
71+
kernel: rust-hyperlight_hyperlight-x86_64
72+
- name: go
73+
kernel: go-hyperlight_hyperlight-x86_64
74+
- name: shell
75+
kernel: shell-hyperlight_hyperlight-x86_64
76+
- name: python
77+
kernel: python-hyperlight_hyperlight-x86_64
78+
- name: nodejs
79+
kernel: nodejs-hyperlight_hyperlight-x86_64
80+
- name: dotnet
81+
kernel: dotnet-hyperlight_hyperlight-x86_64
82+
- name: dotnet-nativeaot
83+
kernel: dotnet-nativeaot-hyperlight_hyperlight-x86_64
84+
- name: powershell
85+
kernel: powershell-hyperlight_hyperlight-x86_64
86+
- name: python-agent-driver
87+
kernel: python-agent-driver-hyperlight_hyperlight-x86_64
88+
steps:
89+
- uses: actions/checkout@v4
90+
91+
- name: Install tools
92+
run: |
93+
# Install kraft-hyperlight
94+
git clone --branch hyperlight-platform --depth 1 https://github.com/danbugs/kraftkit.git /tmp/kraftkit
95+
cd /tmp/kraftkit && go build -o /usr/local/bin/kraft-hyperlight ./cmd/kraft
96+
# Install hyperlight-unikraft
97+
cd ${{ github.workspace }}/host && cargo build --release
98+
sudo cp target/release/hyperlight-unikraft /usr/local/bin/
99+
100+
- name: Build kernel
101+
working-directory: examples/${{ matrix.example.name }}
102+
run: |
103+
kraft-hyperlight --no-prompt build --plat hyperlight --arch x86_64 || true
104+
# Fallback: manual source clone + build
105+
if [ ! -f ".unikraft/build/${{ matrix.example.kernel }}" ]; then
106+
UK_BRANCH=$(grep 'version:' kraft.yaml | head -1 | awk '{print $2}')
107+
mkdir -p .unikraft/apps .unikraft/libs
108+
rm -rf .unikraft/unikraft .unikraft/apps/elfloader
109+
git clone --branch $UK_BRANCH --depth 1 https://github.com/danbugs/unikraft.git .unikraft/unikraft
110+
git clone --branch $UK_BRANCH --depth 1 https://github.com/danbugs/app-elfloader.git .unikraft/apps/elfloader
111+
git clone --branch staging --depth 1 https://github.com/unikraft/lib-libelf.git .unikraft/libs/libelf
112+
rm -rf .unikraft/build
113+
kraft-hyperlight --no-prompt build --plat hyperlight --arch x86_64
114+
fi
115+
116+
- name: Log in to GHCR
117+
uses: docker/login-action@v3
118+
with:
119+
registry: ${{ env.REGISTRY }}
120+
username: ${{ github.actor }}
121+
password: ${{ secrets.GITHUB_TOKEN }}
122+
123+
- name: Publish kernel image
124+
working-directory: examples
125+
run: |
126+
IMAGE=${{ env.IMAGE_BASE }}/${{ matrix.example.name }}-kernel:latest
127+
# Package just the kernel binary in a scratch image
128+
cat > /tmp/Dockerfile.kernel << DEOF
129+
FROM scratch
130+
COPY ${{ matrix.example.name }}/.unikraft/build/${{ matrix.example.kernel }} /kernel
131+
DEOF
132+
docker build -f /tmp/Dockerfile.kernel -t $IMAGE .
133+
docker push $IMAGE
134+
135+
# Publish the python-agent-driver rootfs CPIO as its own image so
136+
# `pyhl setup` can pull the initrd (and kernel, above) from GHCR
137+
# without having to build the driver image locally.
138+
publish-pyhl-initrd:
139+
runs-on: ubuntu-latest
140+
permissions:
141+
contents: read
142+
packages: write
143+
steps:
144+
- uses: actions/checkout@v4
145+
146+
- name: Log in to GHCR
147+
uses: docker/login-action@v3
148+
with:
149+
registry: ${{ env.REGISTRY }}
150+
username: ${{ github.actor }}
151+
password: ${{ secrets.GITHUB_TOKEN }}
152+
153+
# python-agent-driver's Dockerfile builds hl_pydriver against
154+
# local-python-base-dev so the glibc/libpython ABIs match the
155+
# runtime image. Materialise both locally before `just rootfs`.
156+
- name: Build local-python-base and local-python-base-dev
157+
env:
158+
DOCKER_BUILDKIT: '0'
159+
run: |
160+
# Full image with dev headers (compiles hl_pydriver.c)
161+
docker build --target base -t local-python-base-dev:latest \
162+
-f runtimes/python.Dockerfile runtimes/
163+
# Slim runtime image (ends up inside the guest rootfs)
164+
docker build -t local-python-base:latest \
165+
-f runtimes/python.Dockerfile runtimes/
166+
167+
- name: Install just
168+
uses: extractions/setup-just@v2
169+
170+
- name: Build python-agent-driver rootfs (CPIO)
171+
working-directory: examples/python-agent-driver
172+
env:
173+
DOCKER_BUILDKIT: '0'
174+
run: |
175+
just rootfs
176+
177+
- name: Publish initrd image
178+
working-directory: examples/python-agent-driver
179+
run: |
180+
IMAGE=${{ env.IMAGE_BASE }}/python-agent-driver-initrd:latest
181+
cat > /tmp/Dockerfile.initrd << DEOF
182+
FROM scratch
183+
COPY python-agent-driver-initrd.cpio /initrd.cpio
184+
DEOF
185+
docker build -f /tmp/Dockerfile.initrd -t $IMAGE .
186+
docker push $IMAGE

0 commit comments

Comments
 (0)