ci(gitea): dynamically resolve LIBCLANG_PATH for act_runner container
CI / Build + Clippy + Test (push) Failing after 20m22s
CI / Security audit (RUSTSEC) (push) Failing after 1m31s

First real CI run on the Gitea Actions runner hit the predicted
LIBCLANG_PATH issue but for an unexpected reason: workflow-level
'env:' does not reliably propagate into act_runner's Docker executor
(bindgen received empty LIBCLANG_PATH despite /usr/lib/llvm-*/lib
being correct on the runner).

Two changes:

  1. Drop the hardcoded workflow-level 'env: LIBCLANG_PATH' and add a
     dedicated 'Resolve LIBCLANG_PATH' step that does:
         find /usr/lib -name 'libclang.so.*' | head -1 | xargs dirname
     and writes the result to $GITHUB_ENV. Dynamic discovery also
     future-proofs against Debian/Ubuntu version drift (llvm-14 today,
     llvm-18 tomorrow). The $GITHUB_ENV mechanism is reliably visible
     across step boundaries inside the act_runner Docker container,
     whereas workflow-level env: is not.

  2. apt install: drop '--no-install-recommends' on libclang-dev
     (Debian Bookworm's metapackage uses Recommends to pull in
     versioned toolchain bits bindgen needs). Also install 'clang'
     (not just llvm-14) to get version-agnostic libclang shared lib.

Comments inline in ci.yml document both decisions to prevent future
regression.

The 'Resolve LIBCLANG_PATH' step fails fast with a clear message if
libclang isn't installed, instead of letting the clippy/build steps
fail cryptically later.
This commit is contained in:
dailz
2026-06-28 16:58:04 +08:00
parent c772e4eb0b
commit 4e65f4175b
+22 -4
View File
@@ -25,8 +25,6 @@ on:
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
# Build dependencies match shell.nix + README Prerequisites section.
LIBCLANG_PATH: /usr/lib/llvm-14/lib
jobs: jobs:
build-test: build-test:
@@ -43,13 +41,33 @@ jobs:
- name: Install system dependencies - name: Install system dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y --no-install-recommends \ # NOTE: do NOT use --no-install-recommends for libclang-dev — on
# Debian Bookworm (the node:20-bookworm image used by act_runner
# under ubuntu-latest) the recommended toolchain bits are needed
# by bindgen. The pkg-config based deps (pipewire/wayland/etc)
# are also more reliable without the flag.
sudo apt-get install -y \
ffmpeg \ ffmpeg \
libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libva-dev \ libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libva-dev \
libwayland-dev wayland-protocols \ libwayland-dev wayland-protocols \
libdrm-dev \ libdrm-dev \
libpipewire-0.3-dev \ libpipewire-0.3-dev \
libclang-dev llvm-14 libclang-dev clang
- name: Resolve LIBCLANG_PATH
# bindgen needs libclang on the LD path. The actual install location
# varies by Debian/Ubuntu version (llvm-14, llvm-15, ...), so we
# discover it dynamically instead of hardcoding /usr/lib/llvm-14/lib.
# Writing to $GITHUB_ENV propagates the value to subsequent steps
# inside the act_runner Docker container; the workflow-level `env:`
# block is not reliably visible there.
run: |
set -e
LIBCL=$(find /usr/lib -name 'libclang.so.*' -type f 2>/dev/null | head -1)
test -n "$LIBCL" || { echo "ERROR: libclang.so.* not found under /usr/lib"; exit 1; }
LIBDIR=$(dirname "$LIBCL")
echo "Resolved LIBCLANG_PATH=$LIBDIR"
echo "LIBCLANG_PATH=$LIBDIR" >> "$GITHUB_ENV"
- name: Cache cargo registry + build artifacts - name: Cache cargo registry + build artifacts
uses: actions/cache@v4 uses: actions/cache@v4