feat: build script for libkrun #40
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: [ '**' ] | |
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 }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check if relevant files have changed | |
id: check_files | |
run: | | |
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'build_libkrun.sh' && echo "should_build=true" >> $GITHUB_OUTPUT || echo "should_build=false" >> $GITHUB_OUTPUT | |
build-libkrun: | |
needs: check-libkrun-changes | |
if: needs.check-libkrun-changes.outputs.should_build == '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 | |
- name: Cache libkrun | |
uses: actions/cache@v3 | |
with: | |
path: | | |
/usr/local/lib64/libkrunfw.so | |
/usr/local/lib64/libkrun.so | |
key: ${{ runner.os }}-libkrun-${{ github.sha }} | |
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@v3 | |
with: | |
path: | | |
/usr/local/lib64/libkrunfw.so | |
/usr/local/lib64/libkrun.so | |
key: ${{ runner.os }}-libkrun-${{ github.sha }} | |
- name: Check library dependencies | |
run: | | |
sudo ldd /usr/local/lib64/libkrun.so || true | |
sudo ldd /usr/local/lib/libkrun.so || true | |
- name: Verify Cache Contents | |
run: | | |
sudo ls -la /usr/local/lib64 | |
sudo ls -la /usr/local/lib | |
sudo file /usr/local/lib64/libkrun* | |
sudo file /usr/local/lib/libkrun* | |
- 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: cargo build --release | |
- name: Update library cache | |
run: sudo ldconfig | |
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@v3 | |
with: | |
path: | | |
/usr/local/lib64/libkrunfw.so | |
/usr/local/lib64/libkrun.so | |
key: ${{ runner.os }}-libkrun-${{ github.sha }} | |
- name: Check library dependencies | |
run: | | |
sudo ldd /usr/local/lib64/libkrun.so || true | |
sudo ldd /usr/local/lib/libkrun.so || true | |
- name: Verify Cache Contents | |
run: | | |
sudo ls -la /usr/local/lib64 | |
sudo ls -la /usr/local/lib | |
sudo file /usr/local/lib64/libkrun* | |
sudo file /usr/local/lib/libkrun* | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
toolchain: ${{ matrix.rust-toolchain }} | |
- name: Run Tests | |
run: | | |
ls -la /usr/local/lib64 | grep libkrun | |
cargo test --all-features | |
env: | |
LIBRARY_PATH: /usr/local/lib64:${{ env.LIBRARY_PATH }} | |
LD_LIBRARY_PATH: /usr/local/lib64:/usr/local/lib:${{ env.LD_LIBRARY_PATH }} | |
- name: Update library cache | |
run: sudo ldconfig |