Skip to content

Commit fc2d81f

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

9 files changed

Lines changed: 253 additions & 589 deletions

File tree

.github/workflows/audit.yml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
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:
3527
cache: false
3628
rustflags: ""
@@ -40,6 +32,6 @@ jobs:
4032
# version, so the audit would cover versions nobody builds and would miss
4133
# a vulnerable pin that is actually in the lockfile.
4234
- name: Audit check
43-
uses: actions-rust-lang/audit@v1
35+
uses: actions-rust-lang/audit@72c09e02f132669d52284a3323acdb503cfc1a24 # v1.2.7
4436
with:
45-
token: ${{ secrets.GITHUB_TOKEN }}
37+
createIssues: false

.github/workflows/coroutines.yml

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ name: Coroutines build
22

33
on:
44
push:
5-
branches: [master]
6-
pull_request:
5+
branches:
6+
- "**"
7+
workflow_dispatch:
78

89
concurrency:
910
group: ${{ github.workflow }}-${{ github.ref }}
1011
cancel-in-progress: true
1112

13+
permissions:
14+
contents: read
15+
1216
env:
1317
CARGO_TERM_COLOR: always
1418

@@ -17,6 +21,7 @@ jobs:
1721
name: ${{ matrix.build }} (coroutines)
1822
strategy:
1923
fail-fast: false
24+
max-parallel: 2
2025
matrix:
2126
build: [Linux-x64, Linux-ARM]
2227
include:
@@ -25,7 +30,7 @@ jobs:
2530
- build: Linux-ARM
2631
os: ubuntu-24.04-arm
2732
# The host runner just hosts the container; the actual build happens
28-
# inside `ubuntu:25.10` (see `container:` below). We pin a specific host
33+
# inside `ubuntu:26.04` (see `container:` below). We pin a specific host
2934
# image rather than using `ubuntu-latest` so a GHA runner image rollover
3035
# doesn't silently change anything visible to the build. The container
3136
# image is multi-arch on Docker Hub, so the same `image:` works for
@@ -40,7 +45,7 @@ jobs:
4045
# for the cargo builds. The image still matters for the toolchain, and
4146
# the cache key below encodes it so changing this invalidates the folly
4247
# cache.
43-
image: ubuntu:25.10
48+
image: ubuntu:26.04
4449
# Folly's getdeps build can take 30-60+ minutes on a cold cache on
4550
# standard GHA runners (small core count, no parallelism flags). 90
4651
# minutes is a comfortable upper bound. With a warm cache the whole
@@ -58,8 +63,9 @@ jobs:
5863
ca-certificates curl git sudo
5964
6065
- name: Checkout sources
61-
uses: actions/checkout@v5
66+
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
6267
with:
68+
persist-credentials: false
6369
submodules: recursive
6470

6571
- name: Install build dependencies
@@ -72,7 +78,7 @@ jobs:
7278
zlib1g-dev libbz2-dev autoconf automake libtool \
7379
clang llvm
7480
75-
# Force gcc-14 instead of ubuntu:25.10's default gcc-15. folly's pinned
81+
# Force gcc-14 instead of ubuntu:26.04's default gcc-15. folly's pinned
7682
# libunwind commit (f081cf4...) was written pre-C23 and uses legacy
7783
# K&R-style function declarations (`func()` meaning "unspecified
7884
# arguments"). gcc-15 defaults to `-std=gnu23` for C, where `func()`
@@ -93,42 +99,33 @@ jobs:
9399
g++ --version
94100
95101
- name: Install rust
96-
uses: actions-rust-lang/setup-rust-toolchain@v1
102+
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
97103
with:
98104
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' }}
105+
cache-bin: false
106+
cache-on-failure: false
107+
cache-save-if: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }}
108+
cache-targets: false
101109

