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): give mypy the big runner when a pr changes its cache key (#125003)

Julian Bez9f919a1385f4
diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml
index 9257d3f88378..689f3cba1482 100644
--- a/.github/workflows/ci-python.yml
+++ b/.github/workflows/ci-python.yml
@@ -68,6 +68,7 @@ jobs:
stamphog: ${{ steps.filter.outputs.stamphog || 'true' }}
bin_scripts: ${{ steps.filter.outputs.bin_scripts || 'true' }}
api_ratchet: ${{ steps.filter.outputs.api_ratchet || 'true' }}
+ mypy_cache_key: ${{ steps.filter.outputs.mypy_cache_key || 'false' }}
steps:
# For pull requests it's not necessary to checkout the code, but we
# also want this to run on master so we need to checkout
@@ -103,6 +104,12 @@ jobs:
- 'posthog/**/*.py'
- 'ee/**/*.py'
- 'products/**/*.py'
+ # The files the mypy cache key hashes. A change to them can leave the
+ # restored cache stale for most modules, for example a django-stubs bump.
+ mypy_cache_key:
+ - 'uv.lock'
+ - '**/pyproject.toml'
+ - '**/mypy.ini'
python:
# ruff/mypy/ty run repo-wide (`.`) in code-quality, so any Python
# file anywhere must trigger this workflow — otherwise an unformatted
@@ -246,8 +253,9 @@ jobs:
timeout-minutes: 30
name: Python code quality (depot-ubuntu-24.04)
- # Master and the merge queue run mypy cold after a dependency change, which needs more than 8 GB.
- runs-on: ${{ github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/') && 'depot-ubuntu-24.04' || 'depot-ubuntu-24.04-4' }}
+ # Master and the merge queue run mypy cold after a dependency change, which needs more than 8 GB. A pull
+ # request that changes the cache key can also run nearly cold, so it gets the big runner too.
+ runs-on: ${{ github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/') && needs.changes.outputs.mypy_cache_key != 'true' && 'depot-ubuntu-24.04' || 'depot-ubuntu-24.04-4' }}
# Read by shell guards on the pytest steps below. Those steps sit in a
# `parallel:` block, where step-level `if:` is untested in this repo.
env: