Skip to content

Commit 3d51b4b

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 3d51b4b

9 files changed

Lines changed: 259 additions & 589 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: 53 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,34 @@ 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:
104+
toolchain: stable
98105
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' }}
106+
cache-bin: false
107+
cache-on-failure: false
108+
cache-save-if: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }}
109+
cache-targets: false
101110

102111
# The folly build's correctness depends on three independent inputs:
103112
# 1. The folly commit (pinned by RocksDB's folly.mk:FOLLY_COMMIT_HASH).
104-
# 2. The exact container image (glibc + libstdc++ + apt package versions).
113+
# 2. The container release (glibc + libstdc++ + apt package versions).
105114
# 3. The CPU arch (x86_64 vs aarch64).
106-
# All three are encoded in the cache key. The `-v3` suffix lets us bump
115+
# All three are encoded in the cache key. The final suffix lets us bump
107116
# 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
117+
# invalidates prior caches.
118+
- name: Restore folly install
118119
id: cache-folly
119-
uses: actions/cache@v4
120+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
120121
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)
122+
# Cache only the installed artifacts needed by the cargo build. The
123+
# source checkout, downloads, and intermediate object trees are not
124+
# needed on a warm hit and can exceed the repository cache budget.
128125
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
126+
librocksdb-sys/folly-build/installed
127+
librocksdb-sys/folly-build/liburing-2.15
128+
librocksdb-sys/folly-build/liburing-prefix.txt
129+
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
132130

133131
- name: Build folly
134132
if: steps.cache-folly.outputs.cache-hit != 'true'
@@ -142,13 +140,17 @@ jobs:
142140
# system one here so RocksDB's io_uring code and libfolly.a agree
143141
# on the headers and the runtime library. The file is absent when
144142
# the system liburing was already good enough.
143+
append_env() {
144+
printf '%s\n' "$1" >> "$GITHUB_ENV"
145+
}
146+
145147
LIBURING_PREFIX_FILE="$PWD/librocksdb-sys/folly-build/liburing-prefix.txt"
146148
if [ -f "$LIBURING_PREFIX_FILE" ]; then
147149
LIBURING_PREFIX=$(cat "$LIBURING_PREFIX_FILE")
148150
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"
151+
append_env "PKG_CONFIG_PATH=$LIBURING_PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
152+
append_env "CPATH=$LIBURING_PREFIX/include${CPATH:+:$CPATH}"
153+
append_env "LIBRARY_PATH=$LIBURING_PREFIX/lib${LIBRARY_PATH:+:$LIBRARY_PATH}"
152154
fi
153155
154156
INSTALL_ROOT="$PWD/librocksdb-sys/folly-build/installed"
@@ -158,7 +160,7 @@ jobs:
158160
ls -la librocksdb-sys/folly-build/ || true
159161
exit 1
160162
fi
161-
echo "ROCKSDB_FOLLY_INSTALL_PATH=$INSTALL_ROOT" >> "$GITHUB_ENV"
163+
append_env "ROCKSDB_FOLLY_INSTALL_PATH=$INSTALL_ROOT"
162164
163165
# folly's getdeps produces libglog and libgflags as shared libs only
164166
# (no static archives). librocksdb-sys/build.rs links them dynamically.
@@ -188,9 +190,9 @@ jobs:
188190
if [ -n "${LIBURING_PREFIX:-}" ]; then
189191
RUNTIME_LIBDIRS="$RUNTIME_LIBDIRS:$LIBURING_PREFIX/lib"
190192
fi
191-
echo "LD_LIBRARY_PATH=$RUNTIME_LIBDIRS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV"
193+
append_env "LD_LIBRARY_PATH=$RUNTIME_LIBDIRS${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
192194
193-
- uses: taiki-e/install-action@nextest
195+
- uses: taiki-e/install-action@68250fb3d551d72befef105162372ebb3e8016e0 # nextest
194196

195197
- name: cargo build --features coroutines,io-uring
196198
run: cargo build --release --features coroutines,io-uring
@@ -200,3 +202,16 @@ jobs:
200202

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