: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 go jobs and refresh mypy cache snapshots (#102254)
Raúl Negrón-Otero5eb5eb271fcb
diff --git a/.agents/skills/authoring-ci-workflows/SKILL.md b/.agents/skills/authoring-ci-workflows/SKILL.mdindex c8e83e7ca397..35ccf42c9462 100644--- a/.agents/skills/authoring-ci-workflows/SKILL.md+++ b/.agents/skills/authoring-ci-workflows/SKILL.md@@ -349,7 +349,13 @@ The default is 6 hours — a hung job burns paid minutes silently.Route through the shared composites rather than hand-rolling `actions/cache`: `./.github/actions/pnpm-install` (single `pnpm-<os>-<lockhash>` key, restore only; `pnpm-store-cache.yml` writes it on master), `astral-sh/setup-uv` with `enable-cache: true`, Depot cache via `./.github/actions/build-n-cache-image`.One canonical key per artifact; gate saves to master or key deliberately per-ref.-PR-scoped cache writes nobody else can read just fragment the 10 GB LRU cap.++**pnpm on a `depot-*` runner uses Depot Cache, not GitHub Actions cache.** Depot transparently handles the `actions/cache` API calls made by `pnpm-install`.+`pnpm-store-cache.yml` warms two separate backends: Depot Cache on its `depot-*` matrix leg and GitHub Actions cache on its `ubuntu-*` leg.+Never use GitHub's cache API, usage total, or 10 GB limit to diagnose pnpm caching on Depot jobs, and do not propose migrating those jobs to Depot Cache: they already use it.+Inspect Depot's cache data for Depot jobs and GitHub's cache data only for GitHub-hosted jobs.+Keep the pnpm writer master-only because Depot Cache is repository-scoped and has no branch isolation.+PR-scoped writes on GitHub-hosted runners still fragment GitHub's 10 GB LRU cache.**Any job that runs `manage.py migrate` against a fresh Postgres must restore the master schema dump first**, keeping the migrate as a seconds-long top-up.A from-scratch replay of the full migration history grows with every migration merged and already costs more than most jobs' `timeout-minutes`, so an uncached migrate is a timeout that hasn't fired yet ([agent-skills cancelled at 30 min with the checks green](https://github.com/PostHog/posthog/actions/runs/32250956659/job/96061773764)).diff --git a/.github/workflows/ci-livestream.yml b/.github/workflows/ci-livestream.ymlindex f3a554065541..0adf2f550b90 100644--- a/.github/workflows/ci-livestream.yml+++ b/.github/workflows/ci-livestream.yml@@ -4,6 +4,9 @@ on:push:branches:- master+ paths:+ - '.github/workflows/ci-livestream.yml'+ - 'livestream/**'pull_request:paths:- '.github/workflows/ci-livestream.yml'@@ -24,6 +27,9 @@ jobs:steps:- name: Checkout codeuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ sparse-checkout: livestream+ sparse-checkout-cone-mode: false- name: Set up Gouses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0diff --git a/.github/workflows/ci-phrocs.yml b/.github/workflows/ci-phrocs.ymlindex 96558addbbf8..52df1235a1a4 100644--- a/.github/workflows/ci-phrocs.yml+++ b/.github/workflows/ci-phrocs.yml@@ -4,6 +4,9 @@ on:push:branches:- master+ paths:+ - '.github/workflows/ci-phrocs.yml'+ - 'tools/phrocs/**'pull_request:paths:- '.github/workflows/ci-phrocs.yml'@@ -24,11 +27,15 @@ jobs:steps:- name: Checkout codeuses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ sparse-checkout: tools/phrocs+ sparse-checkout-cone-mode: false- name: Set up Gouses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0with:go-version: '1.25.5'+ cache-dependency-path: tools/phrocs/go.sum- name: Run golangci-lintuses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0@@ -38,4 +45,4 @@ jobs:args: --timeout=5m- name: Run tests- run: cd tools/phrocs && go test -v ./...+ run: cd tools/phrocs && go test -count=1 -v ./...diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.ymlindex cc40a1eaf99d..7528d3c5e18c 100644--- a/.github/workflows/ci-python.yml+++ b/.github/workflows/ci-python.yml@@ -264,13 +264,21 @@ jobs:run: |echo "::add-matcher::.github/mypy-problem-matcher.json"+ - name: Compute mypy cache prefix+ id: mypy-cache-key+ shell: bash+ run: |+ python_version=$(python -c 'import platform; print(platform.python_version())')+ mypy_version=$(python -c 'from importlib.metadata import version; print(version("mypy"))')+ echo "prefix=mypy-v3-${{ runner.os }}-${{ runner.arch }}-${python_version}-${mypy_version}-${{ hashFiles('uv.lock', '**/pyproject.toml', '**/mypy.ini') }}" >> "$GITHUB_OUTPUT"+- name: Restore mypy cache+ id: mypy-cacheuses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3with:path: .mypy_cache- key: mypy-cache-${{ runner.os }}-3.12-mypy2-${{ hashFiles('**/pyproject.toml', '**/mypy.ini') }}- restore-keys: |- mypy-cache-${{ runner.os }}-3.12-mypy2-+ key: ${{ steps.mypy-cache-key.outputs.prefix }}-${{ github.run_id }}-${{ github.run_attempt }}+ restore-keys: ${{ steps.mypy-cache-key.outputs.prefix }}-- name: Check static typingshell: bash -e {0}@@ -279,11 +287,11 @@ jobs:run: mypy --version && mypy --cache-fine-grained .- name: Save mypy cache- if: github.ref == 'refs/heads/master'+ if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3with:path: .mypy_cache- key: mypy-cache-${{ runner.os }}-3.12-mypy2-${{ hashFiles('**/pyproject.toml', '**/mypy.ini') }}+ key: ${{ steps.mypy-cache.outputs.cache-primary-key }}- name: Check if "schema.py" is up to dateshell: bashdiff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.ymlindex 8a9b985209e0..1af4d97422b3 100644--- a/.github/workflows/ci-rust.yml+++ b/.github/workflows/ci-rust.yml@@ -341,6 +341,15 @@ jobs:cargo build "${crates[@]}" --locked --releasefind target/release/ -maxdepth 1 -executable -type f -exec strip {} ++ - name: Report sccache counters+ if: always()+ continue-on-error: true+ run: |+ if command -v sccache >/dev/null; then+ # The full report includes the cache endpoint, so allow only numeric counters.+ sccache --show-stats 2>/dev/null | awk '/^(Compile requests|Cache hits|Cache misses|Non-cacheable calls)[[:space:]]+[0-9]+$/ { print }'+ fi+test:name: Test Rust (${{ matrix.packages }})strategy:@@ -591,6 +600,15 @@ jobs:shell: bashrun: exit 1+ - name: Report sccache counters+ if: always()+ continue-on-error: true+ run: |+ if command -v sccache >/dev/null; then+ # The full report includes the cache endpoint, so allow only numeric counters.+ sccache --show-stats 2>/dev/null | awk '/^(Compile requests|Cache hits|Cache misses|Non-cacheable calls)[[:space:]]+[0-9]+$/ { print }'+ fi+# Spawns a real personhog stack (replica, writer, leaders, leader-mode# routers) against dockerized Postgres/Kafka/etcd and asserts that every# write acked by the leader path is visible afterwards — in strong reads@@ -834,6 +852,15 @@ jobs:path: rust/target/debug/harness-logs/if-no-files-found: ignore+ - name: Report sccache counters+ if: always()+ continue-on-error: true+ run: |+ if command -v sccache >/dev/null; then+ # The full report includes the cache endpoint, so allow only numeric counters.+ sccache --show-stats 2>/dev/null | awk '/^(Compile requests|Cache hits|Cache misses|Non-cacheable calls)[[:space:]]+[0-9]+$/ { print }'+ fi+linting:name: Lint Rust services (depot-ubuntu-22.04-4)needs: changes@@ -921,6 +948,15 @@ jobs:- name: Run cargo shearrun: cargo shear+ - name: Report sccache counters+ if: always()+ continue-on-error: true+ run: |+ if command -v sccache >/dev/null; then+ # The full report includes the cache endpoint, so allow only numeric counters.+ sccache --show-stats 2>/dev/null | awk '/^(Compile requests|Cache hits|Cache misses|Non-cacheable calls)[[:space:]]+[0-9]+$/ { print }'+ fi+# Collate job - single required status check for branch protection.# Individual jobs skip entirely when no Rust changes, saving runner time.rust_tests:diff --git a/tools/workflow-plan/tests/workflows.test.ts b/tools/workflow-plan/tests/workflows.test.tsindex 5750b77b3393..d3e94edbc4a1 100644--- a/tools/workflow-plan/tests/workflows.test.ts+++ b/tools/workflow-plan/tests/workflows.test.ts@@ -332,6 +332,52 @@ const namedJobs = (file: string): Set<string> =>)describe('.github/workflows run plans', () => {+ it('Phrocs executes tests even when setup-go restores a warm build cache', () => {+ const testStep = workflow('ci-phrocs.yml').jobs.test.steps?.find((step) => step.name === 'Run tests')+ expect(testStep?.run).toMatch(/\bgo test\s+-count=1\b/)+ })++ it.each([+ ['master schedule', schedule(), 'success', true],+ ['same-repo PR', pullRequest(), 'success', false],+ ['fork PR', pullRequest({ fork: true }), 'success', false],+ ['failed master typecheck', schedule(), 'failure', false],+ ] as const)('mypy cache writer on %s', (_name, github, outcome, runs) => {+ const wf = workflow('ci-python.yml')+ const plan = planWorkflow(wf, {+ name: _name,+ github,+ steps: {+ ...allFiltersChanged(wf),+ 'code-quality': { 'Check static typing': { outcome } },+ },+ })+ expect(plan.errors).toEqual([])+ expect(plan.jobs['code-quality'].steps.find((step) => step.name === 'Save mypy cache')?.runs).toBe(runs)+ })++ it.each(['success', 'failure'] as const)(+ 'sccache counters survive a %s build without changing its verdict',+ (outcome) => {+ const wf = workflow('ci-rust.yml')+ const plan = planWorkflow(wf, {+ name: outcome,+ github: pullRequest(),+ steps: {+ ...allFiltersChanged(wf),+ affected: { shards: { outputs: { matrix: '{"include":[{"packages":"common-types"}]}' } } },+ build: {+ 'Run cargo build': { outcome },+ 'Report sccache counters': { outcome: 'failure' },+ },+ },+ })+ expect(plan.errors).toEqual([])+ expect(plan.jobs.build.steps.find((step) => step.name === 'Report sccache counters')?.runs).toBe(true)+ expect(plan.jobs.build.result).toBe(outcome)+ }+ )+it.each(PINNED_WORKFLOWS)('%s names every conditional job in an expectation row', (file) => {const unnamed = Object.entries(workflow(file).jobs).filter(([id, job]) => job.if !== undefined && !namedJobs(file).has(id))