-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add (refactor) workflow for building gvltctl and tesing VM builder
- Loading branch information
Showing
1 changed file
with
107 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,125 @@ | ||
name: Test Linux VM build | ||
name: Build and test | ||
|
||
# For now triggers only manually, because it takes a lot of time to run this (to build Linux kernel actually). | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
build-gvltctl: | ||
name: Build gvltctl | ||
|
||
# Matches test-vm-builder to avoid errors | ||
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
|
||
- name: Update APT packages | ||
run: |- | ||
sudo apt-get update | ||
- name: Install Buf | ||
uses: bufbuild/buf-setup-action@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install Protoc | ||
uses: arduino/setup-protoc@v3 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
default: true | ||
|
||
- name: Use Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build gvltctl | ||
run: |- | ||
cargo build --features vm-builder-v2 | ||
cp target/debug/gvltctl . | ||
- name: Upload build artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: gvltctl-exe | ||
path: gvltctl | ||
retention-days: 1 | ||
if-no-files-found: error | ||
overwrite: true | ||
|
||
test-vm-builder: | ||
name: Test VM builder | ||
|
||
needs: [build-gvltctl] | ||
|
||
# It's important to run on Ubuntu 24, not Ubuntu 22, because | ||
# fuse2fs is required to be >=1.47 and Ubuntu 22 only has 1.46. | ||
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Podman | ||
- name: Download gvltctl | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: gvltctl-exe | ||
path: tests/vm_builder/simple_vm | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Update APT packages | ||
run: |- | ||
sudo apt-get update | ||
sudo apt-get install -y podman | ||
- name: Build gvltctl debug container (with vm-builder-v2) | ||
- name: Install gvltctl runtime dependencies | ||
run: |- | ||
podman build -t gvltctl:latest -f containers/Containerfile.debug-test-vm-builder-v2 . | ||
sudo apt-get install -y ca-certificates | ||
- name: Run Linux VM builder | ||
# We are using pre-compiled kernel in tests, so we don't need Linux kernel build dependencies. | ||
- name: Install VM builder runtime dependencies | ||
run: |- | ||
podman run --privileged --rm \ | ||
-e RUST_LOG=trace \ | ||
-v ${{ github.workspace }}/tests/vm_builder/simple_vm:/mnt/simple_vm \ | ||
-w /mnt/simple_vm \ | ||
gvltctl:latest build --fuse -f Containerfile --no-gevulot-runtime | ||
sudo apt-get install -y podman e2fsprogs fuse2fs | ||
- name: Check disk.img | ||
- name: Install QEMU | ||
run: |- | ||
sudo apt-get install -y qemu-system-x86 | ||
- name: Build test VM image | ||
working-directory: tests/vm_builder/simple_vm | ||
env: | ||
RUST_LOG: trace | ||
run: |- | ||
chmod +x ./gvltctl | ||
./gvltctl build \ | ||
--fuse \ | ||
--containerfile Containerfile \ | ||
--kernel-file bin/bzImage \ | ||
--no-gevulot-runtime | ||
- name: Check disk.img file | ||
working-directory: tests/vm_builder/simple_vm | ||
run: |- | ||
file disk.img | ||
- name: Run test VM | ||
working-directory: tests/vm_builder/simple_vm | ||
run: |- | ||
OUTPUT=$(qemu-system-x86_64 -machine q35 -nographic --hda disk.img) | ||
echo "$OUTPUT" | ||
RES=$(echo "$OUTPUT" | grep "Hello, world!") | ||
if [[ $RES = "" ]]; then | ||
echo "FAILED" | ||
exit 1; | ||
else | ||
echo "OK" | ||
fi |