Skip to content

Commit c363126

Browse files
committed
Tailor CI for Tuwunel.
Run Tuwunel checks on trusted runners, remove schedules, and repair dependencies, caching, and workflow permissions. Signed-off-by: Jason Volk <jason@zemos.net>
1 parent 2fc3946 commit c363126

9 files changed

Lines changed: 269 additions & 599 deletions

File tree

.github/workflows/audit.yml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
11
name: Security Audit
22

3-
# Advisories land against dependency versions that are already pinned, so this
4-
# has to run on a timer as well as on change. The pull request trigger is what
5-
# used to be a second, separate audit job in rust.yml using a different action.
3+
# Audit the committed lockfile whenever a branch changes. Manual dispatch is
4+
# available when an advisory needs checking without a source change.
65
on:
76
push:
87
branches:
9-
- master
10-
pull_request:
11-
schedule:
12-
- cron: "0 2 * * *" # run at 2 AM UTC
8+
- "**"
139
workflow_dispatch:
1410

1511
permissions:
1612
contents: read
1713

1814
jobs:
1915
security-audit:
20-
# Branch protection requires this exact check name. Renaming it silently
21-
# blocks every pull request, because a required check that never reports
22-
# never passes.
2316
name: Security audit
24-
permissions:
25-
checks: write # for the action to create a check
26-
contents: read # for actions/checkout to fetch code
27-
issues: write # for the action to file advisories it finds
28-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-24.04
18+
timeout-minutes: 10
2919
steps:
30-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
21+
with:
22+
persist-credentials: false
3123

3224
- name: Install rust
33-
uses: actions-rust-lang/setup-rust-toolchain@v1
25+
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
3426
with:
27+
toolchain: stable
3528
cache: false
3629
rustflags: ""
3730

@@ -40,6 +33,6 @@ jobs:
4033
# version, so the audit would cover versions nobody builds and would miss
4134
# a vulnerable pin that is actually in the lockfile.
4235
- name: Audit check
43-
uses: actions-rust-lang/audit@v1
36+
uses: actions-rust-lang/audit@72c09e02f132669d52284a3323acdb503cfc1a24 # v1.2.7
4437
with:
45-
token: ${{ secrets.GITHUB_TOKEN }}
38+
createIssues: false

.github/workflows/coroutines.yml

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
name: Coroutines build
22

3+
# Tuwunel does not enable coroutines. Keep this available for explicit
4+
# compatibility checks without spending CI resources on every push.
35
on:
4-
push:
5-
branches: [master]
6-
pull_request:
6+
workflow_dispatch:
77

88
concurrency:
99
group: ${{ github.workflow }}-${{ github.ref }}
1010
cancel-in-progress: true
1111

12+
permissions:
13+
contents: read
14+
1215
env:
1316
CARGO_TERM_COLOR: always
1417

@@ -17,6 +20,7 @@ jobs:
1720
name: ${{ matrix.build }} (coroutines)
1821
strategy:
1922
fail-fast: false
23+
max-parallel: 2
2024
matrix:
2125
build: [Linux-x64, Linux-ARM]
2226
include:
@@ -25,7 +29,7 @@ jobs:
2529
- build: Linux-ARM
2630
os: ubuntu-24.04-arm
2731
# The host runner just hosts the container; the actual build happens
28-
# inside `ubuntu:25.10` (see `container:` below). We pin a specific host
32+
# inside `ubuntu:24.04` (see `container:` below). We pin a specific host
2933
# image rather than using `ubuntu-latest` so a GHA runner image rollover
3034
# doesn't silently change anything visible to the build. The container
3135
# image is multi-arch on Docker Hub, so the same `image:` works for
@@ -40,7 +44,7 @@ jobs:
4044
# for the cargo builds. The image still matters for the toolchain, and
4145
# the cache key below encodes it so changing this invalidates the folly
4246
# cache.
43-
image: ubuntu:25.10
47+
image: ubuntu:24.04
4448
# Folly's getdeps build can take 30-60+ minutes on a cold cache on
4549
# standard GHA runners (small core count, no parallelism flags). 90
4650
# minutes is a comfortable upper bound. With a warm cache the whole
@@ -58,8 +62,9 @@ jobs:
5862
ca-certificates curl git sudo
5963
6064
- name: Checkout sources
61-
uses: actions/checkout@v5
65+
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
6266
with:
67+
persist-credentials: false
6368
submodules: recursive
6469

