From 4e65f4175bb94c744b10fb2306b0c3d8bfacc07b Mon Sep 17 00:00:00 2001 From: dailz Date: Sun, 28 Jun 2026 16:58:04 +0800 Subject: [PATCH] ci(gitea): dynamically resolve LIBCLANG_PATH for act_runner container 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. --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c624a68..85c6f36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,8 +25,6 @@ on: env: CARGO_TERM_COLOR: always - # Build dependencies match shell.nix + README Prerequisites section. - LIBCLANG_PATH: /usr/lib/llvm-14/lib jobs: build-test: @@ -43,13 +41,33 @@ jobs: - name: Install system dependencies run: | 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 \ libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libva-dev \ libwayland-dev wayland-protocols \ libdrm-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 uses: actions/cache@v4