Skip to content

Commit f4653df

Browse files
committed
CI/code-quality: Check gui_vm/gtk_display example
Verify that the the executable gui_vm (and its dependency gtk_display) examples can compile without warnings using `cargo clippy`. This requires a newer version of GTK than we have in the CI, to solve build the required GTK version from source and cache the built GTK libraries in Github cache. Signed-off-by: Matej Hrica <[email protected]>
1 parent 68365f4 commit f4653df

File tree

1 file changed

+108
-3
lines changed

1 file changed

+108
-3
lines changed

.github/workflows/code-quality.yml

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on: [pull_request]
33

44
jobs:
55
code-quality-linux-x86_64:
6-
name: Linux x86_64
6+
name: libkrun (Linux x86_64)
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
@@ -27,7 +27,7 @@ jobs:
2727
run: cargo clippy --locked --features net,blk,gpu,snd -- -D warnings
2828

2929
code-quality-linux-aarch64:
30-
name: Linux aarch64
30+
name: libkrun (Linux aarch64)
3131
runs-on: ubuntu-24.04-arm
3232
steps:
3333
- uses: actions/checkout@v4
@@ -45,7 +45,7 @@ jobs:
4545
run: cargo clippy --locked --features net,blk,gpu,snd -- -D warnings
4646

4747
code-quality-macos:
48-
name: macOS aarch64
48+
name: libkrun (macOS aarch64)
4949
runs-on: macos-latest
5050
steps:
5151
- uses: actions/checkout@v4
@@ -58,3 +58,108 @@ jobs:
5858

5959
- name: Clippy (efi+gpu)
6060
run: cargo clippy --locked --features efi,gpu -- -D warnings
61+
62+
code-quality-examples:
63+
name: ${{ matrix.name }}
64+
strategy:
65+
matrix:
66+
include:
67+
- name: "Examples (Linux x86_64)"
68+
runner: ubuntu-latest
69+
70+
- name: "Examples (Linux aarch64)"
71+
runner: ubuntu-24.04-arm
72+
runs-on: ${{ matrix.runner }}
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Setup build environment
77+
uses: ./.github/actions/setup-build-env
78+
79+
- name: Cache GLib 2.82 + GTK 4.16 build
80+
uses: actions/cache@v4
81+
id: gtk-cache
82+
with:
83+
path: ~/gtk-prefix
84+
key: ${{ runner.os }}-${{ runner.arch }}-gtk-4.16.0
85+
86+
- name: Install GTK system dependencies
87+
run: |
88+
sudo apt-get update
89+
sudo apt-get install -yqq --no-install-recommends \
90+
libffi-dev \
91+
libmount-dev \
92+
libpcre2-dev \
93+
zlib1g-dev \
94+
libcairo2-dev \
95+
libpango1.0-dev \
96+
libgdk-pixbuf-2.0-dev \
97+
libgraphene-1.0-dev \
98+
libepoxy-dev \
99+
libxkbcommon-dev \
100+
wayland-protocols \
101+
libwayland-dev
102+
103+
- name: Add GLib + GTK paths to environment
104+
run: |
105+
case "$(uname -m)" in
106+
x86_64)
107+
GTK_PKG_CONFIG_PATH="$HOME/gtk-prefix/lib/x86_64-linux-gnu/pkgconfig"
108+
GTK_LIB_PATH="$HOME/gtk-prefix/lib/x86_64-linux-gnu" ;;
109+
aarch64)
110+
GTK_PKG_CONFIG_PATH="$HOME/gtk-prefix/lib/aarch64-linux-gnu/pkgconfig"
111+
GTK_LIB_PATH="$HOME/gtk-prefix/lib/aarch64-linux-gnu" ;;
112+
*)
113+
echo "ERROR: Unsupported architecture: $(uname -m)"
114+
exit 1 ;;
115+
esac
116+
117+
echo "PKG_CONFIG_PATH=$GTK_PKG_CONFIG_PATH:$PKG_CONFIG_PATH" >> $GITHUB_ENV
118+
echo "LD_LIBRARY_PATH=$GTK_LIB_PATH:$LD_LIBRARY_PATH" >> $GITHUB_ENV
119+
120+
- name: Build and install GTK 4.16 from source
121+
if: steps.gtk-cache.outputs.cache-hit != 'true'
122+
run: |
123+
# Install build-only dependencies
124+
sudo apt-get install -yqq --no-install-recommends \
125+
build-essential \
126+
meson \
127+
ninja-build
128+
129+
130+
# Build GLib first
131+
cd /tmp
132+
curl -L -o glib-2.82.2.tar.xz https://download.gnome.org/sources/glib/2.82/glib-2.82.2.tar.xz
133+
tar -xf glib-2.82.2.tar.xz
134+
cd glib-2.82.2
135+
meson setup builddir --prefix=$HOME/gtk-prefix --buildtype=release
136+
meson compile -C builddir
137+
meson install -C builddir
138+
139+
# Build GTK
140+
cd /tmp
141+
curl -L -o gtk-4.16.0.tar.xz https://download.gnome.org/sources/gtk/4.16/gtk-4.16.0.tar.xz
142+
tar -xf gtk-4.16.0.tar.xz
143+
cd gtk-4.16.0
144+
meson setup builddir --prefix=$HOME/gtk-prefix --buildtype=release \
145+
-Dmedia-gstreamer=disabled \
146+
-Dintrospection=disabled \
147+
-Dx11-backend=false \
148+
-Dprint-cups=disabled \
149+
-Dcloudproviders=disabled \
150+
-Dtracker=disabled \
151+
-Dcolord=disabled \
152+
-Dsysprof=disabled \
153+
-Dvulkan=disabled
154+
meson compile -C builddir
155+
meson install -C builddir
156+
157+
- name: Build and install libkrun to local prefix
158+
run: |
159+
mkdir -p $HOME/libkrun-prefix
160+
GPU=1 NET=1 INPUT=1 PREFIX=$HOME/libkrun-prefix make && PREFIX=$HOME/libkrun-prefix make install
161+
162+
- name: Clippy (examples workspace)
163+
run: |
164+
cd examples
165+
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

0 commit comments

Comments
 (0)