6570
- name: Install build dependencies
@@ -72,17 +77,10 @@ jobs:
7277
zlib1g-dev libbz2-dev autoconf automake libtool \
7378
clang llvm
7479
75-
# Force gcc-14 instead of ubuntu:25.10's default gcc-15. folly's pinned
76-
# libunwind commit (f081cf4...) was written pre-C23 and uses legacy
77-
# K&R-style function declarations (`func()` meaning "unspecified
78-
# arguments"). gcc-15 defaults to `-std=gnu23` for C, where `func()`
79-
# means "no arguments", so calls like `func(s)` in libunwind's tests
80-
# become hard errors. gcc-14 still defaults to `-std=gnu17`, which
81-
# preserves the legacy semantic.
82-
#
83-
# gcc-14 and gcc-15 share the same libstdc++ ABI, so the subsequent
84-
# `cargo build` (which uses gcc-14 here too via cc/c++ alternatives)
85-
# links cleanly against folly's output.
80+
# Use gcc-14 instead of ubuntu:24.04's default gcc-13 so both
81+
# architectures build with the same explicit compiler version. gcc-14
82+
# also retains the pre-C23 behavior required by folly's pinned
83+
# libunwind commit.
8684
- name: Switch default compiler to gcc-14
8785
run: |
8886
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
@@ -93,42 +91,34 @@ jobs:
9391
g++ --version
9492
9593
- name: Install rust
96-
uses: actions-rust-lang/setup-rust-toolchain@v1
94+
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
9795
with:
96+
toolchain: stable
9897
cache-key: "v1-rust-coroutines"
99-
# Populate the cache from master runs only, not from PR runs.
100-
cache-save-if: ${{ github.ref == 'refs/heads/master' }}
98+
cache-bin: false
99+
cache-on-failure: false
100+
cache-save-if: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }}
101+
cache-targets: false
101102

102103
# The folly build's correctness depends on three independent inputs:
103104
# 1. The folly commit (pinned by RocksDB's folly.mk:FOLLY_COMMIT_HASH).
104-
# 2. The exact container image (glibc + libstdc++ + apt package versions).
105+
# 2. The container release (glibc + libstdc++ + apt package versions).
105106
# 3. The CPU arch (x86_64 vs aarch64).
106-
# All three are encoded in the cache key. The `-v3` suffix lets us bump
107+
# All three are encoded in the cache key. The final suffix lets us bump
107108
# the cache manually if the build script changes in a way that
108-
# invalidates prior caches (v2 was the previous ubuntu-24.04-host build).
109-
- name: Determine folly commit hash
110-
id: folly-hash
111-
run: |
112-
HASH=$(grep -E '^FOLLY_COMMIT_HASH = ' \
113-
librocksdb-sys/rocksdb/folly.mk \
114-
| sed -E 's/^FOLLY_COMMIT_HASH = //')
115-
echo "hash=$HASH" >> "$GITHUB_OUTPUT"
116-
117-
- name: Cache folly install
109+
# invalidates prior caches.
110+
- name: Restore folly install
118111
id: cache-folly
119-
uses: actions/cache@v4
112+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
120113
with:
121-
# `build_folly.sh` uses --scratch-path so install artifacts live
122-
# inside the workspace at a predictable location. Cache both that
123-
# and the folly source checkout so a warm hit avoids both the
124-
# clone and the build. Files written by the build:
125-
# librocksdb-sys/folly-build/installed/{folly,boost,...}-*/
126-
# librocksdb-sys/folly-build/{downloads,build,extracted,shipit}/
127-
# librocksdb-sys/rocksdb/third-party/folly/ (source + patches)
114+
# Cache only the installed artifacts needed by the cargo build. The
115+
# source checkout, downloads, and intermediate object trees are not
116+
# needed on a warm hit and can exceed the repository cache budget.
128117
path: |
129-
librocksdb-sys/folly-build
130-
librocksdb-sys/rocksdb/third-party/folly
131-
key: folly-${{ runner.os }}-${{ runner.arch }}-ubuntu-25.10-${{ steps.folly-hash.outputs.hash }}-v3
118+
librocksdb-sys/folly-build/installed
119+
librocksdb-sys/folly-build/liburing-2.15
120+
librocksdb-sys/folly-build/liburing-prefix.txt
121+
key: folly-${{ runner.arch }}-u24-${{ hashFiles('scripts/build_folly.sh', 'librocksdb-sys/rocksdb/folly.mk', 'librocksdb-sys/rocksdb/build_tools/getdeps_fallback_mirror.py') }}-v1
132122

