CI: bring back tags #10
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: CI | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
pull_request: | |
merge_group: | |
jobs: | |
test: | |
name: Test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Test | |
run: | | |
cargo test --lib | |
cargo test --bins --examples | |
cargo test --doc | |
run_images: | |
name: Run images | |
runs-on: [self-hosted] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- run: git lfs checkout | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- run: cargo build --locked | |
- name: Run images | |
timeout-minutes: 1 | |
run: | | |
cargo run -- -v data/x86_64/hello_world | |
cargo run -- -v data/x86_64/rusty_demo | |
cargo run -- -v data/x86_64/hello_c | |
fmt: | |
name: Format | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# TODO: Remove this, once https://github.com/rust-lang/rustfmt/issues/4991 is resolved | |
- uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: rustfmt | |
- name: Format | |
run: cargo fmt --all -- --check | |
- name: Install rustfmt for Test Kernels | |
run: rustup component add rustfmt | |
working-directory: tests/test-kernels | |
- name: Format Test Kernels | |
run: cargo fmt --all -- --check | |
working-directory: tests/test-kernels | |
clippy: | |
name: Clippy | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
include: | |
- os: ubuntu-latest | |
targets: x86_64-unknown-linux-gnu | |
flags: --target x86_64-unknown-linux-gnu | |
- os: macos-latest | |
targets: x86_64-apple-darwin, aarch64-apple-darwin | |
flags: --target x86_64-apple-darwin --target aarch64-apple-darwin | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.targets }} | |
components: clippy | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Clippy | |
run: cargo clippy --all-targets ${{ matrix.flags }} -- -D warnings | |
clippy-test-kernel: | |
name: Clippy test-kernels | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Install clippy for Test Kernels | |
run: rustup component add clippy | |
working-directory: tests/test-kernels | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- name: Clippy Test Kernels | |
run: cargo clippy --all-targets -- -D warnings | |
working-directory: tests/test-kernels | |
env: | |
# TODO: Remove once we have a hermit toolchain upgrade | |
# capable of sparse registries | |
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git | |
coverage: | |
name: Coverage | |
runs-on: [self-hosted] | |
steps: | |
- name: Install gdb | |
run: | | |
sudo apt-get update | |
sudo apt-get install gdb | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Install cargo-llvm-cov | |
run: curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.ref == 'refs/heads/main' }} || startsWith(github.ref, 'refs/tags') | |
- name: Generate code coverage | |
run: cargo llvm-cov --lcov --output-path lcov.info | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
disable_safe_directory: true | |
files: lcov.info | |
token: ${{ secrets.CODECOV_TOKEN }} | |
release: | |
if: startsWith(github.ref, 'refs/tags/') | |
name: Create new release | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
asset_name: "uhyve-${{ github.ref_name }}-linux-amd64" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build | |
run: cargo build --release --locked | |
- name: Upload binaries to new release | |
id: release | |
# v2.9.0, pinned to the corresponding commit hash for hardening reasons | |
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: target/release/uhyve | |
asset_name: ${{ matrix.asset_name }} | |
tag: ${{ github.ref }} | |
release_name: "Uhyve ${{ github.ref_name }}" | |
draft: true | |
overwrite: true |