Skip to content

Commit 0ea3df7

Browse files
authored
chore: Merge CI changes from neqo (#47)
1 parent 71eeddf commit 0ea3df7

2 files changed

Lines changed: 42 additions & 8 deletions

File tree

.github/actions/check-vm/action.yml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ inputs:
1111
codecov-token:
1212
description: "Codecov token, if Codecov upload is desired."
1313
default: ""
14+
bindgen-args:
15+
description: "bindgen arguments for generating BSD bindings. Non-empty enables binding generation."
16+
default: ""
1417

1518
runs:
1619
using: composite
@@ -21,19 +24,19 @@ runs:
2124
WD: ${{ inputs.working-directory }}
2225
PLATFORM: ${{ inputs.platform }}
2326
WORKSPACE: ${{ inputs.working-directory == '.' && '--workspace' || '' }}
27+
BINDGEN_ARGS: ${{ inputs.bindgen-args }}
2428
run: |
2529
cat <<EOF > prepare.sh
2630
# This executes as root
2731
set -ex
2832
pwd
2933
case "$PLATFORM" in
30-
freebsd) pkg update -f && pkg install -y curl llvm nss pkgconf
34+
freebsd) pkg update -f && pkg install -y curl llvm nss pkgconf rust-bindgen-cli
3135
;;
3236
openbsd) # TODO: Is there a way to not pin the version of llvm? -z to pkg_add does not work.
33-
pkg_add rust rust-clippy rust-rustfmt llvm-21.1.2p0 nss # rustup does not support OpenBSD at all
34-
;;
35-
netbsd) /usr/sbin/pkg_add pkgin && pkgin -y update && pkgin -y install curl clang nss pkgconf
37+
pkg_add rust rust-clippy rust-rustfmt rust-bindgen llvm-21.1.2p0 nss # rustup does not support OpenBSD at all
3638
;;
39+
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 ;;
3740
solaris) pkg refresh && pkg install clang-libs nss pkg-config
3841
;;
3942
*) echo "Unsupported OS: $PLATFORM"
@@ -56,6 +59,7 @@ runs:
5659
openbsd) export LIBCLANG_PATH=/usr/local/llvm21/lib
5760
export LLVM_COV=/usr/local/llvm21/bin/llvm-cov
5861
export LLVM_PROFDATA=/usr/local/llvm21/bin/llvm-profdata
62+
export PATH="\$HOME/.cargo/bin:\$PATH"
5963
;;
6064
*) sh rustup.sh --default-toolchain stable --profile minimal --component clippy,llvm-tools,rustfmt -y
6165
. "\$HOME/.cargo/env"
@@ -73,6 +77,22 @@ runs:
7377
*) [ "$WORKSPACE" ] && EXCLUDE="--exclude fuzz" # Fuzzing not supported on this platform
7478
;;
7579
esac
80+
# Embed at script-generation time; single quotes protect | from shell interpretation.
81+
BINDGEN_ARGS='$BINDGEN_ARGS'
82+
# Generate bindings first if requested (before build, so we can bootstrap)
83+
if [ -n "$BINDGEN_ARGS" ]; then
84+
# Solaris doesn't have a system package for bindgen
85+
[ "$PLATFORM" = "solaris" ] && cargo install bindgen-cli --locked
86+
echo "$BINDGEN_ARGS" | xargs bindgen src/bindings/bsd.h > "$PLATFORM.rs"
87+
# Compare generated bindings with committed bindings.
88+
# If different, exit early — there's no point compiling with stale
89+
# bindings. The check-bindings job will detect the drift and handle it.
90+
if ! diff -q "src/bindings/$PLATFORM.rs" "$PLATFORM.rs" > /dev/null 2>&1; then
91+
echo "::warning::Bindings for $PLATFORM differ from committed version"
92+
exit 0
93+
fi
94+
fi
95+
7696
cargo version
7797
cargo check --locked --all-targets $WORKSPACE \${EXCLUDE:-}
7898
case "$PLATFORM" in
@@ -103,38 +123,42 @@ runs:
103123
echo "envs=CARGO_TERM_COLOR RUST_BACKTRACE RUST_LOG RUST_TEST_TIME_UNIT RUST_TEST_TIME_INTEGRATION RUST_TEST_TIME_DOCTEST WD" >> "$GITHUB_OUTPUT"
104124
105125
- if: ${{ inputs.platform == 'freebsd' }}
106-
uses: vmactions/freebsd-vm@7ca82f79fe3078fecded6d3a2bff094995447bbd # v1.4.4
126+
uses: vmactions/freebsd-vm@d1e65811565151536c0c894fff74f06351ed26e6 # v1.4.5
107127
with:
108128
usesh: true
109129
disable-cache: true
130+
copyback: true
110131
envs: ${{ steps.prep.outputs.envs }}
111132
prepare: ${{ steps.prep.outputs.prepare }}
112133
run: ${{ steps.prep.outputs.run }}
113134

114135
- if: ${{ inputs.platform == 'openbsd' }}
115-
uses: vmactions/openbsd-vm@9004791062e748d95cc87e499e77485f91888ce1 # v1.3.8
136+
uses: vmactions/openbsd-vm@d7d892b7b9ba97ed2747b0fc201be65037d64c3e # v1.4.0
116137
with:
117138
usesh: true
118139
disable-cache: true
140+
copyback: true
119141
envs: ${{ steps.prep.outputs.envs }}
120142
prepare: ${{ steps.prep.outputs.prepare }}
121143
run: ${{ steps.prep.outputs.run }}
122144

123145
- if: ${{ inputs.platform == 'netbsd' }}
124-
uses: vmactions/netbsd-vm@ca7ff0556959998c82761c34ea0c3c99fa084c48 # v1.3.7
146+
uses: vmactions/netbsd-vm@eb3ba840926911ccf17dc9de235335cb27a02ba0 # v1.3.8
125147
with:
126148
usesh: true
127149
disable-cache: true
150+
copyback: true
128151
envs: ${{ steps.prep.outputs.envs }}
129152
prepare: ${{ steps.prep.outputs.prepare }}
130153
run: ${{ steps.prep.outputs.run }}
131154

132155
- if: ${{ inputs.platform == 'solaris' }}
133-
uses: vmactions/solaris-vm@0a231b94365d1911cf62097ef342f6b30d95598f # v1.3.2
156+
uses: vmactions/solaris-vm@c20562b2c69737b06be9e828915761703e487373 # v1.3.3
134157
with:
135158
release: "11.4-gcc"
136159
usesh: true
137160
disable-cache: true
161+
copyback: true
138162
envs: ${{ steps.prep.outputs.envs }}
139163
prepare: ${{ steps.prep.outputs.prepare }}
140164
run: ${{ steps.prep.outputs.run }}
@@ -154,3 +178,10 @@ runs:
154178
token: ${{ inputs.codecov-token }}
155179
verbose: true
156180
flags: ${{ inputs.platform }}
181+
182+
- if: ${{ always() && inputs.bindgen-args != '' }}
183+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
184+
with:
185+
name: bindings-${{ inputs.platform }}
186+
path: ${{ inputs.working-directory }}/${{ inputs.platform }}.rs
187+
if-no-files-found: error

.github/workflows/actionlint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Lint GitHub Actions workflows
22
on:
3+
push:
4+
branches: ["main"]
5+
paths: [".github/**"]
36
pull_request:
47
paths: [".github/**"]
58
merge_group:

0 commit comments

Comments
 (0)