Skip to content

CI

CI #1071

Workflow file for this run

name: CI
on:
pull_request:
merge_group:
env:
GH_TOKEN: ${{ github.token }}
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
defaults:
run:
shell: bash
jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Clippy
run: cargo xtask clippy
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Check Formatting
run: cargo fmt -- --check
run:
name: Run
strategy:
matrix:
target: [x86_64, aarch64, riscv64]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install QEMU (ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install qemu-system-x86 qemu-system-arm qemu-system-misc
- name: Install QEMU (macos)
if: matrix.os == 'macos-latest'
run: |
brew update
brew install qemu
- name: Install QEMU (windows)
if: matrix.os == 'windows-latest'
run: |
choco install qemu
echo "C:\Program Files\qemu" >> $GITHUB_PATH
- uses: actions/checkout@v4
with:
lfs: true
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Dowload OpenSBI
if: matrix.target == 'riscv64'
run: |
gh release download v1.5.1 --repo riscv-software-src/opensbi --pattern 'opensbi-*-rv-bin.tar.xz'
tar -xvf opensbi-*-rv-bin.tar.xz opensbi-1.5.1-rv-bin/share/opensbi/lp64/generic/firmware/fw_jump.bin
- name: Download OVMF (prebuilt)
run: |
gh release download edk2-stable202408-r1 --repo rust-osdev/ovmf-prebuilt --pattern 'edk2-stable*-bin.tar.xz'
tar -xvf edk2-stable*-bin.tar.xz edk2-stable202408-r1-bin/x64
if: matrix.os != 'ubuntu-latest'
- name: Download OVMF (ubuntu)
run: |
sudo apt-get update
sudo apt-get install ovmf
mkdir -p edk2-stable202408-r1-bin/x64
cp /usr/share/OVMF/OVMF_CODE.fd edk2-stable202408-r1-bin/x64/code.fd
cp /usr/share/OVMF/OVMF_VARS.fd edk2-stable202408-r1-bin/x64/vars.fd
if: matrix.os == 'ubuntu-latest'
- 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_world, uefi, dev)
run: cargo xtask ci qemu --target ${{ matrix.target }}-uefi
if: matrix.target == 'x86_64'
- name: Run VM (hello_world, uefi, release)
run: cargo xtask ci qemu --target ${{ matrix.target }}-uefi --release
if: matrix.target == 'x86_64'
- name: Run VM (hello_world-microvm, dev)
if: matrix.target == 'x86_64' && matrix.os == 'ubuntu-latest'
run: cargo xtask ci qemu --target ${{ matrix.target }} --microvm
- name: Run VM (hello_world-microvm, release)
if: matrix.target == 'x86_64' && matrix.os == 'ubuntu-latest'
run: cargo xtask ci qemu --target ${{ matrix.target }} --microvm --release
- name: Run VM (hello_c, dev)
if: matrix.target == '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: |
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: |
# 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
- name: Download OVMF
run: |
gh release download edk2-stable202408-r1 --repo rust-osdev/ovmf-prebuilt --pattern 'edk2-stable*-bin.tar.xz'
tar -xvf edk2-stable*-bin.tar.xz edk2-stable202408-r1-bin/x64
- 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 QEMU (hello_world-microvm, dev)
run: cargo xtask ci qemu --target x86_64 --accel --microvm
- name: Run QEMU (hello_world-microvm, release)
run: cargo xtask ci qemu --target x86_64 --accel --microvm --release
- name: Run UEFI (dev)
run: cargo xtask ci qemu --target x86_64-uefi --accel
- name: Run UEFI (release)
run: cargo xtask ci qemu --target x86_64-uefi --accel --release
- name: Run Firecracker (hello_world, dev)
run: cargo xtask ci firecracker --target x86_64-fc
- name: Run Firecracker (hello_world, release)
run: cargo xtask ci firecracker --target x86_64-fc --release