102110
# The folly build's correctness depends on three independent inputs:
103111
# 1. The folly commit (pinned by RocksDB's folly.mk:FOLLY_COMMIT_HASH).
104-
# 2. The exact container image (glibc + libstdc++ + apt package versions).
112+
# 2. The container release (glibc + libstdc++ + apt package versions).
105113
# 3. The CPU arch (x86_64 vs aarch64).
106-
# All three are encoded in the cache key. The `-v3` suffix lets us bump
114+
# All three are encoded in the cache key. The final suffix lets us bump
107115
# 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
116+
# invalidates prior caches.
117+
- name: Restore folly install
118118
id: cache-folly
119-
uses: actions/cache@v4
119+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
120120
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)
121+
# Cache only the installed artifacts needed by the cargo build. The
122+
# source checkout, downloads, and intermediate object trees are not
123+
# needed on a warm hit and can exceed the repository cache budget.
128124
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
125+
librocksdb-sys/folly-build/installed
126+
librocksdb-sys/folly-build/liburing-2.15
127+
librocksdb-sys/folly-build/liburing-prefix.txt
128+
key: folly-${{ runner.arch }}-u26-${{ hashFiles('scripts/build_folly.sh', 'librocksdb-sys/rocksdb/folly.mk', 'librocksdb-sys/rocksdb/build_tools/getdeps_fallback_mirror.py') }}-v1
132129

133130
- name: Build folly
134131
if: steps.cache-folly.outputs.cache-hit != 'true'
@@ -142,13 +139,17 @@ jobs:
142139
# system one here so RocksDB's io_uring code and libfolly.a agree
143140
# on the headers and the runtime library. The file is absent when
144141
# the system liburing was already good enough.
142+
append_env() {
143+
printf '%s\n' "$1" >> "$GITHUB_ENV"
144+
}
145+
145146
LIBURING_PREFIX_FILE="$PWD/librocksdb-sys/folly-build/liburing-prefix.txt"
146147
if [ -f "$LIBURING_PREFIX_FILE" ]; then
147148
LIBURING_PREFIX=$(cat "$LIBURING_PREFIX_FILE")
148149
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"
150+
append_env "PKG_CONFIG_PATH=$LIBURING_PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
151+
append_env "CPATH=$LIBURING_PREFIX/include${CPATH:+:$CPATH}"
152+
append_env "LIBRARY_PATH=$LIBURING_PREFIX/lib${LIBRARY_PATH:+:$LIBRARY_PATH}"
152153
fi
153154
154155
INSTALL_ROOT="$PWD/librocksdb-sys/folly-build/installed"
@@ -158,7 +159,7 @@ jobs:
158159
ls -la librocksdb-sys/folly-build/ || true
159160
exit 1
160161
fi
161-
echo "ROCKSDB_FOLLY_INSTALL_PATH=$INSTALL_ROOT" >> "$GITHUB_ENV"
162+
append_env "ROCKSDB_FOLLY_INSTALL_PATH=$INSTALL_ROOT"
162163
163164
# folly's getdeps produces libglog and libgflags as shared libs only
164165
# (no static archives). librocksdb-sys/build.rs links them dynamically.
@@ -188,9 +189,9 @@ jobs:
188189
if [ -n "${LIBURING_PREFIX:-}" ]; then
189190
RUNTIME_LIBDIRS="$RUNTIME_LIBDIRS:$LIBURING_PREFIX/lib"
190191
fi
191-
echo "LD_LIBRARY_PATH=$RUNTIME_LIBDIRS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV"
192+
append_env "LD_LIBRARY_PATH=$RUNTIME_LIBDIRS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
192193
193-
- uses: taiki-e/install-action@nextest
194+
- uses: taiki-e/install-action@68250fb3d551d72befef105162372ebb3e8016e0 # nextest
194195

195196
- name: cargo build --features coroutines,io-uring
196197
run: cargo build --release --features coroutines,io-uring
@@ -200,3 +201,16 @@ jobs:
200201

201202
- name: Run doctests with coroutines feature
202203
run: cargo test --doc --release --features coroutines,io-uring
204+
205+
- name: Save folly install
206+
if: >-
207+
steps.cache-folly.outputs.cache-hit != 'true'
208+
&& github.event_name == 'push'
209+
&& github.ref_name == github.event.repository.default_branch
210+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
211+
with:
212+
path: |
213+
librocksdb-sys/folly-build/installed
214+
librocksdb-sys/folly-build/liburing-2.15
215+
librocksdb-sys/folly-build/liburing-prefix.txt
216+
key: folly-${{ runner.arch }}-u26-${{ 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)