From 0a48652cc58e5487362fc7405d22a54e2d0ad527 Mon Sep 17 00:00:00 2001 From: Nikolas Wipper Date: Wed, 6 May 2026 14:36:06 -0400 Subject: [PATCH] chore: Merge CI changes from neqo --- .github/actions/check-vm/action.yml | 47 ++++++++++++++++++++++++----- .github/workflows/actionlint.yml | 3 ++ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.github/actions/check-vm/action.yml b/.github/actions/check-vm/action.yml index 009f8d6..935e13f 100644 --- a/.github/actions/check-vm/action.yml +++ b/.github/actions/check-vm/action.yml @@ -11,6 +11,9 @@ inputs: codecov-token: description: "Codecov token, if Codecov upload is desired." default: "" + bindgen-args: + description: "bindgen arguments for generating BSD bindings. Non-empty enables binding generation." + default: "" runs: using: composite @@ -21,19 +24,19 @@ runs: WD: ${{ inputs.working-directory }} PLATFORM: ${{ inputs.platform }} WORKSPACE: ${{ inputs.working-directory == '.' && '--workspace' || '' }} + BINDGEN_ARGS: ${{ inputs.bindgen-args }} run: | cat < prepare.sh # This executes as root set -ex pwd case "$PLATFORM" in - freebsd) pkg update -f && pkg install -y curl llvm nss pkgconf + freebsd) pkg update -f && pkg install -y curl llvm nss pkgconf rust-bindgen-cli ;; openbsd) # TODO: Is there a way to not pin the version of llvm? -z to pkg_add does not work. - pkg_add rust rust-clippy rust-rustfmt llvm-21.1.2p0 nss # rustup does not support OpenBSD at all - ;; - netbsd) /usr/sbin/pkg_add pkgin && pkgin -y update && pkgin -y install curl clang nss pkgconf + pkg_add rust rust-clippy rust-rustfmt rust-bindgen llvm-21.1.2p0 nss # rustup does not support OpenBSD at all ;; + netbsd) /usr/sbin/pkg_add pkgin && /usr/pkg/bin/pkgin -y update && /usr/pkg/bin/pkgin -y install curl clang nss pkgconf rust-bindgen cmake ninja ;; solaris) pkg refresh && pkg install clang-libs nss pkg-config ;; *) echo "Unsupported OS: $PLATFORM" @@ -56,6 +59,7 @@ runs: openbsd) export LIBCLANG_PATH=/usr/local/llvm21/lib export LLVM_COV=/usr/local/llvm21/bin/llvm-cov export LLVM_PROFDATA=/usr/local/llvm21/bin/llvm-profdata + export PATH="\$HOME/.cargo/bin:\$PATH" ;; *) sh rustup.sh --default-toolchain stable --profile minimal --component clippy,llvm-tools,rustfmt -y . "\$HOME/.cargo/env" @@ -73,6 +77,22 @@ runs: *) [ "$WORKSPACE" ] && EXCLUDE="--exclude fuzz" # Fuzzing not supported on this platform ;; esac + # Embed at script-generation time; single quotes protect | from shell interpretation. + BINDGEN_ARGS='$BINDGEN_ARGS' + # Generate bindings first if requested (before build, so we can bootstrap) + if [ -n "$BINDGEN_ARGS" ]; then + # Solaris doesn't have a system package for bindgen + [ "$PLATFORM" = "solaris" ] && cargo install bindgen-cli --locked + echo "$BINDGEN_ARGS" | xargs bindgen src/bindings/bsd.h > "$PLATFORM.rs" + # Compare generated bindings with committed bindings. + # If different, exit early — there's no point compiling with stale + # bindings. The check-bindings job will detect the drift and handle it. + if ! diff -q "src/bindings/$PLATFORM.rs" "$PLATFORM.rs" > /dev/null 2>&1; then + echo "::warning::Bindings for $PLATFORM differ from committed version" + exit 0 + fi + fi + cargo version cargo check --locked --all-targets $WORKSPACE \${EXCLUDE:-} case "$PLATFORM" in @@ -103,38 +123,42 @@ runs: echo "envs=CARGO_TERM_COLOR RUST_BACKTRACE RUST_LOG RUST_TEST_TIME_UNIT RUST_TEST_TIME_INTEGRATION RUST_TEST_TIME_DOCTEST WD" >> "$GITHUB_OUTPUT" - if: ${{ inputs.platform == 'freebsd' }} - uses: vmactions/freebsd-vm@7ca82f79fe3078fecded6d3a2bff094995447bbd # v1.4.4 + uses: vmactions/freebsd-vm@d1e65811565151536c0c894fff74f06351ed26e6 # v1.4.5 with: usesh: true disable-cache: true + copyback: true envs: ${{ steps.prep.outputs.envs }} prepare: ${{ steps.prep.outputs.prepare }} run: ${{ steps.prep.outputs.run }} - if: ${{ inputs.platform == 'openbsd' }} - uses: vmactions/openbsd-vm@9004791062e748d95cc87e499e77485f91888ce1 # v1.3.8 + uses: vmactions/openbsd-vm@d7d892b7b9ba97ed2747b0fc201be65037d64c3e # v1.4.0 with: usesh: true disable-cache: true + copyback: true envs: ${{ steps.prep.outputs.envs }} prepare: ${{ steps.prep.outputs.prepare }} run: ${{ steps.prep.outputs.run }} - if: ${{ inputs.platform == 'netbsd' }} - uses: vmactions/netbsd-vm@ca7ff0556959998c82761c34ea0c3c99fa084c48 # v1.3.7 + uses: vmactions/netbsd-vm@eb3ba840926911ccf17dc9de235335cb27a02ba0 # v1.3.8 with: usesh: true disable-cache: true + copyback: true envs: ${{ steps.prep.outputs.envs }} prepare: ${{ steps.prep.outputs.prepare }} run: ${{ steps.prep.outputs.run }} - if: ${{ inputs.platform == 'solaris' }} - uses: vmactions/solaris-vm@0a231b94365d1911cf62097ef342f6b30d95598f # v1.3.2 + uses: vmactions/solaris-vm@c20562b2c69737b06be9e828915761703e487373 # v1.3.3 with: release: "11.4-gcc" usesh: true disable-cache: true + copyback: true envs: ${{ steps.prep.outputs.envs }} prepare: ${{ steps.prep.outputs.prepare }} run: ${{ steps.prep.outputs.run }} @@ -154,3 +178,10 @@ runs: token: ${{ inputs.codecov-token }} verbose: true flags: ${{ inputs.platform }} + + - if: ${{ always() && inputs.bindgen-args != '' }} + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: bindings-${{ inputs.platform }} + path: ${{ inputs.working-directory }}/${{ inputs.platform }}.rs + if-no-files-found: error diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml index c958c0a..a22d598 100644 --- a/.github/workflows/actionlint.yml +++ b/.github/workflows/actionlint.yml @@ -1,5 +1,8 @@ name: Lint GitHub Actions workflows on: + push: + branches: ["main"] + paths: [".github/**"] pull_request: paths: [".github/**"] merge_group: