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.

chore(devex): dedup pnpm cache and gate cache writes in CI (#64497)

Julian Bezc7a9bfec5f85
diff --git a/.github/actions/pnpm-install/action.yml b/.github/actions/pnpm-install/action.yml
new file mode 100644
index 000000000000..19cc5e15d3a4
--- /dev/null
+++ b/.github/actions/pnpm-install/action.yml
@@ -0,0 +1,76 @@
+name: Install pnpm dependencies
+description: |
+ Sets up pnpm + Node, 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 shares
+ one namespace (`pnpm-<os>-<lockfile-hash>`), so the store is cached once
+ instead of fragmenting across runner-arch casings or per-workflow keys.
+
+ Deliberately does NOT use setup-node's `cache: pnpm`: that auto-saves on
+ every run (PRs included, and the post-save can't be gated) and keys on
+ `os.arch()` (lowercase `x64`), which never matches a hand-written
+ `runner.arch` key (uppercase `X64`). We restore/save explicitly instead.
+
+inputs:
+ install-command:
+ description: 'Command used to install dependencies. Override for filtered installs.'
+ required: false
+ default: 'pnpm install --frozen-lockfile'
+ node-version-file:
+ description: 'File specifying the Node version.'
+ required: false
+ default: .nvmrc
+ working-directory:
+ description: 'Directory to run the install command in.'
+ required: false
+ default: '.'
+
+runs:
+ using: composite
+ steps:
+ - name: Install pnpm
+ uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
+
+ - name: Set up Node.js
+ uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ with:
+ node-version-file: ${{ inputs.node-version-file }}
+ token: ${{ github.token }}
+
+ - name: Get pnpm store path
+ id: pnpm-store
+ shell: bash
+ run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
+
+ - name: Restore pnpm store
+ id: restore
+ uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: ${{ steps.pnpm-store.outputs.path }}
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+ restore-keys: pnpm-${{ runner.os }}-
+
+ - name: Install dependencies
+ shell: bash
+ working-directory: ${{ inputs.working-directory }}
+ # Pass the command through env and eval it rather than interpolating
+ # ${{ }} straight into run: — that trips semgrep's run-shell-injection
+ # rule. eval keeps shell parsing so quoted --filter globs survive.
+ # pnpm reads npm_config_* — keep cache-miss fetches resilient to blips.
+ env:
+ INSTALL_COMMAND: ${{ inputs.install-command }}
+ npm_config_fetch_retries: 3
+ npm_config_fetch_retry_mintimeout: 10000
+ npm_config_fetch_retry_maxtimeout: 60000
+ run: eval "$INSTALL_COMMAND"
+
+ # Save only on the default branch. Caches written on a PR/branch ref are
+ # 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'
+ uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: ${{ steps.pnpm-store.outputs.path }}
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
diff --git a/.github/actions/rust-compute-affected/action.yml b/.github/actions/rust-compute-affected/action.yml
index 8020ac1a35a1..a072c645144e 100644
--- a/.github/actions/rust-compute-affected/action.yml
+++ b/.github/actions/rust-compute-affected/action.yml
@@ -48,7 +48,10 @@ runs:
run: cargo build -p affected-services --release --locked
- name: Save binary to cache
- if: steps.cache.outputs.cache-hit != 'true'
+ # Save only on master — a PR ref's cache is scoped to that PR alone and
+ # just evicts the shared one. PRs restore master's binary; PRs that touch
+ # affected-services rebuild without saving. Matches setup-sccache/sqlx-cli.
+ if: steps.cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/master'
uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: rust/target/release/affected-services
diff --git a/.github/workflows/browserslist.yml b/.github/workflows/browserslist.yml
index 6489dfffb62d..f1566022df46 100644
--- a/.github/workflows/browserslist.yml
+++ b/.github/workflows/browserslist.yml
@@ -27,21 +27,15 @@ jobs:
with:
token: ${{ steps.app-token.outputs.token }}
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: 'pnpm'
+ install-command: pnpm install
- name: Update Browserslist database
env:
NO_COLOR: '1'
- run: |
- pnpm install
- npx --yes update-browserslist-db@latest 2>&1 | tee /tmp/browserslist-output.txt
+ run: npx --yes update-browserslist-db@latest 2>&1 | tee /tmp/browserslist-output.txt
- name: Check for changes
id: check-changes
diff --git a/.github/workflows/build-hogql-parser-npm.yml b/.github/workflows/build-hogql-parser-npm.yml
index 4b2720387b57..9b6524450402 100644
--- a/.github/workflows/build-hogql-parser-npm.yml
+++ b/.github/workflows/build-hogql-parser-npm.yml
@@ -139,7 +139,6 @@ jobs:
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
- cache: 'pnpm'
- name: Install uv
id: setup-uv
diff --git a/.github/workflows/ci-agents.yml b/.github/workflows/ci-agents.yml
index 7c6c05e7c5f3..9cbd8a156e2d 100644
--- a/.github/workflows/ci-agents.yml
+++ b/.github/workflows/ci-agents.yml
@@ -82,24 +82,10 @@ jobs:
with:
clean: false
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-agents.yml
-
- - name: Install dependencies
- env:
- npm_config_fetch_retries: 3
- npm_config_fetch_retry_mintimeout: 10000
- npm_config_fetch_retry_maxtimeout: 60000
- run: pnpm --filter="${{ matrix.workspace }}..." install --frozen-lockfile
+ install-command: pnpm --filter="${{ matrix.workspace }}..." install --frozen-lockfile
- name: Typecheck
run: pnpm --filter="${{ matrix.workspace }}" typescript:check
@@ -156,24 +142,10 @@ jobs:
- name: Add service hostnames to /etc/hosts
run: echo "127.0.0.1 db redis7 kafka seaweedfs" | sudo tee -a /etc/hosts
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-agents.yml
-
- - name: Install dependencies
- env:
- npm_config_fetch_retries: 3
- npm_config_fetch_retry_mintimeout: 10000
- npm_config_fetch_retry_maxtimeout: 60000
- run: pnpm --filter="${{ matrix.workspace }}..." install --frozen-lockfile
+ install-command: pnpm --filter="${{ matrix.workspace }}..." install --frozen-lockfile
- name: Create empty test database
# Schema lives in @posthog/agent-migrations; tests call
@@ -219,24 +191,10 @@ jobs:
- name: Add service hostnames to /etc/hosts
run: echo "127.0.0.1 db redis7 kafka seaweedfs" | sudo tee -a /etc/hosts
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-agents.yml
-
- - name: Install dependencies
- env:
- npm_config_fetch_retries: 3
- npm_config_fetch_retry_mintimeout: 10000
- npm_config_fetch_retry_maxtimeout: 60000
- run: pnpm --filter='@posthog/agent-tests...' install --frozen-lockfile
+ install-command: pnpm --filter='@posthog/agent-tests...' install --frozen-lockfile
- name: Create empty test database
# Schema lives in @posthog/agent-migrations; the test harness
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 9f327a9b93a8..d347c6b9da46 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -408,21 +408,10 @@ jobs:
private-key: ${{ secrets.GH_APP_POSTHOG_DEVEX_GENERAL_PRIVATE_KEY }}
skip-token-revoke: true
- - name: Setup pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-backend.yml
- token: ${{ steps.setup-gh-token.outputs.token || github.token }}
-
- name: Install pnpm dependencies
- run: pnpm install --frozen-lockfile --filter=@posthog/root
+ uses: ./.github/actions/pnpm-install
+ with:
+ install-command: pnpm install --frozen-lockfile --filter=@posthog/root
- name: Restore test durations from cache
# Shard counts are derived from .test_durations (Amdahl). Restore the newest
@@ -679,21 +668,10 @@ jobs:
private-key: ${{ secrets.GH_APP_POSTHOG_DEVEX_GENERAL_PRIVATE_KEY }}
skip-token-revoke: true
- - name: Setup pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-backend.yml
- token: ${{ steps.setup-gh-token.outputs.token || github.token }}
-
- name: Install pnpm dependencies
- run: pnpm install --frozen-lockfile --filter=@posthog/root
+ uses: ./.github/actions/pnpm-install
+ with:
+ install-command: pnpm install --frozen-lockfile --filter=@posthog/root
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -1701,25 +1679,10 @@ jobs:
run: |
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-backend.yml
- token: ${{ steps.setup-gh-token.outputs.token || github.token }}
-
- - name: Install package.json dependencies with pnpm
- env:
- npm_config_fetch_retries: 3
- npm_config_fetch_retry_mintimeout: 10000
- npm_config_fetch_retry_maxtimeout: 60000
- run: pnpm --filter=@posthog/root --filter=@posthog/frontend... --filter=@posthog/mcp... install --frozen-lockfile
+ install-command: pnpm --filter=@posthog/root --filter=@posthog/frontend... --filter=@posthog/mcp... install --frozen-lockfile
- name: Wait for Docker services
env:
diff --git a/.github/workflows/ci-cli.yml b/.github/workflows/ci-cli.yml
index ef0d6941a8a0..c99706ef40a5 100644
--- a/.github/workflows/ci-cli.yml
+++ b/.github/workflows/ci-cli.yml
@@ -91,17 +91,10 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- - name: Setup pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: 'pnpm'
-
- - name: Install API CLI dependencies
- run: pnpm --filter '@posthog/mcp...' install --frozen-lockfile
+ install-command: pnpm --filter '@posthog/mcp...' install --frozen-lockfile
- name: Build API CLI release bundle
run: pnpm --dir services/mcp run build:cli:release
diff --git a/.github/workflows/ci-docs-check.yml b/.github/workflows/ci-docs-check.yml
index c41a4e5fb164..49a6099f2b7c 100644
--- a/.github/workflows/ci-docs-check.yml
+++ b/.github/workflows/ci-docs-check.yml
@@ -48,32 +48,9 @@ jobs:
if: steps.source-check.outputs.changed == 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- - name: Setup pnpm
+ - name: Install pnpm dependencies
if: steps.source-check.outputs.changed == 'true'
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- if: steps.source-check.outputs.changed == 'true'
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
-
- - name: Get pnpm store path
- if: steps.source-check.outputs.changed == 'true'
- id: pnpm-store
- run: echo "path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
-
- - name: Restore pnpm cache
- if: steps.source-check.outputs.changed == 'true'
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
- with:
- path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- restore-keys: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-
-
- - name: Install dependencies
- if: steps.source-check.outputs.changed == 'true'
- run: pnpm install --frozen-lockfile
+ uses: ./.github/actions/pnpm-install
- name: Generate docs
if: steps.source-check.outputs.changed == 'true'
diff --git a/.github/workflows/ci-e2e-playwright.yml b/.github/workflows/ci-e2e-playwright.yml
index 4725f8195fca..1a0eb12c8f6e 100644
--- a/.github/workflows/ci-e2e-playwright.yml
+++ b/.github/workflows/ci-e2e-playwright.yml
@@ -297,12 +297,24 @@ jobs:
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-e2e-playwright.yml
token: ${{ github.token }}
+ # This job checks out the PR head (not the merge ref), so it can't use
+ # the ./.github/actions/pnpm-install local action — an un-rebased head
+ # may not contain it. Cache the store inline instead, sharing the same
+ # pnpm-<os>-<lockhash> key as the action and gating the save to master.
+ - name: Get pnpm store path
+ id: pnpm-store
+ shell: bash
+ run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
+
+ - name: Restore pnpm cache
+ uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: ${{ steps.pnpm-store.outputs.path }}
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+ restore-keys: pnpm-${{ runner.os }}-
+
# Workaround for SIGABRT (exit 134) raised after all tests pass.
# See https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#tlambert03-setup-qt-libs
- uses: tlambert03/setup-qt-libs@19e4ef2d781d81f5f067182e228b54ec90d23b76 # v1.8
@@ -358,6 +370,13 @@ jobs:
pnpm --filter=@posthog/playwright... install --frozen-lockfile
bin/turbo --filter=@posthog/frontend prepare
+ - name: Save pnpm cache
+ if: github.ref == 'refs/heads/master'
+ uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: ${{ steps.pnpm-store.outputs.path }}
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Log in to Docker Hub
if: ${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.yml
index 40c768e8c891..136f9df6e2a6 100644
--- a/.github/workflows/ci-frontend.yml
+++ b/.github/workflows/ci-frontend.yml
@@ -251,37 +251,13 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- token: ${{ github.token }}
-
- - name: Get pnpm store path
- id: pnpm-store
- run: echo "path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
-
- - name: Restore pnpm cache
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- restore-keys: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-
-
- - name: Install package.json dependencies with pnpm
- run: |
- pnpm --filter=@posthog/playwright... install --frozen-lockfile
- bin/turbo --filter=@posthog/frontend prepare
+ install-command: pnpm --filter=@posthog/playwright... install --frozen-lockfile
- - name: Save pnpm cache
- if: github.ref == 'refs/heads/master'
- uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
- with:
- path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
+ - name: Prepare frontend
+ run: bin/turbo --filter=@posthog/frontend prepare
- name: Check formatting with oxfmt
run: pnpm run format:frontend:check
@@ -311,6 +287,12 @@ jobs:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
filter: blob:none
+
+ # compressed-size-action below checks out the base branch mid-job, which
+ # removes this repo's local actions from the workspace — a local
+ # ./.github/actions/pnpm-install would then fail in its post phase. Use
+ # inline cache steps (remote actions, no workspace-dependent post) sharing
+ # the same pnpm-<os>-<lockhash> key.
- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
@@ -322,26 +304,27 @@ jobs:
- name: Get pnpm store path
id: pnpm-store
- run: echo "path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
+ run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
- name: Restore pnpm cache
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- restore-keys: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+ restore-keys: pnpm-${{ runner.os }}-
- name: Install package.json dependencies with pnpm
- run: |
- pnpm --filter=@posthog/playwright... install --frozen-lockfile
- bin/turbo --filter=@posthog/frontend prepare
+ run: pnpm --filter=@posthog/playwright... install --frozen-lockfile
- name: Save pnpm cache
if: github.ref == 'refs/heads/master'
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+
+ - name: Prepare frontend
+ run: bin/turbo --filter=@posthog/frontend prepare
- name: Build products
run: pnpm --filter=@posthog/frontend build:products
@@ -455,37 +438,13 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- token: ${{ github.token }}
-
- - name: Get pnpm store path
- id: pnpm-store
- run: echo "path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
-
- - name: Restore pnpm cache
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- restore-keys: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-
+ install-command: pnpm --filter=@posthog/playwright... install --no-frozen-lockfile
- - name: Install package.json dependencies with pnpm
- run: |
- pnpm --filter=@posthog/playwright... install --no-frozen-lockfile
- bin/turbo --filter=@posthog/frontend prepare
-
- - name: Save pnpm cache
- if: github.ref == 'refs/heads/master'
- uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
- with:
- path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
+ - name: Prepare frontend
+ run: bin/turbo --filter=@posthog/frontend prepare
- name: Restore .typegen cache
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
@@ -552,35 +511,10 @@ jobs:
if: matrix.segment == 'FOSS'
run: rm -rf ee
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- token: ${{ github.token }}
-
- - name: Get pnpm store path
- id: pnpm-store
- run: echo "path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
-
- - name: Restore pnpm cache
- uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
- with:
- path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- restore-keys: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-
-
- - name: Install package.json dependencies with pnpm
- run: pnpm --filter=@posthog/frontend... install --frozen-lockfile
-
- - name: Save pnpm cache
- if: github.ref == 'refs/heads/master'
- uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
+ install-command: pnpm --filter=@posthog/frontend... install --frozen-lockfile
- name: Test with Jest
env:
diff --git a/.github/workflows/ci-geoip-canary.yml b/.github/workflows/ci-geoip-canary.yml
index aa95496a0f6d..7fc601bd8962 100644
--- a/.github/workflows/ci-geoip-canary.yml
+++ b/.github/workflows/ci-geoip-canary.yml
@@ -36,28 +36,13 @@ jobs:
with:
clean: false
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-geoip-canary.yml
- token: ${{ github.token }}
-
- name: Download MaxMind database
run: ./bin/download-mmdb
- - name: Install package.json dependencies with pnpm
- env:
- npm_config_fetch_retries: 3
- npm_config_fetch_retry_mintimeout: 10000
- npm_config_fetch_retry_maxtimeout: 60000
- run: pnpm --filter=@posthog/nodejs... install --frozen-lockfile
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
+ with:
+ install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfile
- name: Run canary against live database
id: canary
diff --git a/.github/workflows/ci-hog.yml b/.github/workflows/ci-hog.yml
index c43d753fe726..215ec3335cd8 100644
--- a/.github/workflows/ci-hog.yml
+++ b/.github/workflows/ci-hog.yml
@@ -98,15 +98,10 @@ jobs:
run: |
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: 'pnpm'
- token: ${{ github.token }}
+ install-command: pnpm --filter=@posthog/hogvm install --frozen-lockfile
- name: Check if ANTLR definitions are up to date
run: |
@@ -206,7 +201,6 @@ jobs:
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
- cache: 'pnpm'
registry-url: https://registry.npmjs.org
token: ${{ github.token }}
- name: Install package.json dependencies
diff --git a/.github/workflows/ci-lint-workflows.yml b/.github/workflows/ci-lint-workflows.yml
index 77348ae823b4..6016690ebc1a 100644
--- a/.github/workflows/ci-lint-workflows.yml
+++ b/.github/workflows/ci-lint-workflows.yml
@@ -4,6 +4,7 @@ on:
pull_request:
paths:
- .github/workflows/**
+ - .github/actions/**
- services/**
- tools/hogli-commands/hogli_commands/workflow_lint/**
- hogli.yaml
diff --git a/.github/workflows/ci-mcp-ui-apps.yml b/.github/workflows/ci-mcp-ui-apps.yml
index 538720dbc16c..914e2e5a3d52 100644
--- a/.github/workflows/ci-mcp-ui-apps.yml
+++ b/.github/workflows/ci-mcp-ui-apps.yml
@@ -65,19 +65,11 @@ jobs:
cache-dependency-glob: uv.lock
save-cache: ${{ github.ref == 'refs/heads/master' }}
- - name: Setup pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- cache: 'pnpm'
- token: ${{ github.token }}
-
- - name: Install dependencies
+ - name: Install pnpm dependencies
# Match services/mcp/Dockerfile exactly
- run: pnpm --filter=@posthog/mcp... install --frozen-lockfile
+ uses: ./.github/actions/pnpm-install
+ with:
+ install-command: pnpm --filter=@posthog/mcp... install --frozen-lockfile
- name: Check generated UI apps are up to date
run: |
diff --git a/.github/workflows/ci-mcp.yml b/.github/workflows/ci-mcp.yml
index e5458e73c8f0..88541e3c6a35 100644
--- a/.github/workflows/ci-mcp.yml
+++ b/.github/workflows/ci-mcp.yml
@@ -132,18 +132,10 @@ jobs:
- name: Install Python dependencies
run: UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
- - name: Setup pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: 'pnpm'
- token: ${{ github.token }}
-
- - name: Install dependencies
- run: pnpm --filter=@posthog/mcp... --filter='./products/*' install --frozen-lockfile
+ install-command: pnpm --filter=@posthog/mcp... --filter='./products/*' install --frozen-lockfile
- name: Build package
run: cd services/mcp && pnpm build
@@ -185,18 +177,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- - name: Setup pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: 'pnpm'
- token: ${{ github.token }}
-
- - name: Install dependencies
- run: pnpm --filter=@posthog/mcp... --filter='./products/*' install --frozen-lockfile
+ install-command: pnpm --filter=@posthog/mcp... --filter='./products/*' install --frozen-lockfile
# The workers-pool project in vitest.config.mts parses wrangler.jsonc
# up front and needs `assets.directory` (./public/) populated and
@@ -356,23 +340,15 @@ jobs:
run: |
sudo apt-get update && sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
- - name: Setup pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- cache: 'pnpm'
- token: ${{ github.token }}
-
- name: Install Python dependencies
shell: bash
run: |
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
- - name: Install Node dependencies
- run: pnpm --filter=@posthog/mcp... --filter='./products/*' install --frozen-lockfile
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
+ with:
+ install-command: pnpm --filter=@posthog/mcp... --filter='./products/*' install --frozen-lockfile
- name: Set up needed files
shell: bash
diff --git a/.github/workflows/ci-nodejs.yml b/.github/workflows/ci-nodejs.yml
index 42eb0c63eb19..67e170b9f578 100644
--- a/.github/workflows/ci-nodejs.yml
+++ b/.github/workflows/ci-nodejs.yml
@@ -130,27 +130,13 @@ jobs:
with:
clean: false
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-nodejs.yml
- token: ${{ github.token }}
+ install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfile
- - name: Install package.json dependencies with pnpm
- env:
- npm_config_fetch_retries: 3
- npm_config_fetch_retry_mintimeout: 10000
- npm_config_fetch_retry_maxtimeout: 60000
- run: |
- pnpm --filter=@posthog/nodejs... install --frozen-lockfile
- bin/turbo --filter=@posthog/nodejs prepare
+ - name: Prepare Node.js workspace
+ run: bin/turbo --filter=@posthog/nodejs prepare
- name: Check formatting with prettier
run: pnpm --filter=@posthog/nodejs format:check
@@ -169,27 +155,13 @@ jobs:
with:
clean: false
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-nodejs.yml
- token: ${{ github.token }}
+ install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfile
- - name: Install package.json dependencies with pnpm
- env:
- npm_config_fetch_retries: 3
- npm_config_fetch_retry_mintimeout: 10000
- npm_config_fetch_retry_maxtimeout: 60000
- run: |
- pnpm --filter=@posthog/nodejs... install --frozen-lockfile
- bin/turbo --filter=@posthog/nodejs prepare
+ - name: Prepare Node.js workspace
+ run: bin/turbo --filter=@posthog/nodejs prepare
- name: Check builds correctly
run: pnpm --filter=@posthog/nodejs build
@@ -298,29 +270,14 @@ jobs:
run: |
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-nodejs.yml
- token: ${{ github.token }}
-
- name: Download MaxMind Database
run: |
./bin/download-mmdb
- - name: Install package.json dependencies with pnpm
- env:
- npm_config_fetch_retries: 3
- npm_config_fetch_retry_mintimeout: 10000
- npm_config_fetch_retry_maxtimeout: 60000
- run: pnpm --filter=@posthog/nodejs... install --frozen-lockfile
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
+ with:
+ install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfile
- name: Wait for Clickhouse, Redis, Kafka, Localstack
run: docker compose -f docker-compose.dev.yml up kafka redis7 clickhouse maildev localstack -d --wait
@@ -512,29 +469,14 @@ jobs:
run: |
UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
- with:
- node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-nodejs.yml
- token: ${{ github.token }}
-
- name: Download MaxMind Database
run: |
./bin/download-mmdb
- - name: Install package.json dependencies with pnpm
- env:
- npm_config_fetch_retries: 3
- npm_config_fetch_retry_mintimeout: 10000
- npm_config_fetch_retry_maxtimeout: 60000
- run: pnpm --filter=@posthog/nodejs... install --frozen-lockfile
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
+ with:
+ install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfile
- name: Wait for Clickhouse, Redis, Kafka, Localstack
run: docker compose -f docker-compose.dev.yml up kafka redis7 clickhouse maildev localstack -d --wait
diff --git a/.github/workflows/ci-oauth-proxy.yml b/.github/workflows/ci-oauth-proxy.yml
index 8e0835209349..c0c958bbe726 100644
--- a/.github/workflows/ci-oauth-proxy.yml
+++ b/.github/workflows/ci-oauth-proxy.yml
@@ -49,18 +49,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- - name: Setup pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: 'pnpm'
- token: ${{ github.token }}
-
- - name: Install dependencies
- run: pnpm --filter=@posthog/auth-proxy... install --frozen-lockfile
+ install-command: pnpm --filter=@posthog/auth-proxy... install --frozen-lockfile
- name: Type check (tsgo)
run: cd services/oauth-proxy && pnpm typecheck
diff --git a/.github/workflows/ci-openapi-codegen.yml b/.github/workflows/ci-openapi-codegen.yml
index 7e33738c4523..8709deae7372 100644
--- a/.github/workflows/ci-openapi-codegen.yml
+++ b/.github/workflows/ci-openapi-codegen.yml
@@ -24,17 +24,10 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- - name: Setup pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Setup Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: 'pnpm'
-
- - name: Install dependencies
- run: pnpm --filter=@posthog/openapi-codegen install --frozen-lockfile
+ install-command: pnpm --filter=@posthog/openapi-codegen install --frozen-lockfile
- name: Run tests
run: pnpm --filter=@posthog/openapi-codegen test
diff --git a/.github/workflows/ci-storybook.yml b/.github/workflows/ci-storybook.yml
index 2b2e8a283d1d..52f232fe9d01 100644
--- a/.github/workflows/ci-storybook.yml
+++ b/.github/workflows/ci-storybook.yml
@@ -123,19 +123,37 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
+ # This job checks out the PR head (not the merge ref), so it can't use
+ # the ./.github/actions/pnpm-install local action — an un-rebased head
+ # may not contain it. Cache the store inline instead, sharing the same
+ # pnpm-<os>-<lockhash> key as the action and gating the save to master.
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
- cache: pnpm
- cache-dependency-path: |
- pnpm-lock.yaml
- .github/workflows/ci-storybook.yml
token: ${{ github.token }}
+ - name: Get pnpm store path
+ id: pnpm-store
+ run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
+
+ - name: Restore pnpm cache
+ uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: ${{ steps.pnpm-store.outputs.path }}
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+ restore-keys: pnpm-${{ runner.os }}-
+
- name: Install dependencies
run: pnpm --filter=@posthog/storybook... install --frozen-lockfile
+ - name: Save pnpm cache
+ if: github.ref == 'refs/heads/master'
+ uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: ${{ steps.pnpm-store.outputs.path }}
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Restore webpack build cache
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
@@ -305,8 +323,8 @@ jobs:
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- restore-keys: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+ restore-keys: pnpm-${{ runner.os }}-
- name: Install package.json dependencies with pnpm
run: pnpm --filter=@posthog/storybook... install --frozen-lockfile
@@ -316,7 +334,7 @@ jobs:
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- name: Download Storybook build artifact
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
@@ -465,8 +483,8 @@ jobs:
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ${{ steps.pnpm-store.outputs.path }}
- key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- restore-keys: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-
+ key: pnpm-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
+ restore-keys: pnpm-${{ runner.os }}-
- name: Install dependencies
run: pnpm --filter=@posthog/storybook... install --frozen-lockfile
diff --git a/.github/workflows/ci-turbo.yml b/.github/workflows/ci-turbo.yml
index d10ed7b4d4ee..f5fd3008fb2b 100644
--- a/.github/workflows/ci-turbo.yml
+++ b/.github/workflows/ci-turbo.yml
@@ -49,17 +49,10 @@ jobs:
echo "TURBO_SCM_BASE=master" >> $GITHUB_ENV
fi
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: 'pnpm'
-
- - name: Install Node dependencies
- run: pnpm install --frozen-lockfile --filter=@posthog/root
+ install-command: pnpm install --frozen-lockfile --filter=@posthog/root
- name: Turbo Affected
run: |
diff --git a/.github/workflows/publish-quill-npm.yml b/.github/workflows/publish-quill-npm.yml
index 53a969527f20..7fb28bf3ae46 100644
--- a/.github/workflows/publish-quill-npm.yml
+++ b/.github/workflows/publish-quill-npm.yml
@@ -43,7 +43,6 @@ jobs:
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org
- cache: 'pnpm'
- name: Ensure modern npm (OIDC trusted publishing support)
run: npm install -g [email protected]
diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml
index fb4c93eb7d2d..11114a2a68ac 100644
--- a/.github/workflows/release-cli.yml
+++ b/.github/workflows/release-cli.yml
@@ -440,7 +440,6 @@ jobs:
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
- cache: 'pnpm'
- name: Install API CLI dependencies
run: pnpm --filter '@posthog/mcp...' install --frozen-lockfile
- name: Build API CLI release bundle
@@ -526,7 +525,6 @@ jobs:
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
- cache: 'pnpm'
- name: Install API CLI dependencies
run: pnpm --filter '@posthog/mcp...' install --frozen-lockfile
- name: Build API CLI release bundle
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8a3d65cd5fb8..71ef095a2e62 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -159,7 +159,6 @@ jobs:
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
- cache: 'pnpm'
- name: Install API CLI dependencies
run: pnpm --filter '@posthog/mcp...' install --frozen-lockfile
- name: Build API CLI release bundle
@@ -242,7 +241,6 @@ jobs:
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: .nvmrc
- cache: 'pnpm'
- name: Install API CLI dependencies
run: pnpm --filter '@posthog/mcp...' install --frozen-lockfile
- name: Build API CLI release bundle
diff --git a/.github/workflows/update-ai-costs.yml b/.github/workflows/update-ai-costs.yml
index 97a6734652c3..7af174a09559 100644
--- a/.github/workflows/update-ai-costs.yml
+++ b/.github/workflows/update-ai-costs.yml
@@ -32,21 +32,12 @@ jobs:
with:
token: ${{ steps.app-token.outputs.token }}
- - name: Install pnpm
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
-
- - name: Set up Node.js
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
with:
- node-version-file: .nvmrc
- cache: 'pnpm'
-
- - name: Install dependencies
- env:
- HUSKY: 0
- run: |
- cd nodejs
- pnpm install --frozen-lockfile --ignore-scripts
+ working-directory: nodejs
+ # --ignore-scripts already skips husky's prepare hook (no need for HUSKY=0)
+ install-command: pnpm install --frozen-lockfile --ignore-scripts
- name: Update AI costs
run: |
diff --git a/tools/hogli-commands/hogli_commands/tests/test_workflow_lint.py b/tools/hogli-commands/hogli_commands/tests/test_workflow_lint.py
index 739bfffd4a9b..3741d53d926a 100644
--- a/tools/hogli-commands/hogli_commands/tests/test_workflow_lint.py
+++ b/tools/hogli-commands/hogli_commands/tests/test_workflow_lint.py
@@ -15,6 +15,13 @@ import pytest
from hogli_commands.workflow_lint.check import CheckResult, WorkflowCheck
from hogli_commands.workflow_lint.checks import CHECKS, _build_lookup, get_check
+from hogli_commands.workflow_lint.checks.cache_writes import (
+ _can_run_on_branch_ref,
+ _is_gated,
+ _push_trigger_is_default_only,
+ _violation_kind,
+ _write_kind,
+)
from hogli_commands.workflow_lint.checks.checkout_full_depth import CheckoutFullDepthCheck
from hogli_commands.workflow_lint.checks.dorny_negation import DornyNegationCheck
from hogli_commands.workflow_lint.checks.job_timeouts import JobTimeoutsCheck
@@ -699,6 +706,114 @@ class TestCheckoutFullDepthCheck:
assert CheckoutFullDepthCheck().run(_read_all(tmp_path)).issues == []
+# ---------------------------------------------------------------------------
+# CacheWriteGateCheck
+# ---------------------------------------------------------------------------
+
+
+def _cache_step(if_cond: str | None = None, key: str | None = None) -> dict:
+ step: dict = {"uses": "actions/cache@v4"}
+ if if_cond is not None:
+ step["if"] = if_cond
+ if key is not None:
+ step["with"] = {"key": key}
+ return step
+
+
+class TestCacheWriteGateCheck:
+ @pytest.mark.parametrize(
+ "uses, with_, expected",
+ [
+ ("actions/cache@v4", None, "cache (combined)"),
+ ("actions/cache/save@v4", None, "cache/save"),
+ ("actions/cache/restore@v4", None, None),
+ ("actions/setup-node@v4", {"cache": "pnpm"}, "setup auto-cache"),
+ ("actions/setup-node@v4", {}, None),
+ ("actions/checkout@v4", None, None),
+ ],
+ )
+ def test_write_kind(self, uses: str, with_: dict | None, expected: str | None) -> None:
+ step: dict = {"uses": uses}
+ if with_ is not None:
+ step["with"] = with_
+ assert _write_kind(step) == expected
+
+ @pytest.mark.parametrize(
+ "if_cond, gated",
+ [
+ ("github.ref == 'refs/heads/master'", True),
+ ("github.ref == 'refs/heads/main'", True),
+ ("github.ref_name == 'master'", True),
+ # AND only narrows — still pinned to master
+ ("github.ref == 'refs/heads/master' && github.event_name == 'push'", True),
+ # both OR alternatives pin to a default branch
+ ("github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'", True),
+ # the nit: negation runs on branches, not master
+ ("github.ref != 'refs/heads/master'", False),
+ # the nit: OR re-opens the write to PRs
+ ("github.ref == 'refs/heads/master' || github.event_name == 'pull_request'", False),
+ ("", False),
+ ],
+ )
+ def test_is_gated(self, if_cond: str, gated: bool) -> None:
+ assert _is_gated({"if": if_cond}, push_is_default_only=True) is gated
+
+ @pytest.mark.parametrize("push_is_default_only, gated", [(True, True), (False, False)])
+ def test_event_name_push_gate_depends_on_push_scope(self, push_is_default_only: bool, gated: bool) -> None:
+ # `event_name == 'push'` only pins to master when push can't fire on a branch
+ assert _is_gated({"if": "github.event_name == 'push'"}, push_is_default_only) is gated
+
+ @pytest.mark.parametrize(
+ "step, expected",
+ [
+ (_cache_step(), "cache (combined)"),
+ (_cache_step(if_cond="github.ref == 'refs/heads/master'"), None),
+ (_cache_step(key="pnpm-${{ github.event.pull_request.number }}"), None),
+ # the nit: previously these slipped through as gated
+ (_cache_step(if_cond="github.ref != 'refs/heads/master'"), "cache (combined)"),
+ (
+ _cache_step(if_cond="github.ref == 'refs/heads/master' || github.event_name == 'pull_request'"),
+ "cache (combined)",
+ ),
+ ],
+ )
+ def test_violation_kind(self, step: dict, expected: str | None) -> None:
+ assert _violation_kind(step, push_is_default_only=True) == expected
+
+ def test_setup_autocache_cannot_be_gated(self) -> None:
+ # gating the whole setup step would skip the toolchain on PRs, so the
+ # auto-save is always a violation regardless of `if:`
+ step = {"uses": "actions/setup-node@v4", "if": "github.ref == 'refs/heads/master'", "with": {"cache": "pnpm"}}
+ assert _violation_kind(step, push_is_default_only=True) == "setup auto-cache"
+
+ @pytest.mark.parametrize(
+ "on, can_run_on_branch",
+ [
+ ("pull_request", True),
+ (["pull_request", "push"], True),
+ ({"push": None}, True), # bare push fires on every branch
+ ({"push": {"branches": ["master"]}}, False),
+ ({"push": {"tags": ["*"]}}, False), # release pushes
+ ("workflow_dispatch", False),
+ ("schedule", False),
+ ],
+ )
+ def test_can_run_on_branch_ref(self, on: object, can_run_on_branch: bool) -> None:
+ assert _can_run_on_branch_ref(on) is can_run_on_branch
+
+ @pytest.mark.parametrize(
+ "on, default_only",
+ [
+ ("pull_request", True), # no push trigger
+ ({"push": {"branches": ["master"]}}, True),
+ ({"push": None}, False), # bare push leaks to branches
+ ({"push": {"branches": ["master", "feature"]}}, False),
+ ],
+ )
+ def test_push_trigger_is_default_only(self, on: object, default_only: bool) -> None:
+ assert _push_trigger_is_default_only(on) is default_only
+
+
# ---------------------------------------------------------------------------
# Registry / smoke
# ---------------------------------------------------------------------------
diff --git a/tools/hogli-commands/hogli_commands/workflow_lint/checks/__init__.py b/tools/hogli-commands/hogli_commands/workflow_lint/checks/__init__.py
index ae31b869ba72..4df3110b329b 100644
--- a/tools/hogli-commands/hogli_commands/workflow_lint/checks/__init__.py
+++ b/tools/hogli-commands/hogli_commands/workflow_lint/checks/__init__.py
@@ -12,6 +12,7 @@ up first.
from __future__ import annotations
from ..check import WorkflowCheck
+from .cache_writes import CacheWriteGateCheck
from .checkout_full_depth import CheckoutFullDepthCheck
from .dorny_negation import DornyNegationCheck
from .job_timeouts import JobTimeoutsCheck
@@ -24,6 +25,7 @@ CHECKS: list[WorkflowCheck] = [
DornyNegationCheck(),
SemgrepServicesCoverageCheck(),
CheckoutFullDepthCheck(),
+ CacheWriteGateCheck(),
]
diff --git a/tools/hogli-commands/hogli_commands/workflow_lint/checks/cache_writes.py b/tools/hogli-commands/hogli_commands/workflow_lint/checks/cache_writes.py
new file mode 100644
index 000000000000..7a4354d933c6
--- /dev/null
+++ b/tools/hogli-commands/hogli_commands/workflow_lint/checks/cache_writes.py
@@ -0,0 +1,231 @@
+"""Cache writes must not be able to land on a non-default branch ref.
+
+A cache written on a PR/branch ref is scoped to that ref alone: no other branch
+can read it, it evicts the shared default-branch cache, and it only ever serves
+that one PR's re-runs before LRU eviction. Near the repo's 10 GB cache cap that
+churns the useful master caches out.
+
+A cache WRITE is one of:
+ - actions/cache@ combined action; auto-saves every run in its post step
+ - actions/cache/save@ explicit save
+ - actions/setup-*@ with a truthy `cache:` input — auto-saves in a post step that
+ can't be gated (gating the whole step would skip the toolchain on PRs)
+
+A write is FINE when any of these hold:
+ 1. its workflow can't run on a branch ref at all — triggers are default-only
+ (push to the default branch, schedule, workflow_run). ``workflow_dispatch``
+ is treated as default-scoped on purpose: a cache write behind a *manual*
+ dispatch on a branch is an explicit choice, not the silent PR/push pollution
+ this rule guards against;
+ 2. the step ``if:`` gates it to the default branch — ``github.ref ==
+ 'refs/heads/<default>'``, ``ref_name == '<default>'``, or (only when the
+ workflow's own ``push:`` trigger is default-branch-only) ``event_name ==
+ 'push'``;
+ 3. the cache key embeds a per-PR/branch/run id (e.g.
+ ``github.event.pull_request.number``) — it's deliberately unique, not a
+ shared cache that fragmented.
+
+Scans ``.github/workflows/**`` and ``.github/actions/*/action.yml`` — cache
+writes live in both (the shared ``pnpm-install`` action saves the store, and
+un-gating it would leak from every workflow that uses it). Composite actions have
+no triggers, so they run wherever called: condition 1 never applies to them.
+"""
+
+from __future__ import annotations
+
+import yaml
+from hogli.manifest import REPO_ROOT
+
+from ..check import CheckResult, Issue, WorkflowCheck
+from ..model import Workflow
+
+DEFAULT_BRANCHES = ("master", "main")
+
+# setup actions whose `cache:` input enables an ungatable post-save
+SETUP_CACHE_ACTIONS = (
+ "actions/setup-node",
+ "actions/setup-python",
+ "actions/setup-go",
+ "actions/setup-java",
+ "actions/setup-dotnet",
+ "actions/setup-ruby",
+)
+
+# triggers whose runs can land on a non-default ref (workflow_dispatch is excluded
+# on purpose — see module docstring, condition 1)
+BRANCH_REF_TRIGGERS = frozenset({"pull_request", "pull_request_target", "merge_group", "workflow_call"})
+
+# step `if:` substrings (whitespace-stripped) that pin a write to the default branch.
+# Positive `==` only, so a negation like `github.ref != 'refs/heads/master'` (which runs
+# on branches) isn't mistaken for a gate.
+GATE_MARKERS = tuple(f"=='refs/heads/{b}'" for b in DEFAULT_BRANCHES) + tuple(
+ f"ref_name=='{b}'" for b in DEFAULT_BRANCHES
+)
+
+# cache-key substrings that make the entry deliberately unique per ref/PR/run
+PER_REF_KEY_MARKERS = (
+ "github.event.pull_request.number",
+ "github.event.number",
+ "github.head_ref",
+ "github.ref_name",
+ "github.run_id",
+)
+
+
+def _triggers(on: object) -> dict:
+ if isinstance(on, str):
+ return {on: None}
+ if isinstance(on, list):
+ return dict.fromkeys(on)
+ if isinstance(on, dict):
+ return on
+ return {}
+
+
+def _push_is_default_only(cfg: object) -> bool:
+ # bare `push:` (no filter) runs on every branch push — can leak
+ if not isinstance(cfg, dict):
+ return False
+ branches = cfg.get("branches")
+ if branches:
+ return all(b in DEFAULT_BRANCHES for b in branches)
+ # push restricted to tags only (release pushes) — treat as default-scoped
+ return bool(cfg.get("tags"))
+
+
+def _can_run_on_branch_ref(on: object) -> bool:
+ for name, cfg in _triggers(on).items():
+ if name in BRANCH_REF_TRIGGERS:
+ return True
+ if name == "push" and not _push_is_default_only(cfg):
+ return True
+ return False
+
+
+def _push_trigger_is_default_only(on: object) -> bool:
+ """Whether `event_name == 'push'` is a real master-only gate here.
+
+ True when the workflow has no push trigger, or its push is default-only.
+ """
+ triggers = _triggers(on)
+ if "push" not in triggers:
+ return True
+ return _push_is_default_only(triggers["push"])
+
+
+def _write_kind(step: dict) -> str | None:
+ uses = str(step.get("uses") or "")
+ if uses.startswith("actions/cache/restore@"):
+ return None
+ if uses.startswith("actions/cache/save@"):
+ return "cache/save"
+ if uses.startswith("actions/cache@"):
+ return "cache (combined)"
+ if uses.startswith(SETUP_CACHE_ACTIONS) and (step.get("with") or {}).get("cache"):
+ return "setup auto-cache"
+ return None
+
+
+def _clause_pins_to_default(clause: str, push_is_default_only: bool) -> bool:
+ if any(marker in clause for marker in GATE_MARKERS):
+ return True
+ # `event_name == 'push'` only pins to the default branch when push can't fire on a branch
+ return push_is_default_only and "event_name=='push'" in clause
+
+
+def _is_gated(step: dict, push_is_default_only: bool) -> bool:
+ cond = str(step.get("if") or "").replace(" ", "")
+ if not cond:
+ return False
+ # an `||` lets the step also run on the other operand, so EVERY alternative must
+ # independently pin to the default branch — `master || event_name == 'pull_request'`
+ # is not a gate, but `master || main` is
+ return all(_clause_pins_to_default(part, push_is_default_only) for part in cond.split("||"))
+
+
+def _key_is_per_ref(step: dict) -> bool:
+ key = str((step.get("with") or {}).get("key") or "").replace(" ", "")
+ return any(marker in key for marker in PER_REF_KEY_MARKERS)
+
+
+def _violation_kind(step: dict, push_is_default_only: bool) -> str | None:
+ """The write kind if this step is an unsafe cache write, else None."""
+ kind = _write_kind(step)
+ if kind is None:
+ return None
+ # setup-* auto-caches can't be gated; everything else is fine once gated or per-ref
+ if kind != "setup auto-cache" and (_is_gated(step, push_is_default_only) or _key_is_per_ref(step)):
+ return None
+ return kind
+
+
+def _composite_action_steps() -> list[tuple[str, dict]]:
+ """(`relative path`, raw step) for every step in every composite action.
+
+ Composite actions run wherever they're called, so all their cache writes must
+ be gated regardless of the calling workflow.
+ """
+ actions_dir = REPO_ROOT / ".github" / "actions"
+ out: list[tuple[str, dict]] = []
+ if not actions_dir.exists():
+ return out
+ for path in sorted(actions_dir.glob("*/action.yml")):
+ try:
+ doc = yaml.safe_load(path.read_text())
+ except yaml.YAMLError:
+ continue
+ runs = doc.get("runs") if isinstance(doc, dict) else None
+ steps = runs.get("steps") if isinstance(runs, dict) else None
+ if not isinstance(steps, list):
+ continue
+ rel = path.relative_to(REPO_ROOT).as_posix()
+ out.extend((rel, step) for step in steps if isinstance(step, dict))
+ return out
+
+
+class CacheWriteGateCheck(WorkflowCheck):
+ id = "WF006-cache-writes"
+ label = "Cache write gating"
+ description = "cache writes can't land on a branch ref (gated to the default branch, per-ref keyed, or in a default-only workflow)"
+
+ @property
+ def fix_hint(self) -> str | None:
+ return (
+ "Make the cache write safe one of these ways:\n"
+ " - gate the save to the default branch: `if: github.ref == 'refs/heads/master'`\n"
+ " - replace a setup-* `cache:` input with an explicit restore + gated save\n"
+ " (see .github/actions/pnpm-install/action.yml)\n"
+ " - if the cache is meant to be per-PR, key it on github.event.pull_request.number"
+ )
+
+ def run(self, workflows: list[Workflow]) -> CheckResult:
+ result = CheckResult()
+ for wf in workflows:
+ if not _can_run_on_branch_ref(wf.on):
+ continue
+ push_default_only = _push_trigger_is_default_only(wf.on)
+ for job in wf.jobs:
+ for step in job.steps:
+ kind = _violation_kind(step.raw, push_default_only)
+ if kind is not None:
+ result.issues.append(
+ Issue(
+ workflow=wf.path.name,
+ message=f"{kind} can land on a non-default branch ref",
+ file=str(wf.path),
+ job=job.name,
+ step=str(step.raw.get("name") or step.ref),
+ )
+ )
+ for rel, step in _composite_action_steps():
+ kind = _violation_kind(step, push_is_default_only=False)
+ if kind is not None:
+ result.issues.append(
+ Issue(
+ workflow=rel,
+ message=f"{kind} can land on a non-default branch ref (composite action runs wherever it's called)",
+ file=rel,
+ step=str(step.get("name") or "<unnamed>"),
+ )
+ )
+ return result