: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): narrow product matrix on schema.json changes (#59623)
Georges-Antoine Assibd27697f35de
diff --git a/.github/scripts/schema-impact.js b/.github/scripts/schema-impact.jsnew file mode 100644index 000000000000..304319d0fcf6--- /dev/null+++ b/.github/scripts/schema-impact.js@@ -0,0 +1,159 @@+// Diff `frontend/src/queries/schema.json` between base and HEAD, then map the+// changed definitions to the products that depend on them (resolved from the+// AST by schema_usage_scan.py). Used by turbo-discover.js to narrow the product+// matrix on schema-only PRs.+//+// Returns 'additive' (only new defs — nothing to retest), 'impacting' (union of+// affected products), or 'fallback' (base schema unreadable or scanner failed —+// caller tests everything).++const { execFileSync } = require('child_process')+const fs = require('fs')+const path = require('path')++const SCHEMA_PATH = 'frontend/src/queries/schema.json'+const PRODUCTS_ROOT = 'products'+const SCAN_SCRIPT = path.join(__dirname, 'schema_usage_scan.py')+// Sentinel key: products with unresolvable usage, unioned in on any change.+const WILDCARD = '*'++function readHeadSchema(schemaPath = SCHEMA_PATH) {+ try {+ return fs.readFileSync(schemaPath, 'utf-8')+ } catch {+ return null+ }+}++function readBaseSchema(scmBase, schemaPath = SCHEMA_PATH) {+ if (!scmBase) {+ return null+ }+ try {+ return execFileSync('git', ['show', `${scmBase}:${schemaPath}`], {+ encoding: 'utf-8',+ stdio: ['pipe', 'pipe', 'pipe'],+ maxBuffer: 50 * 1024 * 1024,+ })+ } catch {+ return null+ }+}++function diffDefinitions(baseRaw, headRaw) {+ const base = JSON.parse(baseRaw)+ const head = JSON.parse(headRaw)+ const baseDefs = base.definitions || {}+ const headDefs = head.definitions || {}+ const added = []+ const removed = []+ const modified = []+ for (const key of Object.keys(headDefs)) {+ if (!(key in baseDefs)) {+ added.push(key)+ } else if (JSON.stringify(baseDefs[key]) !== JSON.stringify(headDefs[key])) {+ modified.push(key)+ }+ }+ for (const key of Object.keys(baseDefs)) {+ if (!(key in headDefs)) {+ removed.push(key)+ }+ }+ return { added, removed, modified }+}++// Map<type, Set<product>> (incl. WILDCARD) from the AST scanner. Throws if no+// Python is available or the scan fails; analyzeSchemaImpact turns that into a+// conservative 'fallback'.+function buildImportMap(productsRoot = PRODUCTS_ROOT) {+ const candidates = process.env.PYTHON ? [process.env.PYTHON] : ['python3', 'python']+ let raw+ let lastErr+ for (const bin of candidates) {+ try {+ raw = execFileSync(bin, [SCAN_SCRIPT, productsRoot], {+ encoding: 'utf-8',+ stdio: ['pipe', 'pipe', 'pipe'],+ maxBuffer: 64 * 1024 * 1024,+ })+ break+ } catch (e) {+ lastErr = e+ }+ }+ if (raw === undefined) {+ throw lastErr || new Error('schema_usage_scan.py could not be executed')+ }+ const map = new Map()+ for (const [typeName, products] of Object.entries(JSON.parse(raw))) {+ map.set(typeName, new Set(products))+ }+ return map+}++function affectedProductsFor(changedTypes, importMap) {+ const products = new Set()+ const collect = (key) => {+ for (const product of importMap.get(key) || []) {+ products.add(product)+ }+ }+ for (const typeName of changedTypes) {+ collect(typeName)+ }+ // any change also pulls in products with unresolvable usage+ if (changedTypes.length > 0) {+ collect(WILDCARD)+ }+ return [...products].sort()+}++function analyzeSchemaImpact({ scmBase, schemaPath = SCHEMA_PATH, productsRoot = PRODUCTS_ROOT } = {}) {+ const fallback = (reason) => ({ kind: 'fallback', reason, affectedProducts: [] })++ const headRaw = readHeadSchema(schemaPath)+ if (headRaw === null) {+ return fallback('head-schema-missing')+ }+ const baseRaw = readBaseSchema(scmBase, schemaPath)+ if (baseRaw === null) {+ return fallback('base-schema-unavailable')+ }+ let diff+ try {+ diff = diffDefinitions(baseRaw, headRaw)+ } catch (e) {+ return fallback(`parse-error: ${e.message}`)+ }+ const impacting = [...diff.modified, ...diff.removed]+ if (impacting.length === 0) {+ return {+ kind: 'additive',+ affectedProducts: [],+ counts: { added: diff.added.length, modified: 0, removed: 0 },+ }+ }+ let importMap+ try {+ importMap = buildImportMap(productsRoot)+ } catch (e) {+ return fallback(`scanner-failed: ${e.message}`)+ }+ const affectedProducts = affectedProductsFor(impacting, importMap)+ const wildcardProducts = [...(importMap.get(WILDCARD) || [])].sort()+ return {+ kind: 'impacting',+ affectedProducts,+ wildcardProducts,+ changedTypes: impacting,+ counts: { added: diff.added.length, modified: diff.modified.length, removed: diff.removed.length },+ }+}++module.exports = {+ analyzeSchemaImpact,+ diffDefinitions,+ buildImportMap,+ affectedProductsFor,+}diff --git a/.github/scripts/schema-impact.test.js b/.github/scripts/schema-impact.test.jsnew file mode 100644index 000000000000..296491b897db--- /dev/null+++ b/.github/scripts/schema-impact.test.js@@ -0,0 +1,88 @@+// Run with: node --test .github/scripts/schema-impact.test.js+//+// JS-side: schema.json diffing, product unioning, and one end-to-end pass+// through buildImportMap. Scanner resolution is unit-tested in+// test_schema_usage_scan.py.++const test = require('node:test')+const assert = require('node:assert/strict')+const fs = require('fs')+const os = require('os')+const path = require('path')++const { diffDefinitions, affectedProductsFor, buildImportMap } = require('./schema-impact')++const schema = (defs) => JSON.stringify({ $schema: 'x', definitions: defs })++test('diffDefinitions classifies added/removed/modified', () => {+ const base = schema({ A: { type: 'object', a: 1 }, B: { type: 'string' } })+ const head = schema({ A: { type: 'object', a: 2 }, C: { type: 'number' } })+ const { added, removed, modified } = diffDefinitions(base, head)+ assert.deepEqual(added, ['C'])+ assert.deepEqual(removed, ['B'])+ assert.deepEqual(modified, ['A'])+})++test('diffDefinitions: purely additive change has empty modified+removed', () => {+ const base = schema({ A: { type: 'object' } })+ const head = schema({ A: { type: 'object' }, NewType: { type: 'string' } })+ const { added, removed, modified } = diffDefinitions(base, head)+ assert.deepEqual(added, ['NewType'])+ assert.deepEqual(removed, [])+ assert.deepEqual(modified, [])+})++test('affectedProductsFor unions products across all changed types', () => {+ const map = new Map([+ ['A', new Set(['logs'])],+ ['B', new Set(['logs', 'experiments'])],+ ['C', new Set(['surveys'])],+ ])+ assert.deepEqual(affectedProductsFor(['A', 'B'], map), ['experiments', 'logs'])+ assert.deepEqual(affectedProductsFor(['nonexistent'], map), [])+})++test('affectedProductsFor includes wildcard products on any change', () => {+ const map = new Map([+ ['A', new Set(['logs'])],+ ['*', new Set(['alerts'])],+ ])+ assert.deepEqual(affectedProductsFor(['A'], map), ['alerts', 'logs'])+ assert.deepEqual(affectedProductsFor(['Unrelated'], map), ['alerts'])+ assert.deepEqual(affectedProductsFor([], map), [])+})++test('buildImportMap resolves every import shape end-to-end (via the AST scanner)', () => {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'schema-impact-'))+ try {+ const mk = (name) => {+ const dir = path.join(root, name, 'backend')+ fs.mkdirSync(dir, { recursive: true })+ return dir+ }+ // direct symbol import+ fs.writeFileSync(path.join(mk('logs'), 'a.py'), 'from posthog.schema import LogsQuery, HogQLFilters\n')+ // `from posthog import schema` + attribute refs+ fs.writeFileSync(+ path.join(mk('product_analytics'), 'b.py'),+ 'from posthog import schema\nx = schema.InsightVizNode\ny = schema.DataVisualizationNode\n'+ )+ // `import posthog.schema` + dotted ref+ fs.writeFileSync(path.join(mk('alerts'), 'c.py'), 'import posthog.schema\ns = posthog.schema.AlertState["FIRING"]\n')+ // module bound but used dynamically → wildcard+ fs.writeFileSync(path.join(mk('mystery'), 'd.py'), 'from posthog import schema\nregister(schema)\n')+ // noise: no schema usage at all+ fs.writeFileSync(path.join(mk('noise'), 'e.py'), 'import os\n')++ const map = buildImportMap(root)+ assert.deepEqual([...map.get('LogsQuery')], ['logs'])+ assert.deepEqual([...map.get('HogQLFilters')], ['logs'])+ assert.deepEqual([...map.get('InsightVizNode')], ['product-analytics'])+ assert.deepEqual([...map.get('DataVisualizationNode')], ['product-analytics'])+ assert.deepEqual([...map.get('AlertState')], ['alerts'])+ assert.deepEqual([...map.get('*')], ['mystery'])+ assert.equal(map.has('NeverImported'), false)+ } finally {+ fs.rmSync(root, { recursive: true, force: true })+ }+})diff --git a/.github/scripts/schema_usage_scan.py b/.github/scripts/schema_usage_scan.pynew file mode 100644index 000000000000..ebaa812901f0--- /dev/null+++ b/.github/scripts/schema_usage_scan.py@@ -0,0 +1,132 @@+#!/usr/bin/env python3+"""Map posthog.schema types to the products that depend on them.++Parses every ``<products_root>/**/*.py`` with ``ast`` and prints a JSON object+of type name → sorted product list. Products whose usage can't be resolved to+concrete types (star import, dynamic access, parse failure) land under the+``"*"`` wildcard key, which the caller treats as affected by any schema change.+"""++from __future__ import annotations++import ast+import sys+import json+from collections import Counter, defaultdict+from pathlib import Path++WILDCARD = "*"+SCHEMA_MODULE = "posthog.schema"+++def _product_name(rel_path: Path) -> str | None:+ # hyphenated to match @posthog/products-<name>+ parts = rel_path.parts+ if not parts:+ return None+ return parts[0].replace("_", "-")+++class _SchemaUsageVisitor(ast.NodeVisitor):+ """Resolve posthog.schema type references within a single module."""++ def __init__(self) -> None:+ self.types: set[str] = set()+ self.module_aliases: set[str] = set() # names bound to posthog.schema (e.g. `schema`, `ps`)+ self.posthog_pkg = False # `import posthog[.schema]` → resolve `posthog.schema.Foo`+ self.star_import = False+ self._alias_uses: Counter[str] = Counter() # every reference to an alias+ self._alias_attr_uses: Counter[str] = Counter() # references of the form `alias.Type`++ def visit_ImportFrom(self, node: ast.ImportFrom) -> None:+ if node.module == SCHEMA_MODULE:+ for alias in node.names:+ if alias.name == "*":+ self.star_import = True+ else:+ # schema.json keys are the original names, not local aliases+ self.types.add(alias.name)+ elif node.module == "posthog":+ for alias in node.names:+ if alias.name == "schema":+ self.module_aliases.add(alias.asname or "schema")+ self.generic_visit(node)++ def visit_Import(self, node: ast.Import) -> None:+ for alias in node.names:+ if alias.name == SCHEMA_MODULE:+ if alias.asname:+ self.module_aliases.add(alias.asname)+ else:+ self.posthog_pkg = True+ elif alias.name == "posthog" and alias.asname is None:+ self.posthog_pkg = True+ self.generic_visit(node)++ def visit_Attribute(self, node: ast.Attribute) -> None:+ value = node.value+ # posthog.schema.Foo+ if (+ self.posthog_pkg+ and isinstance(value, ast.Attribute)+ and value.attr == "schema"+ and isinstance(value.value, ast.Name)+ and value.value.id == "posthog"+ ):+ self.types.add(node.attr)+ # alias.Foo+ elif isinstance(value, ast.Name) and value.id in self.module_aliases:+ self.types.add(node.attr)+ self._alias_attr_uses[value.id] += 1+ self.generic_visit(node)++ def visit_Name(self, node: ast.Name) -> None:+ if node.id in self.module_aliases:+ self._alias_uses[node.id] += 1+ self.generic_visit(node)++ @property+ def is_wildcard(self) -> bool:+ # opaque if a star import, or an alias is ever used bare rather than as `alias.Type`+ return self.star_import or any(self._alias_uses[a] > self._alias_attr_uses[a] for a in self.module_aliases)+++def scan(products_root: str) -> dict[str, list[str]]:+ root = Path(products_root)+ type_to_products: dict[str, set[str]] = defaultdict(set)+ for path in sorted(root.rglob("*.py")):+ product = _product_name(path.relative_to(root))+ if product is None:+ continue+ try:+ source = path.read_text(encoding="utf-8")+ except (OSError, UnicodeDecodeError):+ type_to_products[WILDCARD].add(product)+ continue+ # every relevant form contains "schema" — skip the rest cheaply+ if "schema" not in source:+ continue+ try:+ tree = ast.parse(source)+ except SyntaxError:+ type_to_products[WILDCARD].add(product)+ continue+ visitor = _SchemaUsageVisitor()+ visitor.visit(tree)+ for type_name in visitor.types:+ type_to_products[type_name].add(product)+ if visitor.is_wildcard:+ type_to_products[WILDCARD].add(product)+ return {key: sorted(products) for key, products in sorted(type_to_products.items())}+++def main(argv: list[str]) -> int:+ if len(argv) != 2:+ sys.stderr.write("usage: schema_usage_scan.py <products_root>\n")+ return 2+ json.dump(scan(argv[1]), sys.stdout)+ return 0+++if __name__ == "__main__":+ raise SystemExit(main(sys.argv))diff --git a/.github/scripts/test_schema_usage_scan.py b/.github/scripts/test_schema_usage_scan.pynew file mode 100644index 000000000000..2cc8dd92285d--- /dev/null+++ b/.github/scripts/test_schema_usage_scan.py@@ -0,0 +1,132 @@+"""Tests for the posthog.schema AST dependency scanner.++Run with: uv run --with pytest pytest .github/scripts/test_schema_usage_scan.py+"""++import textwrap+from pathlib import Path++from schema_usage_scan import scan+++def write_py(root: Path, product: str, name: str, content: str) -> None:+ path = root / product / "backend" / name+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(textwrap.dedent(content).lstrip())+++def test_direct_symbol_import(tmp_path: Path) -> None:+ write_py(tmp_path, "logs", "a.py", "from posthog.schema import LogsQuery, HogQLFilters\n")+ result = scan(str(tmp_path))+ assert result == {"HogQLFilters": ["logs"], "LogsQuery": ["logs"]}+++def test_direct_import_uses_original_name_not_alias(tmp_path: Path) -> None:+ write_py(tmp_path, "logs", "a.py", "from posthog.schema import LogsQuery as LQ\nq = LQ()\n")+ result = scan(str(tmp_path))+ assert result == {"LogsQuery": ["logs"]}+++def test_star_import_is_wildcard(tmp_path: Path) -> None:+ write_py(tmp_path, "logs", "a.py", "from posthog.schema import *\n")+ assert scan(str(tmp_path)) == {"*": ["logs"]}+++def test_from_posthog_import_schema_attribute_refs(tmp_path: Path) -> None:+ write_py(+ tmp_path,+ "product_analytics",+ "b.py",+ """+ from posthog import schema++ def build(node: schema.InsightVizNode) -> schema.DataVisualizationNode:+ return schema.DataVisualizationNode()+ """,+ )+ result = scan(str(tmp_path))+ assert result == {+ "DataVisualizationNode": ["product-analytics"],+ "InsightVizNode": ["product-analytics"],+ }+++def test_from_posthog_import_schema_aliased(tmp_path: Path) -> None:+ write_py(tmp_path, "logs", "b.py", "from posthog import schema as sch\nq = sch.TrendsQuery()\n")+ assert scan(str(tmp_path)) == {"TrendsQuery": ["logs"]}+++def test_import_posthog_schema_dotted(tmp_path: Path) -> None:+ write_py(tmp_path, "alerts", "c.py", 'import posthog.schema\ns = posthog.schema.AlertState["FIRING"]\n')+ assert scan(str(tmp_path)) == {"AlertState": ["alerts"]}+++def test_import_posthog_schema_aliased(tmp_path: Path) -> None:+ write_py(tmp_path, "logs", "c.py", "import posthog.schema as ps\nx: ps.HogQLQuery = ps.HogQLQuery()\n")+ assert scan(str(tmp_path)) == {"HogQLQuery": ["logs"]}+++def test_import_posthog_package_dotted(tmp_path: Path) -> None:+ write_py(tmp_path, "alerts", "c.py", "import posthog\nx = posthog.schema.AlertState\n")+ assert scan(str(tmp_path)) == {"AlertState": ["alerts"]}+++def test_nested_attribute_records_type_not_member(tmp_path: Path) -> None:+ write_py(tmp_path, "logs", "b.py", "from posthog import schema\nv = schema.AlertState.FIRING\n")+ assert scan(str(tmp_path)) == {"AlertState": ["logs"]}+++def test_dynamic_use_of_module_is_wildcard(tmp_path: Path) -> None:+ write_py(tmp_path, "mystery", "d.py", "from posthog import schema\nregister(schema)\n")+ assert scan(str(tmp_path)) == {"*": ["mystery"]}+++def test_reassigned_module_binding_is_wildcard(tmp_path: Path) -> None:+ write_py(tmp_path, "mystery", "d.py", "from posthog import schema\ns = schema\nx = s.LogsQuery\n")+ result = scan(str(tmp_path))+ assert result["*"] == ["mystery"]+++def test_comments_and_strings_do_not_match(tmp_path: Path) -> None:+ write_py(+ tmp_path,+ "logs",+ "a.py",+ '''+ # from posthog import schema -> schema.LogsQuery+ """Docstring mentioning schema.TrendsQuery should be ignored."""+ x = "from posthog.schema import EventsQuery"+ ''',+ )+ assert scan(str(tmp_path)) == {}+++def test_unrelated_schema_attribute_not_matched(tmp_path: Path) -> None:+ write_py(+ tmp_path,+ "logs",+ "a.py",+ """+ from posthog import schema++ config.schema.something # unrelated object, must not leak `something`+ real = schema.LogsQuery+ """,+ )+ assert scan(str(tmp_path)) == {"LogsQuery": ["logs"]}+++def test_syntax_error_is_wildcard(tmp_path: Path) -> None:+ write_py(tmp_path, "broken", "a.py", "from posthog import schema\ndef oops(:\n")+ assert scan(str(tmp_path)) == {"*": ["broken"]}+++def test_file_without_schema_is_skipped(tmp_path: Path) -> None:+ write_py(tmp_path, "logs", "a.py", "import os\nfrom posthog.models import Team\n")+ assert scan(str(tmp_path)) == {}+++def test_unioned_across_products_and_sorted(tmp_path: Path) -> None:+ write_py(tmp_path, "surveys", "a.py", "from posthog.schema import LogsQuery\n")+ write_py(tmp_path, "logs", "b.py", "from posthog import schema\nx = schema.LogsQuery\n")+ assert scan(str(tmp_path)) == {"LogsQuery": ["logs", "surveys"]}diff --git a/.github/scripts/turbo-discover.js b/.github/scripts/turbo-discover.jsindex 7deb0307be5c..81b7eb4f3c30 100644--- a/.github/scripts/turbo-discover.js+++ b/.github/scripts/turbo-discover.js@@ -14,11 +14,15 @@// Durations come from .test_durations (maintained by pytest-split).//// Input: LEGACY_CHANGED env var ("true"/"false")+// SCHEMA_CHANGED env var ("true"/"false") — when set and LEGACY_CHANGED+// is false, schema-impact.js narrows the matrix to products that+// depend on the affected posthog.schema types.// Output: JSON on stdout: { matrix, run_legacy, django_shards }// Diagnostics on stderrconst { execFileSync } = require('child_process')const fs = require('fs')+const { analyzeSchemaImpact } = require('./schema-impact')// --- Product shard sizing (same Amdahl shape as Django below) ---// Each product is atomic for packing, but unlike Django the test pool isn't@@ -314,6 +318,7 @@ function buildMatrix(products, durations) {// --- Main ---const legacyChanged = process.env.LEGACY_CHANGED === 'true'+const schemaChanged = process.env.SCHEMA_CHANGED === 'true'let allTestTasks, affectedTestTasks, affectedContractTasks, contractTaskstry {@@ -376,6 +381,30 @@ if (legacyChanged) {products = []runLegacy = false}++ if (schemaChanged) {+ const impact = analyzeSchemaImpact({ scmBase: process.env.TURBO_SCM_BASE })+ console.error(`Schema impact: ${JSON.stringify({ kind: impact.kind, counts: impact.counts, reason: impact.reason })}`)+ if (impact.kind === 'fallback') {+ console.error(`Schema diff unavailable (${impact.reason}) — falling back to all products + Django`)+ products = allProducts+ runLegacy = true+ } else {+ if (impact.kind === 'impacting') {+ console.error(`Schema-affected products: ${JSON.stringify(impact.affectedProducts)}`)+ if (impact.wildcardProducts && impact.wildcardProducts.length > 0) {+ console.error(+ `Products with unresolved schema module imports (always tested): ${JSON.stringify(impact.wildcardProducts)}`+ )+ }+ products = [...new Set([...products, ...impact.affectedProducts])].sort()+ } else {+ console.error('Schema change is purely additive — no extra products needed')+ }+ // Core (posthog/, ee/, etc.) imports schema heavily; always run Django on schema changes.+ runLegacy = true+ }+ }}console.error(`Products to test: ${JSON.stringify(products)}`)diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex 452ff3d50fe4..718cdf00e659 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -75,6 +75,7 @@ jobs:tasks_temporal: ${{ steps.filter.outputs.tasks_temporal || 'true' }}openapi_types: ${{ steps.filter.outputs.openapi_types || 'true' }}legacy: ${{ steps.filter.outputs.legacy || 'true' }}+ schema: ${{ steps.filter.outputs.schema || 'true' }}product_yamls: ${{ steps.filter.outputs.product_yamls || 'false' }}product_yamls_files: ${{ steps.filter.outputs.product_yamls_files }}timing_scripts: ${{ steps.filter.outputs.timing_scripts }}@@ -192,7 +193,6 @@ jobs:- mypy.ini- pytest.ini- .test_durations- - frontend/src/queries/schema.json- frontend/src/products.json- 'products/*/manifest.tsx'- rust/feature-flags/src/properties/property_models.rs@@ -205,6 +205,11 @@ jobs:- bin/ci-wait-for-docker- frontend/public/email/*- 'docker/clickhouse/**'+ schema:+ # Tracked separately from `legacy` so turbo-discover can+ # diff schema.json and narrow the product matrix to+ # products that import the changed types.+ - frontend/src/queries/schema.jsonmigrations:- 'docker/clickhouse/**'- 'posthog/migrations/*.py'@@ -348,6 +353,7 @@ jobs:# On pushes to master, always run everything.# On PRs, use the path filter to detect legacy changes.LEGACY_CHANGED: ${{ github.event_name != 'pull_request' || needs.changes.outputs.legacy }}+ SCHEMA_CHANGED: ${{ github.event_name != 'pull_request' || needs.changes.outputs.schema }}TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.event.pull_request.base.ref) || '' }}TURBO_SCM_HEAD: ${{ github.sha }}run: |diff --git a/.github/workflows/ci-scripts.yml b/.github/workflows/ci-scripts.ymlnew file mode 100644index 000000000000..40412d3cde3d--- /dev/null+++ b/.github/workflows/ci-scripts.yml@@ -0,0 +1,47 @@+name: Script tests++# Unit tests for the helper scripts in .github/scripts that gate CI decisions+# (e.g. schema-impact narrowing). Without this, a regression in the narrowing+# logic could silently skip affected product tests.+on:+ pull_request:+ paths:+ - .github/scripts/**+ - .github/workflows/ci-scripts.yml++concurrency:+ group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}++permissions:+ contents: read++jobs:+ script-tests:+ name: .github/scripts unit tests+ runs-on: ubuntu-latest+ timeout-minutes: 5+ steps:+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2++ - name: Setup Node.js+ uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0+ with:+ node-version-file: .nvmrc++ - name: Setup Python+ uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0+ with:+ python-version-file: pyproject.toml++ - name: Install pytest+ run: python -m pip install --quiet pytest++ # `-c /dev/null` skips the repo pytest.ini (its --reuse-db addopt needs+ # pytest-django, which we don't install here).+ - name: Schema-usage scanner tests (Python)+ run: python -m pytest .github/scripts/test_schema_usage_scan.py -v -c /dev/null -p no:cacheprovider++ # Shells out to schema_usage_scan.py via python3 (preinstalled on ubuntu).+ - name: Schema-impact tests (Node)+ run: node --test .github/scripts/schema-impact.test.js