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/krunkit && brew install virglrenderer 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
165 changes: 165 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: Code Quality
on: [pull_request]

jobs:
code-quality-linux-x86_64:
name: libkrun (Linux x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Create a fake init
run: touch init/init

- name: Clippy (default)
run: cargo clippy --locked -- -D warnings

- name: Clippy (amd-sev)
run: cargo clippy --locked --features amd-sev -- -D warnings

- name: Clippy (tdx)
run: cargo clippy --locked --features tdx -- -D warnings

- name: Clippy (net+blk+gpu+snd)
run: cargo clippy --locked --features net,blk,gpu,snd -- -D warnings

code-quality-linux-aarch64:
name: libkrun (Linux aarch64)
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4

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

- name: Create a fake init
run: touch init/init

- name: Clippy (default)
run: cargo clippy --locked -- -D warnings

- name: Clippy (net+blk+gpu+snd)
run: cargo clippy --locked --features net,blk,gpu,snd -- -D warnings

code-quality-macos:
name: libkrun (macOS aarch64)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

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

- name: Create a fake init
run: touch init/init

- name: Clippy (efi+gpu)
run: cargo clippy --locked --features efi,gpu -- -D warnings

code-quality-examples:
name: ${{ matrix.name }}
strategy:
matrix:
include:
- name: "Examples (Linux x86_64)"
runner: ubuntu-latest

- name: "Examples (Linux aarch64)"
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4

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

- name: Cache GLib 2.82 + GTK 4.16 build

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the motivation behind building GTK manually?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I just saw that in the commit message but wouldn't using a fedora container be enough?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, gtk would build glib automatically if the required version is not installed. So you can drop the glib build part

Copy link
Collaborator Author

@mtjhrc mtjhrc Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I realized maybe I should have done that. But then we would have to maintain both list of build libraries for Fedora and for Ubuntu in the CI (not sure if we can get KVM in a container). Anyways I'm hoping we can just drop this once Ubuntu 26.04 LTS is released.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, gtk would build glib automatically if the required version is not installed. So you can drop the glib build part

This would only work if you pull from git though but i guess what you have is good enough. When it comes to build deps, installing libgtk4-dev should pull all the needed deps i guess

uses: actions/cache@v4
id: gtk-cache
with:
path: ~/gtk-prefix
key: ${{ runner.os }}-${{ runner.arch }}-gtk-4.16.0

- name: Install GTK system dependencies
run: |
sudo apt-get update
sudo apt-get install -yqq --no-install-recommends \
libffi-dev \
libmount-dev \
libpcre2-dev \
zlib1g-dev \
libcairo2-dev \
libpango1.0-dev \
libgdk-pixbuf-2.0-dev \
libgraphene-1.0-dev \
libepoxy-dev \
libxkbcommon-dev \
wayland-protocols \
libwayland-dev

- name: Add GLib + GTK paths to environment
run: |
case "$(uname -m)" in
x86_64)
GTK_PKG_CONFIG_PATH="$HOME/gtk-prefix/lib/x86_64-linux-gnu/pkgconfig"
GTK_LIB_PATH="$HOME/gtk-prefix/lib/x86_64-linux-gnu" ;;
aarch64)
GTK_PKG_CONFIG_PATH="$HOME/gtk-prefix/lib/aarch64-linux-gnu/pkgconfig"
GTK_LIB_PATH="$HOME/gtk-prefix/lib/aarch64-linux-gnu" ;;
*)
echo "ERROR: Unsupported architecture: $(uname -m)"
exit 1 ;;
esac

echo "PKG_CONFIG_PATH=$GTK_PKG_CONFIG_PATH:$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$GTK_LIB_PATH:$LD_LIBRARY_PATH" >> $GITHUB_ENV

- name: Build and install GTK 4.16 from source
if: steps.gtk-cache.outputs.cache-hit != 'true'
run: |
# Install build-only dependencies
sudo apt-get install -yqq --no-install-recommends \
build-essential \
meson \
ninja-build


# Build GLib first
cd /tmp
curl -L -o glib-2.82.2.tar.xz https://download.gnome.org/sources/glib/2.82/glib-2.82.2.tar.xz
tar -xf glib-2.82.2.tar.xz
cd glib-2.82.2
meson setup builddir --prefix=$HOME/gtk-prefix --buildtype=release
meson compile -C builddir
meson install -C builddir

# Build GTK
cd /tmp
curl -L -o gtk-4.16.0.tar.xz https://download.gnome.org/sources/gtk/4.16/gtk-4.16.0.tar.xz
tar -xf gtk-4.16.0.tar.xz
cd gtk-4.16.0
meson setup builddir --prefix=$HOME/gtk-prefix --buildtype=release \
-Dmedia-gstreamer=disabled \
-Dintrospection=disabled \
-Dx11-backend=false \
-Dprint-cups=disabled \
-Dcloudproviders=disabled \
-Dtracker=disabled \
-Dcolord=disabled \
-Dsysprof=disabled \
-Dvulkan=disabled
meson compile -C builddir
meson install -C builddir

- name: Build and install libkrun to local prefix
run: |
mkdir -p $HOME/libkrun-prefix
GPU=1 NET=1 INPUT=1 PREFIX=$HOME/libkrun-prefix make && PREFIX=$HOME/libkrun-prefix make install

- name: Clippy (examples workspace)
run: |
cd examples
PKG_CONFIG_PATH="$HOME/libkrun-prefix/lib64/pkgconfig:$PKG_CONFIG_PATH" LD_LIBRARY_PATH="$HOME/libkrun-prefix/lib64:$LD_LIBRARY_PATH" cargo clippy --locked -- -D warnings
35 changes: 0 additions & 35 deletions .github/workflows/code_quality-aarch64-darwin.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/code_quality-aarch64.yml

This file was deleted.

98 changes: 0 additions & 98 deletions .github/workflows/code_quality-x86_64.yml

This file was deleted.

Loading