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): derive frontend CI Node-workspace exclusion from pnpm-workspace.yaml (#65138)

Julian Bezc8a172cc0b6a
diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.yml
index c08680565ca9..11862677a1b8 100644
--- a/.github/workflows/ci-frontend.yml
+++ b/.github/workflows/ci-frontend.yml
@@ -37,16 +37,16 @@ jobs:
# carries real code changes. The aggregator (frontend_tests) treats skips as success.
outputs:
# AND the broad filter with `exclude` (below): a PR that touches only
- # the Node-only agent-platform services/packages must not trigger
- # frontend CI — they have their own suite (ci-agents.yml) and are
- # excluded from jest (frontend/jest.config.ts) and the bundle.
+ # Node-only product workspaces (their own ci-agents.yml suite, no stories,
+ # nothing in the bundle) must not trigger frontend CI. The excluded dirs are
+ # derived from pnpm-workspace.yaml, not hardcoded — see the exclude step.
frontend: >-
${{ (steps.filter.outputs.frontend || 'true') == 'true'
- && (steps.exclude.outputs.outside_non_frontend_ts || 'true') == 'true'
+ && (steps.exclude.outputs.outside_node_product_workspaces || 'true') == 'true'
&& steps.baseline_push.outputs.result != 'true' }}
frontend_code: >-
${{ (steps.filter.outputs.frontend_code || 'true') == 'true'
- && (steps.exclude.outputs.outside_non_frontend_ts || 'true') == 'true'
+ && (steps.exclude.outputs.outside_node_product_workspaces || 'true') == 'true'
&& steps.baseline_push.outputs.result != 'true' }}
steps:
# For pull requests it's not necessary to check out the code, but we
@@ -153,28 +153,31 @@ jobs:
echo "result=$result" >>"$GITHUB_OUTPUT"
echo "Visual Review baseline-only push: $result"
- # Dirs that match the broad `frontend` rules above but aren't frontend
- # code — Node-only TS that has its own suite (ci-agents.yml) and isn't in
- # jest or the bundle. Appending a plain `!...` negation to the rules above
- # wouldn't help: dorny's default `some` quantifier OR-matches predicates,
- # so the broad `products/**/*.ts` rule still matches and the negation is
- # neutralized (same gotcha documented in
- # ci-migrations-service-separation-check.yml). A separate step is required
- # because `predicate-quantifier` is step-level: with `every`, this filter
- # is true only when some changed file lives OUTSIDE every excluded dir.
- # AND-ed into the outputs above so a PR touching only these dirs skips
- # frontend CI. To exclude another non-frontend dir, add a `!` line below —
- # the outputs reference this one filter, so they don't need to change.
+ # The broad `products/**/*.ts(x)` rules above correctly match all product
+ # frontend code (which doesn't always live under frontend/ — see
+ # products/games, products/data_warehouse, products/ai_observability/shared),
+ # but they also match product dirs that are their own Node services
+ # (products/agent_platform/services/**) with their own ci-agents.yml suite and
+ # nothing in the bundle. Exclude those so a PR touching only them skips frontend
+ # CI. The excluded dirs are derived from pnpm-workspace.yaml (the product paths
+ # that declare nested pnpm workspaces) rather than hardcoded, so a new product's
+ # services are excluded automatically — see bin/frontend-exclude-filter.
+ #
+ # A separate `every`-quantifier step is required: appending a plain `!...` to the
+ # broad filter wouldn't work because dorny's default `some` quantifier OR-matches
+ # predicates and neutralizes the negation (same gotcha as
+ # ci-migrations-service-separation-check.yml). With `every`, the filter is true
+ # only when some changed file lives OUTSIDE every excluded dir.
+ - name: Derive Node-only product workspace exclusions
+ if: github.event_name != 'push'
+ run: bin/frontend-exclude-filter > "$RUNNER_TEMP/frontend-exclude.yml"
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: exclude
if: github.event_name != 'push'
with:
token: ${{ steps.app-token.outputs.token || github.token }}
predicate-quantifier: 'every'
- filters: |
- outside_non_frontend_ts:
- - '!products/agent_platform/services/**'
- - '!products/agent_platform/packages/**'
+ filters: ${{ runner.temp }}/frontend-exclude.yml
# Pick which jest tests to run on draft PRs by passing changed files to
# `jest --findRelatedTests` (jest's resolver walks the import graph for us).
diff --git a/.github/workflows/ci-storybook.yml b/.github/workflows/ci-storybook.yml
index bc1e8b779a07..ae9fb9ab9f25 100644
--- a/.github/workflows/ci-storybook.yml
+++ b/.github/workflows/ci-storybook.yml
@@ -43,13 +43,18 @@ jobs:
${{
github.event_name == 'push'
|| (steps.filter.outputs.frontend == 'true'
- && steps.exclude.outputs.outside_non_frontend_ts == 'true'
+ && steps.exclude.outputs.outside_node_product_workspaces == 'true'
&& fromJSON(steps.filter.outputs.frontend_count || '0')
> fromJSON(steps.filter.outputs.frontend_generated_count || '0')
&& steps.baseline_push.outputs.result != 'true')
}}
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
+ # Needed by the "Derive Node-only product workspace exclusions" step below,
+ # which reads pnpm-workspace.yaml + bin/frontend-exclude-filter. dorny itself
+ # needs no checkout (it diffs via the API), so this job didn't check out before.
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
@@ -109,28 +114,27 @@ jobs:
echo "result=$result" >>"$GITHUB_OUTPUT"
echo "Visual Review baseline-only push: $result"
- # The `frontend` filter's `products/**/*.{ts,tsx}` rule matches dirs that
- # aren't frontend code — Node-only TS (agent-platform services/packages)
- # with no stories and nothing in the bundle. Appending a plain `!...`
- # negation to that rule wouldn't help: dorny's default `some` quantifier
- # OR-matches predicates, so the broad rule still matches and the negation
- # is neutralized (same gotcha as the output comment above). A separate
- # step is required because `predicate-quantifier` is step-level: with
- # `every`, this filter is true only when some changed file lives OUTSIDE
- # every excluded dir. AND-ed into the `frontend` output so a PR touching
- # only these dirs skips the visual-regression suite. To exclude another
- # non-frontend dir, add a `!` line below — the output references this one
- # filter, so it doesn't need to change.
+ # The broad `products/**/*.{ts,tsx}` rule above matches all product code,
+ # including product dirs that are their own Node services
+ # (products/agent_platform/services/**) — no stories, nothing in the bundle.
+ # Exclude those so a PR touching only them skips the visual-regression suite.
+ # The excluded dirs are derived from pnpm-workspace.yaml (the product paths that
+ # declare nested pnpm workspaces), not hardcoded — see bin/frontend-exclude-filter.
+ #
+ # A separate `every`-quantifier step is required: a plain `!...` in the broad
+ # filter is neutralized by dorny's default `some` quantifier (same gotcha as the
+ # output comment above). With `every`, the filter is true only when some changed
+ # file lives OUTSIDE every excluded dir.
+ - name: Derive Node-only product workspace exclusions
+ if: github.event_name != 'push'
+ run: bin/frontend-exclude-filter > "$RUNNER_TEMP/frontend-exclude.yml"
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: exclude
if: github.event_name != 'push'
with:
token: ${{ steps.app-token.outputs.token || github.token }}
predicate-quantifier: 'every'
- filters: |
- outside_non_frontend_ts:
- - '!products/agent_platform/services/**'
- - '!products/agent_platform/packages/**'
+ filters: ${{ runner.temp }}/frontend-exclude.yml
# Build the visual-regression matrix.
# On PRs, only run chromium shards — no story currently opts into webkit snapshots
diff --git a/bin/frontend-exclude-filter b/bin/frontend-exclude-filter
new file mode 100755
index 000000000000..59d4fa99a082
--- /dev/null
+++ b/bin/frontend-exclude-filter
@@ -0,0 +1,55 @@
+#!/usr/bin/env node
+/**
+ * Emit a dorny/paths-filter filter (YAML on stdout) that excludes the Node-only
+ * product workspaces from frontend / storybook CI gating.
+ *
+ * Why: the frontend and storybook gates match all product code with a broad
+ * `products/**\/*.ts(x)` rule (correctly — product frontend doesn't always live
+ * under `frontend/`; see products/games, products/data_warehouse,
+ * products/ai_observability/shared). That broad rule also matches product dirs
+ * that are their own Node services (e.g. products/agent_platform/services) — they
+ * have their own CI (ci-agents.yml), no stories, and nothing in the bundle, so a
+ * PR touching only them should skip frontend/storybook CI.
+ *
+ * Those Node dirs are exactly the product paths that declare nested pnpm
+ * workspaces in pnpm-workspace.yaml — `products/<...>/*` entries deeper than the
+ * bare `products/*` that covers the product packages themselves. Deriving the
+ * exclusion from there means a new product's services/ are excluded automatically
+ * once added to the workspace file — no product names hardcoded in the workflows.
+ *
+ * Output (fed into dorny `filters:` with `predicate-quantifier: every`, so the
+ * filter is true only when some changed file lives OUTSIDE every excluded dir):
+ * outside_node_product_workspaces:
+ * - '!products/agent_platform/packages/**'
+ * - '!products/agent_platform/services/**'
+ */
+
+const fs = require('fs')
+const path = require('path')
+
+const REPO_ROOT = path.resolve(__dirname, '..')
+const raw = fs.readFileSync(path.join(REPO_ROOT, 'pnpm-workspace.yaml'), 'utf-8')
+
+// Match `- products/<dir>/*` workspace globs that are deeper than the bare
+// `products/*` (which covers the product packages, i.e. their frontend). The
+// captured dir is the Node workspace root to exclude.
+const dirs = new Set()
+for (const line of raw.split('\n')) {
+ const m = line.match(/^\s*-\s*['"]?(products\/[^'"\s]+)\/\*\s*['"]?\s*$/)
+ if (m) {
+ dirs.add(m[1])
+ }
+}
+
+const sorted = [...dirs].sort()
+let out = 'outside_node_product_workspaces:\n'
+if (sorted.length === 0) {
+ // No nested product workspaces — nothing to exclude; match everything so the
+ // filter is always true and never skips frontend CI.
+ out += " - '**'\n"
+} else {
+ for (const dir of sorted) {
+ out += ` - '!${dir}/**'\n`
+ }
+}
+process.stdout.write(out)
diff --git a/hogli.yaml b/hogli.yaml
index 5a5c0625088f..a88cd90c2922 100644
--- a/hogli.yaml
+++ b/hogli.yaml
@@ -955,6 +955,10 @@ tools:
bin_script: find-affected-stories
description: Compute the set of stories affected by changed files during storybook builds
hidden: true
+ ci:frontend_exclude_filter:
+ bin_script: frontend-exclude-filter
+ description: Emit the dorny paths-filter excluding Node-only product workspaces (from pnpm-workspace.yaml) for frontend/storybook CI gating
+ hidden: true
ci:insights:
click: hogli_commands.ci_insights:ci_insights
description: Show CI insights for the current repo + branch (search/view/plan subcommands)