: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
perf(ci): drop pnpm install from product test shards (#94192)
Raúl Negrón-Otero04f8267fe011
diff --git a/.depot/actions/pnpm-install/action.yml b/.depot/actions/pnpm-install/action.ymlindex 74ce13213980..6bbe80e2d044 100644--- a/.depot/actions/pnpm-install/action.yml+++ b/.depot/actions/pnpm-install/action.yml@@ -5,16 +5,13 @@# not collide.name: Install pnpm dependenciesdescription: |- Sets up pnpm + Node, restores the shared pnpm store cache, installs, and- saves the cache only on the default branch.+ Sets up pnpm + Node via `setup-pnpm`, restores the shared pnpm store cache,+ installs, and saves the cache only on the default branch.Single source of truth for the pnpm cache key. Every node workflow sharesone namespace (`pnpm-<os>-<lockfile-hash>`), so the store is cached onceinstead of fragmenting across runner-arch casings or per-workflow keys.- Also pre-seeds the Node tool cache (`node-toolcache-<os>-<arch>-<version>`,- master-gated save) so setup-node makes no GitHub API calls on a hit.-Deliberately does NOT use setup-node's `cache: pnpm`: that auto-saves onevery run (PRs included, and the post-save can't be gated) and keys on`os.arch()` (lowercase `x64`), which never matches a hand-written@@ -37,68 +34,20 @@ inputs:runs:using: compositesteps:- - name: Install pnpm- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8- env:- # Kept in sync with .github/actions/pnpm-install: npm's audit blocks the pnpm- # bootstrap and gates nothing.- NPM_CONFIG_AUDIT: 'false'- NPM_CONFIG_FUND: 'false'-- - name: Fix node-gyp permissions- shell: bash- # Depot CI's restored pnpm store can land node-gyp's gyp_main.py without +x.- # Locate it across pnpm/action-setup layouts and never fail if it is absent.- run: find ~/setup-pnpm -name gyp_main.py -path '*/node-gyp/*' -exec chmod +x {} + 2>/dev/null || true-- - name: Resolve Node version- id: node-version- shell: bash- # An empty version (missing file or non-exact pin) skips the tool cache- # steps, so setup-node falls back to resolving the version itself. Only- # exact x.y.z pins are cacheable: the tool-cache directory is named after- # the resolved version, so a range spec would never match it.- env:- NODE_VERSION_FILE: ${{ inputs.node-version-file }}- run: |- version=""- [[ -f "$NODE_VERSION_FILE" ]] && version=$(tr -d 'v[:space:]' < "$NODE_VERSION_FILE")- [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || version=""- echo "version=$version" >> "$GITHUB_OUTPUT"-- # A tool-cache hit turns setup-node into a filesystem lookup. On a miss it- # fetches the version manifest from api.github.com (two rate-limited API- # calls per job) and downloads the tarball, on every Node job, because- # runner images don't ship the .nvmrc version.- - name: Restore Node tool cache- id: node-toolcache- if: steps.node-version.outputs.version != ''- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3- with:- path: ${{ runner.tool_cache }}/node/${{ steps.node-version.outputs.version }}- key: node-toolcache-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.version }}-- - name: Set up Node.js- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0+ - name: Set up pnpm and Node+ uses: ./.depot/actions/setup-pnpmwith:node-version-file: ${{ inputs.node-version-file }}- token: ${{ github.token }}-- # Save only on the default branch, for the same reasons as the pnpm store save below.- - name: Save Node tool cache- if: github.ref == 'refs/heads/master' && steps.node-version.outputs.version != '' && steps.node-toolcache.outputs.cache-hit != 'true'- uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3- with:- path: ${{ runner.tool_cache }}/node/${{ steps.node-version.outputs.version }}- key: node-toolcache-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.version }}- name: Get pnpm store pathid: pnpm-store+ if: inputs.install != 'false'shell: bashrun: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"- name: Restore pnpm storeid: restore+ if: inputs.install != 'false'uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3with:path: ${{ steps.pnpm-store.outputs.path }}@@ -106,6 +55,7 @@ runs:restore-keys: pnpm-${{ runner.os }}-- name: Install dependencies+ if: inputs.install != 'false'shell: bashworking-directory: ${{ inputs.working-directory }}# Pass the command through env and eval it rather than interpolating@@ -123,7 +73,7 @@ runs:# scoped to that ref alone — no other branch can read them, they evict# the shared master cache, and they only ever help that one PR's re-runs.- name: Save pnpm store- if: github.ref == 'refs/heads/master' && steps.restore.outputs.cache-hit != 'true'+ if: inputs.install != 'false' && github.ref == 'refs/heads/master' && steps.restore.outputs.cache-hit != 'true'uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3with:path: ${{ steps.pnpm-store.outputs.path }}diff --git a/.depot/actions/setup-pnpm/action.yml b/.depot/actions/setup-pnpm/action.ymlnew file mode 100644index 000000000000..b9c3541cd8a2--- /dev/null+++ b/.depot/actions/setup-pnpm/action.yml@@ -0,0 +1,76 @@+name: Set up pnpm and Node+description: |+ Puts pnpm and the `.nvmrc` Node on PATH. Installs nothing.++ Pre-seeds the Node tool cache (`node-toolcache-<os>-<arch>-<version>`,+ master-gated save) so setup-node makes no GitHub API calls on a hit.++ Use `pnpm-install` instead when the job needs the workspace installed.++ Depot shadow of .github/actions/setup-pnpm: no app token is available here,+ so setup-node reads github.token.++inputs:+ node-version-file:+ description: 'File specifying the Node version.'+ required: false+ default: .nvmrc++runs:+ using: composite+ steps:+ - name: Install pnpm+ uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8+ env:+ # Kept in sync with .github/actions/setup-pnpm: npm's audit blocks the pnpm+ # bootstrap and gates nothing.+ NPM_CONFIG_AUDIT: 'false'+ NPM_CONFIG_FUND: 'false'++ - name: Fix node-gyp permissions+ shell: bash+ # Depot CI's restored pnpm store can land node-gyp's gyp_main.py without +x.+ # Locate it across pnpm/action-setup layouts and never fail if it is absent.+ run: find ~/setup-pnpm -name gyp_main.py -path '*/node-gyp/*' -exec chmod +x {} + 2>/dev/null || true++ - name: Resolve Node version+ id: node-version+ shell: bash+ # An empty version (missing file or non-exact pin) skips the tool cache+ # steps, so setup-node falls back to resolving the version itself. Only+ # exact x.y.z pins are cacheable: the tool-cache directory is named after+ # the resolved version, so a range spec would never match it.+ env:+ NODE_VERSION_FILE: ${{ inputs.node-version-file }}+ run: |+ version=""+ [[ -f "$NODE_VERSION_FILE" ]] && version=$(tr -d 'v[:space:]' < "$NODE_VERSION_FILE")+ [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || version=""+ echo "version=$version" >> "$GITHUB_OUTPUT"++ # A tool-cache hit turns setup-node into a filesystem lookup. On a miss it+ # fetches the version manifest from api.github.com (two rate-limited API+ # calls per job) and downloads the tarball, on every Node job, because+ # runner images don't ship the .nvmrc version.+ - name: Restore Node tool cache+ id: node-toolcache+ if: steps.node-version.outputs.version != ''+ uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3+ with:+ path: ${{ runner.tool_cache }}/node/${{ steps.node-version.outputs.version }}+ key: node-toolcache-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.version }}++ - name: Set up Node.js+ uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0+ with:+ node-version-file: ${{ inputs.node-version-file }}+ token: ${{ github.token }}++ # Save only on the default branch: caches written on a PR ref are scoped to+ # that ref alone, evict the shared master entry, and help only that one PR.+ - name: Save Node tool cache+ if: github.ref == 'refs/heads/master' && steps.node-version.outputs.version != '' && steps.node-toolcache.outputs.cache-hit != 'true'+ uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3+ with:+ path: ${{ runner.tool_cache }}/node/${{ steps.node-version.outputs.version }}+ key: node-toolcache-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.version }}diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.ymlindex 2716f87de58a..6886dbe82115 100644--- a/.depot/workflows/ci-backend.yml+++ b/.depot/workflows/ci-backend.yml@@ -11,7 +11,8 @@# - runs-on: depot-* labels instead of ubuntu-latest# - action paths: ./.depot/actions/... instead of ./.github/actions/... (pnpm-install,# setup-sqlx-cli, setup-python-cached, and paths-filter mirror the canonical-# composites; any deltas are documented in each mirror's header)+# composites; any deltas are documented in each mirror's header). setup-turbo has no+# mirror because there is nothing Depot needs to strip from it.# - permissions: pull-requests:read (no comment/auto-commit side effects)# - Stripped side effects: artifact uploads, CI report section posters (canonical# additionally skips these on trunk-merge/** branches to save GITHUB_TOKEN budget;@@ -865,10 +866,8 @@ jobs:# pnpm-install and setup-python; mint stripped here (secret not# available on Depot), so setup-python keeps the bot PAT.- parallel:- - name: Install pnpm dependencies- uses: ./.depot/actions/pnpm-install- with:- install-command: pnpm install --frozen-lockfile --filter=@posthog/root+ - name: Set up pnpm and Node+ uses: ./.depot/actions/setup-pnpm- name: Set up Pythonuses: ./.depot/actions/setup-python-cachedwith:@@ -879,6 +878,10 @@ jobs:with:toolchain: 1.91.1components: cargo+ # Needs pnpm from the block above, so it cannot run inside it.+ - name: Install turbo+ uses: ./.github/actions/setup-turbo+- name: Install uvid: setup-uvuses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0@@ -1049,7 +1052,7 @@ jobs:echo "::group::turbo backend:test $leg_filters $leg_args"# Word splitting is intended here: both variables carry several flags.# shellcheck disable=SC2086- pnpm turbo run backend:test $leg_filters --concurrency=1 --output-logs=full --force --log-order=stream $leg_args+ turbo run backend:test $leg_filters --concurrency=1 --output-logs=full --force --log-order=stream $leg_argsexit_code=$?echo "::endgroup::"if [ $exit_code -eq 5 ]; thendiff --git a/.github/actions/pnpm-install/action.yml b/.github/actions/pnpm-install/action.ymlindex de3be522b519..59a21202b55a 100644--- a/.github/actions/pnpm-install/action.yml+++ b/.github/actions/pnpm-install/action.yml@@ -1,6 +1,7 @@name: Install pnpm dependenciesdescription: |- Sets up pnpm + Node, restores the shared pnpm store cache, and installs.+ Sets up pnpm + Node via `setup-pnpm`, restores the shared pnpm store cache,+ and installs.Single source of truth for the pnpm cache key. Every node workflow sharesone namespace (`pnpm-<os>-<lockfile-hash>`), so the store is cached once@@ -8,9 +9,6 @@ description: |Restore only: .github/workflows/pnpm-store-cache.yml writes the entry onmaster from a cold install, and explains why no consumer may save it.- Also pre-seeds the Node tool cache (`node-toolcache-<os>-<arch>-<version>`,- master-gated save) so setup-node makes no GitHub API calls on a hit.-Deliberately does NOT use setup-node's `cache: pnpm`: that auto-saves onevery run (PRs included, and the post-save can't be gated) and keys on`os.arch()` (lowercase `x64`), which never matches a hand-written@@ -40,62 +38,12 @@ inputs:runs:using: compositesteps:- - name: Install pnpm- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8- env:- # The action bootstraps pnpm with `npm ci`, which audits by default. That audit- # covers two packages and gates nothing, but it blocks until npm answers, so a- # degraded audit endpoint stalls the step until npm's 300s fetch timeout. That- # alone exhausts a 5 minute job budget before any test runs.- NPM_CONFIG_AUDIT: 'false'- NPM_CONFIG_FUND: 'false'-- - name: Fix node-gyp permissions- shell: bash- run: find ~/setup-pnpm -name gyp_main.py -exec chmod +x {} +-- - name: Resolve Node version- id: node-version- shell: bash- # An empty version (missing file or non-exact pin) skips the tool cache- # steps, so setup-node falls back to resolving the version itself. Only- # exact x.y.z pins are cacheable: the tool-cache directory is named after- # the resolved version, so a range spec would never match it.- env:- NODE_VERSION_FILE: ${{ inputs.node-version-file }}- run: |- version=""- [[ -f "$NODE_VERSION_FILE" ]] && version=$(tr -d 'v[:space:]' < "$NODE_VERSION_FILE")- [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || version=""- echo "version=$version" >> "$GITHUB_OUTPUT"-- # A tool-cache hit turns setup-node into a filesystem lookup. On a miss it- # fetches the version manifest from api.github.com (two rate-limited API- # calls per job) and downloads the tarball, on every Node job, because- # runner images don't ship the .nvmrc version.- - name: Restore Node tool cache- id: node-toolcache- if: steps.node-version.outputs.version != ''- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3- with:- path: ${{ runner.tool_cache }}/node/${{ steps.node-version.outputs.version }}- key: node-toolcache-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.version }}-- - name: Set up Node.js- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0+ - name: Set up pnpm and Node+ uses: ./.github/actions/setup-pnpmwith:node-version-file: ${{ inputs.node-version-file }}token: ${{ inputs.token }}- # Save only on the default branch: a cache written on a PR ref serves that- # PR alone and evicts the shared master entries.- - name: Save Node tool cache- if: github.ref == 'refs/heads/master' && steps.node-version.outputs.version != '' && steps.node-toolcache.outputs.cache-hit != 'true'- uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3- with:- path: ${{ runner.tool_cache }}/node/${{ steps.node-version.outputs.version }}- key: node-toolcache-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.version }}-- name: Get pnpm store pathid: pnpm-storeshell: bashdiff --git a/.github/actions/setup-pnpm/action.yml b/.github/actions/setup-pnpm/action.ymlnew file mode 100644index 000000000000..7866587d7f9e--- /dev/null+++ b/.github/actions/setup-pnpm/action.yml@@ -0,0 +1,80 @@+name: Set up pnpm and Node+description: |+ Puts pnpm and the `.nvmrc` Node on PATH. Installs nothing.++ Pre-seeds the Node tool cache (`node-toolcache-<os>-<arch>-<version>`,+ master-gated save) so setup-node makes no GitHub API calls on a hit.++ Use `pnpm-install` instead when the job needs the workspace installed.++inputs:+ node-version-file:+ description: 'File specifying the Node version.'+ required: false+ default: .nvmrc+ token:+ description: |+ GitHub token for setup-node's version-manifest lookup and Node download.+ Pass an app token at high-fanout call sites to keep those API calls off+ the shared per-repo GITHUB_TOKEN core bucket.+ required: false+ default: ${{ github.token }}++runs:+ using: composite+ steps:+ - name: Install pnpm+ uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8+ env:+ # The action bootstraps pnpm with `npm ci`, which audits by default. That audit+ # covers two packages and gates nothing, but it blocks until npm answers, so a+ # degraded audit endpoint stalls the step until npm's 300s fetch timeout. That+ # alone exhausts a 5 minute job budget before any test runs.+ NPM_CONFIG_AUDIT: 'false'+ NPM_CONFIG_FUND: 'false'++ - name: Fix node-gyp permissions+ shell: bash+ run: find ~/setup-pnpm -name gyp_main.py -exec chmod +x {} +++ - name: Resolve Node version+ id: node-version+ shell: bash+ # An empty version (missing file or non-exact pin) skips the tool cache+ # steps, so setup-node falls back to resolving the version itself. Only+ # exact x.y.z pins are cacheable: the tool-cache directory is named after+ # the resolved version, so a range spec would never match it.+ env:+ NODE_VERSION_FILE: ${{ inputs.node-version-file }}+ run: |+ version=""+ [[ -f "$NODE_VERSION_FILE" ]] && version=$(tr -d 'v[:space:]' < "$NODE_VERSION_FILE")+ [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || version=""+ echo "version=$version" >> "$GITHUB_OUTPUT"++ # A tool-cache hit turns setup-node into a filesystem lookup. On a miss it+ # fetches the version manifest from api.github.com (two rate-limited API+ # calls per job) and downloads the tarball, on every Node job, because+ # runner images don't ship the .nvmrc version.+ - name: Restore Node tool cache+ id: node-toolcache+ if: steps.node-version.outputs.version != ''+ uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3+ with:+ path: ${{ runner.tool_cache }}/node/${{ steps.node-version.outputs.version }}+ key: node-toolcache-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.version }}++ - name: Set up Node.js+ uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0+ with:+ node-version-file: ${{ inputs.node-version-file }}+ token: ${{ inputs.token }}++ # Save only on the default branch: caches written on a PR ref are scoped to+ # that ref alone, evict the shared master entry, and help only that one PR.+ - name: Save Node tool cache+ if: github.ref == 'refs/heads/master' && steps.node-version.outputs.version != '' && steps.node-toolcache.outputs.cache-hit != 'true'+ uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3+ with:+ path: ${{ runner.tool_cache }}/node/${{ steps.node-version.outputs.version }}+ key: node-toolcache-${{ runner.os }}-${{ runner.arch }}-${{ steps.node-version.outputs.version }}diff --git a/.github/actions/setup-turbo/action.yml b/.github/actions/setup-turbo/action.ymlnew file mode 100644index 000000000000..f286357b4c93--- /dev/null+++ b/.github/actions/setup-turbo/action.yml@@ -0,0 +1,51 @@+name: Install turbo+description: |+ Puts the lockfile-pinned `turbo` binary on PATH, for a job that runs turbo+ tasks but does not need the workspace installed.++ Requires pnpm and Node on PATH already: pnpm resolves and fetches the+ package, and turbo shells out through pnpm to launch each task.++inputs:+ lockfile:+ description: 'pnpm lockfile that pins the turbo version and integrity.'+ required: false+ default: pnpm-lock.yaml++runs:+ using: composite+ steps:+ - name: Install turbo+ shell: bash+ env:+ LOCKFILE: ${{ inputs.lockfile }}+ npm_config_fetch_retries: 3+ npm_config_fetch_retry_mintimeout: 10000+ npm_config_fetch_retry_maxtimeout: 60000+ run: |+ set -euo pipefail++ # Every turbo entry, as "<name>@<version> <integrity>". Comparing the+ # whole set catches a registry that serves different bytes than the+ # ones committed here, which resolving by version alone would accept.+ turbo_packages='.packages | to_entries+ | map(select(.key | test("^(turbo|@turbo/)")))+ | map(.key + " " + .value.resolution.integrity) | sort | .[]'++ version=$(yq -e '.importers["."].devDependencies.turbo.version' "$LOCKFILE")++ # Outside the workspace, so pnpm treats it as its own project and+ # writes nothing into the checkout.+ dir="$RUNNER_TEMP/turbo"+ mkdir -p "$dir"+ echo '{"name":"turbo-runner","private":true}' > "$dir/package.json"+ pnpm --dir "$dir" add "turbo@$version"++ if ! diff <(yq -r "$turbo_packages" "$LOCKFILE") \+ <(yq -r "$turbo_packages" "$dir/pnpm-lock.yaml"); then+ echo "::error::turbo resolved to different bytes than $LOCKFILE pins"+ exit 1+ fi++ echo "$dir/node_modules/.bin" >> "$GITHUB_PATH"+ "$dir/node_modules/.bin/turbo" --versiondiff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex 80ae1bf39618..b63b76c7480b 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -825,10 +825,11 @@ jobs:skip-token-revoke: true- parallel:- - name: Install pnpm dependencies- uses: ./.github/actions/pnpm-install+ # turbo launches each backend:test script through pnpm, so pnpm and+ # Node must stay on PATH even though nothing here reads the workspace.+ - name: Set up pnpm and Node+ uses: ./.github/actions/setup-pnpmwith:- install-command: pnpm install --frozen-lockfile --filter=@posthog/roottoken: ${{ steps.setup-gh-token.outputs.token || github.token }}- name: Set up Python@@ -843,6 +844,10 @@ jobs:toolchain: 1.91.1components: cargo+ # Needs pnpm from the block above, so it cannot run inside it.+ - name: Install turbo+ uses: ./.github/actions/setup-turbo+- name: Install uvid: setup-uvuses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0@@ -1070,7 +1075,7 @@ jobs:echo "::group::turbo backend:test $leg_filters $leg_args"# Word splitting is intended here: both variables carry several flags.# shellcheck disable=SC2086- pnpm turbo run backend:test $leg_filters --concurrency=1 --output-logs=full --force --log-order=stream $leg_args+ turbo run backend:test $leg_filters --concurrency=1 --output-logs=full --force --log-order=stream $leg_argsexit_code=$?echo "::endgroup::"if [ $exit_code -eq 5 ]; then