11name : Coroutines build
22
3+ # Tuwunel does not enable coroutines. Keep this available for explicit
4+ # compatibility checks without spending CI resources on every push.
35on :
4- push :
5- branches : [master]
6- pull_request :
6+ workflow_dispatch :
77
88concurrency :
99 group : ${{ github.workflow }}-${{ github.ref }}
1010 cancel-in-progress : true
1111
12+ permissions :
13+ contents : read
14+
1215env :
1316 CARGO_TERM_COLOR : always
1417
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 :
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
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
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