133123
- name: Build folly
134124
if: steps.cache-folly.outputs.cache-hit != 'true'
@@ -142,13 +132,17 @@ jobs:
142132
# system one here so RocksDB's io_uring code and libfolly.a agree
143133
# on the headers and the runtime library. The file is absent when
144134
# the system liburing was already good enough.
135+
append_env() {
136+
printf '%s\n' "$1" >> "$GITHUB_ENV"
137+
}
138+
145139
LIBURING_PREFIX_FILE="$PWD/librocksdb-sys/folly-build/liburing-prefix.txt"
146140
if [ -f "$LIBURING_PREFIX_FILE" ]; then
147141
LIBURING_PREFIX=$(cat "$LIBURING_PREFIX_FILE")
148142
echo "Using liburing from $LIBURING_PREFIX"
149-
echo "PKG_CONFIG_PATH=$LIBURING_PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" >> "$GITHUB_ENV"
150-
echo "CPATH=$LIBURING_PREFIX/include${CPATH:+:$CPATH}" >> "$GITHUB_ENV"
151-
echo "LIBRARY_PATH=$LIBURING_PREFIX/lib${LIBRARY_PATH:+:$LIBRARY_PATH}" >> "$GITHUB_ENV"
143+
append_env "PKG_CONFIG_PATH=$LIBURING_PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
144+
append_env "CPATH=$LIBURING_PREFIX/include${CPATH:+:$CPATH}"
145+
append_env "LIBRARY_PATH=$LIBURING_PREFIX/lib${LIBRARY_PATH:+:$LIBRARY_PATH}"
152146
fi
153147
154148
INSTALL_ROOT="$PWD/librocksdb-sys/folly-build/installed"
@@ -158,7 +152,7 @@ jobs:
158152
ls -la librocksdb-sys/folly-build/ || true
159153
exit 1
160154
fi
161-
echo "ROCKSDB_FOLLY_INSTALL_PATH=$INSTALL_ROOT" >> "$GITHUB_ENV"
155+
append_env "ROCKSDB_FOLLY_INSTALL_PATH=$INSTALL_ROOT"
162156
163157
# folly's getdeps produces libglog and libgflags as shared libs only
164158
# (no static archives). librocksdb-sys/build.rs links them dynamically.
@@ -188,9 +182,9 @@ jobs:
188182
if [ -n "${LIBURING_PREFIX:-}" ]; then
189183
RUNTIME_LIBDIRS="$RUNTIME_LIBDIRS:$LIBURING_PREFIX/lib"
190184
fi
191-
echo "LD_LIBRARY_PATH=$RUNTIME_LIBDIRS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV"
185+
append_env "LD_LIBRARY_PATH=$RUNTIME_LIBDIRS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
192186
193-
- uses: taiki-e/install-action@nextest
187+
- uses: taiki-e/install-action@68250fb3d551d72befef105162372ebb3e8016e0 # nextest
194188

195189
- name: cargo build --features coroutines,io-uring
196190
run: cargo build --release --features coroutines,io-uring
@@ -200,3 +194,16 @@ jobs:
200194

201195
- name: Run doctests with coroutines feature
202196
run: cargo test --doc --release --features coroutines,io-uring
197+
198+
- name: Save folly install
199+
if: >-
200+
steps.cache-folly.outputs.cache-hit != 'true'
201+
&& github.event_name == 'push'
202+
&& github.ref_name == github.event.repository.default_branch
203+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
204+
with:
205+
path: |
206+
librocksdb-sys/folly-build/installed
207+
librocksdb-sys/folly-build/liburing-2.15
208+
librocksdb-sys/folly-build/liburing-prefix.txt
209+
key: folly-${{ runner.arch }}-u24-${{ hashFiles('scripts/build_folly.sh', 'librocksdb-sys/rocksdb/folly.mk', 'librocksdb-sys/rocksdb/build_tools/getdeps_fallback_mirror.py') }}-v1

0 commit comments

Comments
 (0)