feat: add basic vm implementation #65
Workflow file for this run
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
name: 🧪 Tests and Checks | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ '**' ] | |
workflow_dispatch: | |
inputs: | |
force_build_libkrun: | |
description: 'Force build libkrun' | |
required: false | |
type: boolean | |
default: false | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
check-libkrun-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
should_build: ${{ steps.check_files.outputs.should_build }} | |
libkrun_hash: ${{ steps.hash_libkrun.outputs.hash }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Check if relevant files have changed | |
id: check_files | |
run: | | |
if [ $(git rev-list --count HEAD) -lt 2 ]; then | |
echo "Only one commit in the repository, building libkrun" | |
echo "should_build=true" >> $GITHUB_OUTPUT | |
else | |
git diff --name-only HEAD^ HEAD | grep -q 'build_libkrun.sh' && echo "should_build=true" >> $GITHUB_OUTPUT || echo "should_build=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Hash build_libkrun.sh | |
id: hash_libkrun | |
run: | | |
HASH=$(sha256sum build_libkrun.sh | awk '{ print $1 }') | |
echo "hash=$HASH" >> $GITHUB_OUTPUT | |
echo "Calculated hash: $HASH" | |
build-libkrun: | |
needs: check-libkrun-changes | |
if: needs.check-libkrun-changes.outputs.should_build == 'true' || github.event.inputs.force_build_libkrun == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update -qqy | |
sudo apt-get install -y jq libelf-dev build-essential flex bison libssl-dev libncurses5-dev python3-pip | |
pip3 install --user pyelftools | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Build libkrun | |
run: | | |
./build_libkrun.sh --no-cleanup --force-build | |
# A hack to make `ld` find the libkrunfw because right now it seems to only look for libkrunfw.so.x | |
# and not libkrunfw.so or libkrunfw.so.x.x.x even though their SONAME is libkrunfw.so.x | |
- name: Create symlinks | |
run: | | |
cd ${{ github.workspace }}/build/libkrunfw | |
objdump -p libkrunfw.so.4 | grep SONAME # sanity check | |
objdump -p libkrunfw.so.4.4.2 | grep SONAME # sanity check | |
ln -sf libkrunfw.so.4.4.2 libkrunfw.so.4 | |
ln -sf libkrunfw.so.4 libkrunfw.so | |
- name: Cache libkrun | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
build/libkrunfw/libkrunfw*.so* | |
build/libkrun/target/release/libkrun*.so* | |
key: ${{ runner.os }}-libkrun-${{ needs.check-libkrun-changes.outputs.libkrun_hash }} | |
run-checks: | |
needs: [check-libkrun-changes, build-libkrun] | |
if: always() | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
rust-toolchain: | |
- stable | |
- nightly | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Cache Project | |
uses: Swatinem/rust-cache@v2 | |
- name: Restore libkrun cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
build/libkrunfw/libkrunfw*.so* | |
build/libkrun/target/release/libkrun*.so* | |
key: ${{ runner.os }}-libkrun-${{ needs.check-libkrun-changes.outputs.libkrun_hash }} | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
components: rustfmt, clippy | |
toolchain: ${{ matrix.rust-toolchain }} | |
- name: Check Format | |
uses: actions-rs/cargo@v1 | |
with: | |
args: --all -- --check | |
command: fmt | |
toolchain: ${{ matrix.rust-toolchain }} | |
- name: Run Linter | |
uses: actions-rs/cargo@v1 | |
with: | |
args: --all -- -D warnings | |
command: clippy | |
toolchain: ${{ matrix.rust-toolchain }} | |
- name: Check Advisories | |
if: ${{ matrix.rust-toolchain == 'stable' }} | |
uses: EmbarkStudios/cargo-deny-action@v2 | |
with: | |
command: check advisories | |
continue-on-error: true | |
- name: Check Bans, Licenses, and Sources | |
if: ${{ matrix.rust-toolchain == 'stable' }} | |
uses: EmbarkStudios/cargo-deny-action@v2 | |
with: | |
command: check bans licenses sources | |
- name: Test Release | |
if: ${{ matrix.rust-toolchain == 'stable' && github.event_name == 'push' }} | |
run: | | |
LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release:${{ env.LIBRARY_PATH }} \ | |
LD_LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release:${{ env.LD_LIBRARY_PATH }} \ | |
cargo build --release | |
run-tests: | |
needs: [check-libkrun-changes, build-libkrun] | |
if: always() | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
rust-toolchain: | |
- stable | |
- nightly | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install Environment Packages | |
run: | | |
sudo apt-get update -qqy | |
sudo apt-get install jq | |
- name: Cache Project | |
uses: Swatinem/rust-cache@v2 | |
- name: Restore libkrun cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
build/libkrunfw/libkrunfw*.so* | |
build/libkrun/target/release/libkrun*.so* | |
key: ${{ runner.os }}-libkrun-${{ needs.check-libkrun-changes.outputs.libkrun_hash }} | |
- name: Print Cache | |
run: tree -L 2 build/ | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
toolchain: ${{ matrix.rust-toolchain }} | |
- name: Run Tests | |
run: | | |
LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release:${{ env.LIBRARY_PATH }} \ | |
LD_LIBRARY_PATH=${{ github.workspace }}/build/libkrunfw:${{ github.workspace }}/build/libkrun/target/release:${{ env.LD_LIBRARY_PATH }} \ | |
cargo test --all-features |