Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/actions/setup-build-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Setup Build Environment'
description: 'Common setup for Rust builds with all required packages (Linux & macOS)'
runs:
using: 'composite'
steps:
- name: Install Rust toolchain
shell: bash
run: |
rustup update stable
rustup default stable
rustup component add rustfmt clippy

- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Set up Homebrew (macOS)
if: runner.os == 'macOS'
uses: Homebrew/actions/setup-homebrew@master

- name: Install packages (macOS)
if: runner.os == 'macOS'
shell: bash
run: brew tap slp/krun && brew install asciidoctor libkrun clang-format llvm

- name: Install packages (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y \
libvirglrenderer-dev \
libepoxy-dev \
libdrm-dev \
libpipewire-0.3-dev \
clang-format \
libclang-dev
51 changes: 12 additions & 39 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,15 @@
name: Code Quality (rustfmt and clippy)
on: [pull_request, create]
name: Code Quality
on: [pull_request]

jobs:
build:
if: github.event_name == 'pull_request'
name: Code Quality (clippy, rustfmt)
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
target:
- x86_64-unknown-linux-gnu
code-quality-macos:
name: krunvm (macOS aarch64)
runs-on: macos-latest
steps:
- name: Code checkout
uses: actions/checkout@v2
- name: Install Rust toolchain (${{ matrix.rust }})
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
components: rustfmt, clippy

- name: Install asciidoctor
run: sudo apt-get install -y asciidoctor

- name: Install additional Rust rust targets
run: rustup target add aarch64-unknown-linux-gnu aarch64-apple-darwin

- name: Formatting (rustfmt)
run: cargo fmt -- --check

- name: Clippy x86_64-unknown-linux-gnu (all features)
run: cargo clippy --all-features --target x86_64-unknown-linux-gnu

- name: Clippy aarch64-unknown-linux-gnu (all features)
run: cargo clippy --all-features --target aarch64-unknown-linux-gnu

- name: Clippy aarch64-apple-darwin (all features)
run: cargo clippy --all-features --target aarch64-apple-darwin
- uses: actions/checkout@v4

- name: Setup build environment
uses: ./.github/actions/setup-build-env

- name: Clippy
run: cargo clippy --locked -- -D warnings
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "krunvm"
version = "0.2.4"
version = "0.2.5"
authors = ["Sergio Lopez <slp@redhat.com>"]
description = "Create microVMs from OCI images"
repository = "https://github.com/containers/krunvm"
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn generate_man_page<P: AsRef<Path>>(outdir: P, command: &str) -> io::Result<()>
.wait()?;
if !result.success() {
let msg = format!("'asciidoctor' failed with exit code {:?}", result.code());
return Err(io::Error::new(io::ErrorKind::Other, msg));
return Err(io::Error::other(msg));
}
Ok(())
}
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ fn get_brew_prefix() -> Option<String> {

#[cfg(target_os = "macos")]
fn reexec() -> Result<(), Error> {
let exec_path = env::current_exe().map_err(|_| ErrorKind::NotFound)?;
let exec_cstr = CString::new(exec_path.to_str().ok_or(ErrorKind::InvalidFilename)?)?;

let args: Vec<CString> = env::args_os()
.map(|arg| CString::new(arg.into_vec()).unwrap())
.collect();
Expand All @@ -212,7 +215,7 @@ fn reexec() -> Result<(), Error> {

// Use execve to replace the current process. This function only returns
// if an error occurs.
match execve(&args[0], &args, &envs) {
match execve(&exec_cstr, &args, &envs) {
Ok(_) => Ok(()),
Err(e) => {
eprintln!("Error re-executing krunvm: {}", e);
Expand Down