Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(ci): Add SCCACHE_CACHE_KEY_PREFIX derived from Cargo.lock hash to Rust CI workflows (#62609)

mendral-app[bot]8712f3af1de3
diff --git a/.github/workflows/_rust-build-images.yml b/.github/workflows/_rust-build-images.yml
index b49dafebc3f6..5884e3430013 100644
--- a/.github/workflows/_rust-build-images.yml
+++ b/.github/workflows/_rust-build-images.yml
@@ -141,6 +141,7 @@ jobs:
echo "endpoint=$SCCACHE_WEBDAV_ENDPOINT" >> "$GITHUB_OUTPUT"
echo "::add-mask::$SCCACHE_WEBDAV_TOKEN"
echo "token=$SCCACHE_WEBDAV_TOKEN" >> "$GITHUB_OUTPUT"
+ echo "cache-key-prefix=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_OUTPUT"
- name: Build and push image
id: docker_build
@@ -159,6 +160,7 @@ jobs:
SCCACHE_NO_DAEMON=1
BIN=${{ matrix.bin || matrix.image }}
BUILD_FEATURES=${{ matrix.features || '' }}
+ SCCACHE_WEBDAV_KEY_PREFIX=${{ steps.sccache.outputs.cache-key-prefix }}
secrets: |
SCCACHE_WEBDAV_ENDPOINT=${{ steps.sccache.outputs.endpoint }}
SCCACHE_WEBDAV_TOKEN=${{ steps.sccache.outputs.token }}
diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml
index e4212f814cb2..f10b17b48fce 100644
--- a/.github/workflows/ci-rust.yml
+++ b/.github/workflows/ci-rust.yml
@@ -252,6 +252,9 @@ jobs:
with:
toolchain: 1.91.1
+ - name: Set sccache WebDAV key prefix (Cargo.lock hash)
+ run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"
+
- name: Install sccache
uses: ./.github/actions/setup-sccache
@@ -338,6 +341,9 @@ jobs:
- name: Install protoc
uses: ./.github/actions/setup-protoc
+ - name: Set sccache WebDAV key prefix (Cargo.lock hash)
+ run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"
+
- name: Install sccache
uses: ./.github/actions/setup-sccache
@@ -449,6 +455,9 @@ jobs:
toolchain: 1.91.1
components: clippy,rustfmt
+ - name: Set sccache WebDAV key prefix (Cargo.lock hash)
+ run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"
+
- name: Install sccache
uses: ./.github/actions/setup-sccache
diff --git a/rust/Dockerfile b/rust/Dockerfile
index 8c07cdd474a6..94c2c2567390 100644
--- a/rust/Dockerfile
+++ b/rust/Dockerfile
@@ -17,7 +17,8 @@ FROM base AS builder
WORKDIR /app
ARG BIN
ARG BUILD_FEATURES=""
-ENV PROTO_ROOT=../proto
+ARG SCCACHE_WEBDAV_KEY_PREFIX
+ENV PROTO_ROOT=../proto SCCACHE_WEBDAV_KEY_PREFIX=${SCCACHE_WEBDAV_KEY_PREFIX}
# Ensure working C compile setup (not installed by default in arm64 images)
# libclang-dev is required for bindgen (used by librocksdb-sys)