: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(ci): cache rust dependency builds in the nodejs and crate-publish jobs (#73307)
Robbie0216c09975fb
diff --git a/.github/workflows/ci-nodejs.yml b/.github/workflows/ci-nodejs.ymlindex 6971b021aa71..d7dc36e1de98 100644--- a/.github/workflows/ci-nodejs.yml+++ b/.github/workflows/ci-nodejs.yml@@ -140,6 +140,27 @@ jobs:with:install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfile+ - name: Install rust+ uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9+ with:+ toolchain: 1.91.1++ # for security reasons, external builds (forks) don't use the shared WebDAV cache+ - name: Set sccache WebDAV key prefix (Cargo.lock hash)+ if: env.RUNS_ON_INTERNAL_PR == 'true'+ run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"++ - name: Install sccache+ if: env.RUNS_ON_INTERNAL_PR == 'true'+ uses: ./.github/actions/setup-sccache++ - name: Cache Rust dependencies+ uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2+ with:+ shared-key: 'v2-rust-nodejs'+ workspaces: rust+ save-if: ${{ github.ref == 'refs/heads/master' }}+- name: Prepare Node.js workspacerun: bin/turbo --filter=@posthog/nodejs prepare@@ -175,6 +196,27 @@ jobs:with:install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfile+ - name: Install rust+ uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9+ with:+ toolchain: 1.91.1++ # for security reasons, external builds (forks) don't use the shared WebDAV cache+ - name: Set sccache WebDAV key prefix (Cargo.lock hash)+ if: env.RUNS_ON_INTERNAL_PR == 'true'+ run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"++ - name: Install sccache+ if: env.RUNS_ON_INTERNAL_PR == 'true'+ uses: ./.github/actions/setup-sccache++ - name: Cache Rust dependencies+ uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2+ with:+ shared-key: 'v2-rust-nodejs'+ workspaces: rust+ save-if: ${{ github.ref == 'refs/heads/master' }}+- name: Prepare Node.js workspacerun: bin/turbo --filter=@posthog/nodejs prepare@@ -266,6 +308,22 @@ jobs:with:toolchain: 1.91.1+ # for security reasons, external builds (forks) don't use the shared WebDAV cache+ - name: Set sccache WebDAV key prefix (Cargo.lock hash)+ if: env.RUNS_ON_INTERNAL_PR == 'true'+ run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"++ - name: Install sccache+ if: env.RUNS_ON_INTERNAL_PR == 'true'+ uses: ./.github/actions/setup-sccache++ - name: Cache Rust dependencies+ uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2+ with:+ shared-key: 'v2-rust-nodejs'+ workspaces: rust+ save-if: ${{ github.ref == 'refs/heads/master' }}+- name: Install sqlx-cliuses: ./.github/actions/setup-sqlx-cli@@ -358,6 +416,13 @@ jobs:# Create dedicated persons database for postgres-parity testscd nodejs && pnpm run setup:test:persons-parity+ # Build workspace deps (Rust addons + TS) up front so the Jest step times only tests, not the addon compile.+ - name: Prepare Node.js workspace+ env:+ SHARD_INDEX: ${{ matrix.shard }}+ SHARD_COUNT: 3+ run: bin/turbo --filter=@posthog/nodejs prepare+- name: Test with Jestid: run-jest# continue-on-error so the quarantine gate below is the verdict — it passes when@@ -510,6 +575,22 @@ jobs:with:toolchain: 1.91.1+ # for security reasons, external builds (forks) don't use the shared WebDAV cache+ - name: Set sccache WebDAV key prefix (Cargo.lock hash)+ if: env.RUNS_ON_INTERNAL_PR == 'true'+ run: echo "SCCACHE_WEBDAV_KEY_PREFIX=cargo-${{ hashFiles('rust/Cargo.lock') }}" >> "$GITHUB_ENV"++ - name: Install sccache+ if: env.RUNS_ON_INTERNAL_PR == 'true'+ uses: ./.github/actions/setup-sccache++ - name: Cache Rust dependencies+ uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2+ with:+ shared-key: 'v2-rust-nodejs'+ workspaces: rust+ save-if: ${{ github.ref == 'refs/heads/master' }}+- name: Install sqlx-cliuses: ./.github/actions/setup-sqlx-clidiff --git a/.github/workflows/publish-replay-anonymizer-crate.yml b/.github/workflows/publish-replay-anonymizer-crate.ymlindex aca13debefbd..0557ee7945d0 100644--- a/.github/workflows/publish-replay-anonymizer-crate.yml+++ b/.github/workflows/publish-replay-anonymizer-crate.yml@@ -80,6 +80,8 @@ jobs:publish:name: Publish to crates.io+ # Not on a Depot runner: this job holds CARGO_REGISTRY_TOKEN and Depot injects the shared+ # sccache WebDAV credentials ambiently, which a malicious dependency build script could read.runs-on: ubuntu-24.04timeout-minutes: 10if: github.event_name == 'push' && github.repository == 'PostHog/posthog'@@ -140,6 +142,17 @@ jobs:with:toolchain: 1.91.1+ # No sccache here: cargo publish runs dependency build scripts with CARGO_REGISTRY_TOKEN+ # present, so it must not read the fork-writable shared compiler cache. rust-cache is+ # GitHub's own cache (fork-isolated, master-write-only below), so it stays.+ - name: Cache Rust dependencies+ if: steps.version.outputs.publish-needed == 'true'+ uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2+ with:+ shared-key: 'v2-rust-nodejs'+ workspaces: rust+ save-if: ${{ github.ref == 'refs/heads/master' }}+- name: Authenticate with crates.ioif: steps.version.outputs.publish-needed == 'true'id: auth