Skip to content

Commit 8712f3a

Browse files
mendral-app[bot]gantoineCopilot
authored
fix(ci): Add SCCACHE_CACHE_KEY_PREFIX derived from Cargo.lock hash to Rust CI workflows (#62609)
Co-authored-by: mendral-app[bot] <233154221+mendral-app[bot]@users.noreply.github.com> Co-authored-by: Georges-Antoine Assi <3247106+gantoine@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent d72cdc4 commit 8712f3a

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/_rust-build-images.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ jobs:
141141
echo "endpoint=$SCCACHE_WEBDAV_ENDPOINT" >> "$GITHUB_OUTPUT"
142142
echo "::add-mask::$SCCACHE_WEBDAV_TOKEN"
143143
echo "token=$SCCACHE_WEBDAV_TOKEN" >> "$GITHUB_OUTPUT"
144+
echo "cache-key-prefix=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_OUTPUT"
144145
145146
- name: Build and push image
146147
id: docker_build
@@ -159,6 +160,7 @@ jobs:
159160
SCCACHE_NO_DAEMON=1
160161
BIN=${{ matrix.bin || matrix.image }}
161162
BUILD_FEATURES=${{ matrix.features || '' }}
163+
SCCACHE_WEBDAV_KEY_PREFIX=${{ steps.sccache.outputs.cache-key-prefix }}
162164
secrets: |
163165
SCCACHE_WEBDAV_ENDPOINT=${{ steps.sccache.outputs.endpoint }}
164166
SCCACHE_WEBDAV_TOKEN=${{ steps.sccache.outputs.token }}

.github/workflows/ci-rust.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ jobs:
252252
with:
253253
toolchain: 1.91.1
254254

255+
- name: Set sccache WebDAV key prefix (Cargo.lock hash)
256+
run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"
257+
255258
- name: Install sccache
256259
uses: ./.github/actions/setup-sccache
257260

@@ -338,6 +341,9 @@ jobs:
338341
- name: Install protoc
339342
uses: ./.github/actions/setup-protoc
340343

344+
- name: Set sccache WebDAV key prefix (Cargo.lock hash)
345+
run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"
346+
341347
- name: Install sccache
342348
uses: ./.github/actions/setup-sccache
343349

@@ -449,6 +455,9 @@ jobs:
449455
toolchain: 1.91.1
450456
components: clippy,rustfmt
451457

458+
- name: Set sccache WebDAV key prefix (Cargo.lock hash)
459+
run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"
460+
452461
- name: Install sccache
453462
uses: ./.github/actions/setup-sccache
454463

rust/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ FROM base AS builder
1717
WORKDIR /app
1818
ARG BIN
1919
ARG BUILD_FEATURES=""
20-
ENV PROTO_ROOT=../proto
20+
ARG SCCACHE_WEBDAV_KEY_PREFIX
21+
ENV PROTO_ROOT=../proto SCCACHE_WEBDAV_KEY_PREFIX=${SCCACHE_WEBDAV_KEY_PREFIX}
2122

2223
# Ensure working C compile setup (not installed by default in arm64 images)
2324
# libclang-dev is required for bindgen (used by librocksdb-sys)

0 commit comments

Comments
 (0)