Skip to content

Commit

Permalink
Merge pull request #294 from hermit-os/xtask-ci
Browse files Browse the repository at this point in the history
feat(xtask): add ci subcommand
  • Loading branch information
mkroening authored Feb 8, 2024
2 parents 9d6adc7 + 6b9ef15 commit 3cecbef
Show file tree
Hide file tree
Showing 18 changed files with 981 additions and 256 deletions.
126 changes: 48 additions & 78 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
pull_request:
merge_group:

env:
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings

defaults:
run:
shell: bash
Expand All @@ -24,8 +28,6 @@ jobs:
components: clippy
- name: Clippy
run: cargo xtask clippy
env:
RUSTFLAGS: -Dwarnings

fmt:
name: Format
Expand All @@ -43,7 +45,7 @@ jobs:
name: Run
strategy:
matrix:
target: [x86_64, x86_64-uefi, x86_64-fc, aarch64, riscv64]
target: [x86_64, aarch64, riscv64]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -55,13 +57,12 @@ jobs:
- name: Install QEMU, NASM (macos)
if: matrix.os == 'macos-latest'
run: |
# enable once it works again
# brew update
brew update
brew install qemu nasm
- name: Install QEMU, NASM (windows)
if: matrix.os == 'windows-latest'
run: |
choco install qemu --version=2023.5.31 --checksum64=20d26b460ec045b2cad4bdc4af59713db3110ab95dd73821a590571e4fc1ce1b972e9647867c16e061d1f7381de362ac9c9bfc027f47cdcce8a186818b595ffb
choco install qemu
echo "C:\Program Files\qemu" >> $GITHUB_PATH
choco install nasm
echo "C:\Program Files\NASM" >> $GITHUB_PATH
Expand All @@ -70,79 +71,48 @@ jobs:
lfs: true
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo xtask build --target ${{ matrix.target }}
- name: Run loader (x86_64)
- name: Run VM (hello_world, dev)
run: cargo xtask ci qemu --target ${{ matrix.target }}
- name: Run VM (hello_world, release)
run: cargo xtask ci qemu --target ${{ matrix.target }} --release
- name: Run VM (hello_c, dev)
if: matrix.target == 'x86_64'
run: |
qemu-system-x86_64 \
-cpu qemu64,apic,fsgsbase,fxsr,rdrand,rdtscp,xsave,xsaveopt \
-smp 1 -m 64M \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-display none -serial stdio \
-kernel target/x86_64/debug/hermit-loader \
-initrd data/x86_64/hello_world
qemu-system-x86_64 \
-cpu qemu64,apic,fsgsbase,fxsr,rdrand,rdtscp,xsave,xsaveopt \
-smp 1 -m 64M \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-display none -serial stdio \
-kernel target/x86_64/debug/hermit-loader \
-initrd data/x86_64/hello_c
- name: Run loader (aarch64)
if: matrix.target == 'aarch64'
run: |
qemu-system-aarch64 \
-machine virt,gic-version=3 -cpu cortex-a72 -smp 1 -m 512M \
-display none -serial stdio -semihosting \
-kernel target/aarch64/debug/hermit-loader \
-device guest-loader,addr=0x48000000,initrd=data/aarch64/hello_world
- name: Run loader (riscv64)
if: matrix.target == 'riscv64'
run: |
qemu-system-riscv64 \
-machine virt \
-cpu rv64 \
-smp 1 \
-m 32M \
-display none -serial stdio \
-kernel target/riscv64/debug/hermit-loader \
-initrd data/riscv64/hello_world
- name: Build (release)
run: cargo xtask build --target ${{ matrix.target }} --release
- name: Run loader (release, x86_64)
run: cargo xtask ci qemu --target ${{ matrix.target }} --image hello_c
- name: Run VM (hello_c, release)
if: matrix.target == 'x86_64'
run: cargo xtask ci qemu --target ${{ matrix.target }} --image hello_c --release

run-kvm:
name: Run (KVM)
runs-on: [self-hosted]
steps:
- name: Install QEMU
run: |
qemu-system-x86_64 \
-cpu qemu64,apic,fsgsbase,fxsr,rdrand,rdtscp,xsave,xsaveopt \
-smp 1 -m 64M \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-display none -serial stdio \
-kernel target/x86_64/release/hermit-loader \
-initrd data/x86_64/hello_world
qemu-system-x86_64 \
-cpu qemu64,apic,fsgsbase,fxsr,rdrand,rdtscp,xsave,xsaveopt \
-smp 1 -m 64M \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-display none -serial stdio \
-kernel target/x86_64/release/hermit-loader \
-initrd data/x86_64/hello_c
- name: Run loader (release, aarch64)
if: matrix.target == 'aarch64'
run: |
qemu-system-aarch64 \
-machine virt,gic-version=3 -cpu cortex-a72 -smp 1 -m 512M \
-display none -serial stdio -semihosting \
-kernel target/aarch64/release/hermit-loader \
-device guest-loader,addr=0x48000000,initrd=data/aarch64/hello_world
- name: Run loader (release, riscv64)
if: matrix.target == 'riscv64'
sudo apt-get update
sudo apt-get install -y --no-install-recommends qemu-system-x86
- uses: actions/checkout@v4
with:
lfs: true
- name: Install firecracker
run: |
qemu-system-riscv64 \
-machine virt \
-cpu rv64 \
-smp 1 \
-m 32M \
-display none -serial stdio \
-kernel target/riscv64/release/hermit-loader \
-initrd data/riscv64/hello_world
# https://github.com/firecracker-microvm/firecracker/blob/v1.5.1/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
./firecracker --version
- uses: dtolnay/rust-toolchain@stable
- name: Run QEMU (hello_world, dev)
run: cargo xtask ci qemu --target x86_64 --accel
- name: Run QEMU (hello_world, release)
run: cargo xtask ci qemu --target x86_64 --accel --release
- name: Run Firecracker (hello_world, dev)
run: cargo xtask ci firecracker --target x86_64-fc --features fc
- name: Run Firecracker (hello_world, release)
run: cargo xtask ci firecracker --target x86_64-fc --features fc --release
Loading

0 comments on commit 3cecbef

Please sign in to comment.