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.

perf(ci): restrict pnpm cache writes to master branch only (#59364)

mendral-app[bot]fcd5532383cf
diff --git a/.github/workflows/ci-docs-check.yml b/.github/workflows/ci-docs-check.yml
index 933f1d8cbf1b..cc96691d4354 100644
--- a/.github/workflows/ci-docs-check.yml
+++ b/.github/workflows/ci-docs-check.yml
@@ -57,10 +57,19 @@ 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-docs-check.yml
+
+ - 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'
diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.yml
index d0566024eece..fb3de63ae5aa 100644
--- a/.github/workflows/ci-frontend.yml
+++ b/.github/workflows/ci-frontend.yml
@@ -119,16 +119,30 @@ 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-frontend.yml
+
+ - 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/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: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Check formatting with oxfmt
run: pnpm run format:frontend:check
@@ -167,16 +181,30 @@ 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-frontend.yml
+
+ - 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/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: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Build products
run: pnpm --filter=@posthog/frontend build:products
@@ -258,16 +286,30 @@ 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-frontend.yml
+
+ - 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/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: Restore .typegen cache
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
@@ -341,14 +383,28 @@ 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-frontend.yml
+
+ - 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
+ with:
+ path: ${{ steps.pnpm-store.outputs.path }}
+ key: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Test with Jest
run: bin/turbo run test --filter=@posthog/frontend -- --maxWorkers=2
env:
diff --git a/.github/workflows/ci-storybook.yml b/.github/workflows/ci-storybook.yml
index 9d494d0122ee..c00d5c5b55fb 100644
--- a/.github/workflows/ci-storybook.yml
+++ b/.github/workflows/ci-storybook.yml
@@ -258,14 +258,28 @@ 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-storybook.yml
+
+ - 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/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: node-cache-${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Download Storybook build artifact
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
@@ -386,10 +400,17 @@ 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-storybook.yml
+
+ - 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 dependencies
run: pnpm --filter=@posthog/storybook... install --frozen-lockfile