:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(ci): migrate product ownership from CODEOWNERS to product.yaml (#57971)
Julian Bez0e61ac210d2a
diff --git a/.github/CODEOWNERS-soft b/.github/CODEOWNERS-softindex e7ce93f07e65..128651bc8d5d 100644--- a/.github/CODEOWNERS-soft+++ b/.github/CODEOWNERS-soft@@ -1,4 +1,9 @@# If a file is set here, then PRs will tag for the team's approval but will not block PRs.+#+# For top-level product ownership (`products/<name>/**`), prefer setting `owners`+# in `products/<name>/product.yaml` — the auto-assigner reads those files and+# applies them as soft codeowners. This file is for sub-folder overrides,+# secondary reviewers, and ownership of paths outside `products/`.# Surveys - owned by @PostHog/team-surveysfrontend/src/scenes/settings/environment/SurveySettings.tsx @PostHog/team-surveys@@ -36,7 +41,6 @@ nodejs/src/session-replay/shared/ @PostHog/team-replay @PostHog/team-ingestionposthog/cdp/** @PostHog/team-workflows# Web Analytics - owned by @PostHog/team-web-analytics-products/web_analytics/** @PostHog/team-web-analyticsfrontend/src/scenes/web-analytics/** @PostHog/team-web-analyticsposthog/hogql_queries/web_analytics/** @PostHog/team-web-analyticsfrontend/src/toolbar/web-vitals/** @PostHog/team-web-analytics@@ -100,15 +104,13 @@ frontend/src/scenes/data-warehouse/\*\* @PostHog/team-data-stackposthog/management/commands/generate_source_configs.py @PostHog/team-warehouse-sourcesposthog/settings/data_warehouse.py @PostHog/team-data-stackfrontend/src/scenes/models/** @PostHog/team-data-modeling-products/data_modeling/** @PostHog/team-data-modelingposthog/temporal/data_modeling/** @PostHog/team-data-modeling# HogQL - owned by @PostHog/team-data-tools# and also hard owned by the @PostHog/hogql on `CODEOWNERS` fileposthog/hogql/\*\* @PostHog/team-data-tools-# Logs/Metrics/Tracing - owned by @PostHog/logs-products/logs/** @PostHog/logs+# Tracing/Metrics — owned by @PostHog/logs (logs itself comes from products/logs/product.yaml)products/tracing/** @PostHog/logsproducts/metrics/** @PostHog/logs@@ -205,6 +207,3 @@ docs/published/developing-locally.md @PostHog/team-devexposthog/api/documentation.py @PostHog/team-devexposthog/api/mixins.py @PostHog/team-devexposthog/management/commands/find_enum_collisions.py @PostHog/team-devex--# Visual Review - owned by @PostHog/team-devex-products/visual_review/** @PostHog/team-devexdiff --git a/.github/scripts/assign-reviewers.js b/.github/scripts/assign-reviewers.jsindex 1ba14370d14a..0b0e08653133 100644--- a/.github/scripts/assign-reviewers.js+++ b/.github/scripts/assign-reviewers.js@@ -31,6 +31,90 @@ function parseCodeowners(codeownersPath) {return rules}+// Minimal parser for the `owners:` list in products/<name>/product.yaml.+// We don't depend on a YAML library because this script runs from a bare CI+// checkout; the schema is simple and validated elsewhere by hogli.+function parseOwnersFromProductYaml(content) {+ const owners = []+ let inOwners = false++ for (const rawLine of content.split('\n')) {+ const line = rawLine.replace(/\s+#.*$/, '').trimEnd()++ // Skip blank lines and full-line comments — neither should terminate the+ // owners block. Inline comments are already stripped above; the regex+ // requires preceding whitespace, so we handle column-0 comments here.+ if (!line.trim() || /^\s*#/.test(rawLine)) {+ continue+ }++ if (/^owners\s*:\s*$/.test(line)) {+ inOwners = true+ continue+ }++ if (!inOwners) {+ continue+ }++ const listMatch = line.match(/^\s+-\s+(.+?)$/)+ if (listMatch) {+ owners.push(listMatch[1].replace(/^["']|["']$/g, '').trim())+ continue+ }++ // A new top-level key terminates the owners block.+ if (/^\S/.test(rawLine)) {+ inOwners = false+ }+ }++ return owners+}++function loadProductYamlRules(productsDir = 'products') {+ const rules = []++ if (!fs.existsSync(productsDir)) {+ return rules+ }++ const entries = fs.readdirSync(productsDir, { withFileTypes: true })++ for (const entry of entries) {+ if (!entry.isDirectory()) {+ continue+ }++ const yamlPath = `${productsDir}/${entry.name}/product.yaml`+ if (!fs.existsSync(yamlPath)) {+ continue+ }++ const content = fs.readFileSync(yamlPath, 'utf8')+ const slugs = parseOwnersFromProductYaml(content)++ const owners = []+ for (const slug of slugs) {+ // Guard against slugs that already include an `@` prefix — otherwise+ // we'd build `@PostHog/@PostHog/team-foo`, which GitHub silently+ // refuses to resolve and reviewer assignment is dropped.+ if (!slug || slug === 'team-CHANGEME' || slug.startsWith('@')) {+ continue+ }+ owners.push(`@PostHog/${slug}`)+ }++ if (owners.length === 0) {+ continue+ }++ rules.push({ pattern: `${productsDir}/${entry.name}/**`, owners })+ }++ return rules+}+function globToRegex(pattern) {let regex = pattern.replace(/[.+^${}()|[\]\\]/g, '\\$&')@@ -116,7 +200,10 @@ function parseOwners(owners) {async function getReviewersForChangedFiles() {const codeownersPath = '.github/CODEOWNERS-soft'- const rules = parseCodeowners(codeownersPath)+ // products/<name>/product.yaml is the source of truth for product team+ // ownership; we layer those rules on top of CODEOWNERS-soft so the file+ // only needs to carry sub-folder overrides and secondary reviewers.+ const rules = [...parseCodeowners(codeownersPath), ...loadProductYamlRules()]const changedFiles = await getChangedFiles()console.info(`Found ${changedFiles.length} changed files:`)