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
47 changes: 39 additions & 8 deletions .github/actions/check-vm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,19 +24,19 @@ runs:
WD: ${{ inputs.working-directory }}
PLATFORM: ${{ inputs.platform }}
WORKSPACE: ${{ inputs.working-directory == '.' && '--workspace' || '' }}
BINDGEN_ARGS: ${{ inputs.bindgen-args }}
run: |
cat <<EOF > 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 ;;
Comment thread
Not-Nik marked this conversation as resolved.
Comment thread
Not-Nik marked this conversation as resolved.
solaris) pkg refresh && pkg install clang-libs nss pkg-config
;;
*) echo "Unsupported OS: $PLATFORM"
Expand All @@ -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"
Expand All @@ -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"
Comment thread
Not-Nik marked this conversation as resolved.
# 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
Comment thread
Not-Nik marked this conversation as resolved.
fi

cargo version
cargo check --locked --all-targets $WORKSPACE \${EXCLUDE:-}
case "$PLATFORM" in
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Comment thread
Not-Nik marked this conversation as resolved.
3 changes: 3 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Lint GitHub Actions workflows
on:
push:
branches: ["main"]
paths: [".github/**"]
pull_request:
paths: [".github/**"]
merge_group:
Expand Down
Loading