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(ci): add depot ci-backend shadow for timing trial (#53803)

Raúl Negrón-Otero5f07422978a3
diff --git a/.depot/actions/setup-sqlx-cli/action.yml b/.depot/actions/setup-sqlx-cli/action.yml
new file mode 100644
index 000000000000..6834ce95e689
--- /dev/null
+++ b/.depot/actions/setup-sqlx-cli/action.yml
@@ -0,0 +1,52 @@
+name: Setup sqlx-cli
+description: |
+ Installs sqlx-cli and adds it to PATH.
+ Uses actions/cache to avoid recompiling from source on every run.
+ The binary is pinned to a specific version for reproducibility.
+
+inputs:
+ version:
+ description: 'sqlx-cli version to install (e.g. 0.8.0)'
+ required: false
+ default: '0.8.0'
+
+runs:
+ using: composite
+ steps:
+ - name: Restore sqlx-cli binary from cache
+ id: cache-sqlx-cli
+ uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
+ with:
+ path: ${{ runner.temp }}/sqlx-cli
+ key: sqlx-cli-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}
+
+ - name: Build sqlx-cli on cache miss
+ if: steps.cache-sqlx-cli.outputs.cache-hit != 'true'
+ shell: bash
+ env:
+ SQLX_CLI_VERSION: ${{ inputs.version }}
+ run: |
+ set -euo pipefail
+ echo "Cache miss — building sqlx-cli v$SQLX_CLI_VERSION from source"
+
+ cargo install sqlx-cli \
+ --version "$SQLX_CLI_VERSION" \
+ --features postgres \
+ --no-default-features \
+ --locked \
+ --root "$RUNNER_TEMP/sqlx-cli"
+
+ chmod +x "$RUNNER_TEMP/sqlx-cli/bin/sqlx"
+
+ - name: Save sqlx-cli binary to cache
+ if: steps.cache-sqlx-cli.outputs.cache-hit != 'true' && github.ref == 'refs/heads/master'
+ uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
+ with:
+ path: ${{ runner.temp }}/sqlx-cli
+ key: sqlx-cli-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}
+
+ - name: Add sqlx-cli to PATH
+ shell: bash
+ run: |
+ echo "$RUNNER_TEMP/sqlx-cli/bin" >> "$GITHUB_PATH"
+ "$RUNNER_TEMP/sqlx-cli/bin/sqlx" --version
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
new file mode 100644
index 000000000000..baac50f68f13
--- /dev/null
+++ b/.depot/workflows/ci-backend.yml
@@ -0,0 +1,1294 @@
+# Depot CI shadow of .github/workflows/ci-backend.yml. Lives under .depot/ so
+# GitHub Actions ignores it; only Depot CI parses this file. Statuses posted
+# from here are non-blocking; canonical is the authoritative signal.
+#
+# Apples-to-apples is the whole point — keep action pins, env vars, runner
+# sizes, and pytest flags in sync with the canonical workflow. A drift-check
+# job in .github/workflows/ci-backend-shadow-drift.yml fails when canonical
+# changes without a matching depot bump.
+#
+# Intentional deltas vs canonical:
+# - runs-on: depot-* labels instead of ubuntu-latest
+# - action paths: ./.depot/actions/... instead of ./.github/actions/...
+# - permissions: pull-requests:read (no comment/auto-commit side effects)
+# - Stripped side effects: artifact uploads, PR comment posters, snapshot
+# auto-commit (handle-snapshots), OpenAPI auto-commit, app-token issuance,
+# posthog-github-action telemetry, --store-durations, test-selection verdict
+# - actions/cache reads/writes route to Depot Cache, not GitHub Actions Cache,
+# so shared keys with canonical (schema, rust-cache, uv, pnpm) do not collide
+# - Three data-modeling tests deselected (Depot-only MinIO 403 quarantine)
+# - GITHUB_TOKEN / OTEL_SERVICE_NAME neutralized (ambient on Depot, not on GHA)
+# - Path-filter persons-SQL folded into migrations; product_yamls dropped
+
+# This workflow runs all of our backend django tests.
+#
+# If these tests get too slow, look at increasing concurrency and re-timing the tests by manually dispatching
+# .depot/workflows/ci-backend-update-test-timing.yml action
+name: Backend CI
+on:
+ push:
+ branches:
+ - master
+ workflow_dispatch:
+ inputs:
+ clickhouseServerVersion:
+ description: ClickHouse server version. Leave blank for default
+ type: string
+ pull_request:
+ merge_group:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+env:
+ SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da' # unsafe - for testing only
+ DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
+ REDIS_URL: 'redis://localhost'
+ CLICKHOUSE_HOST: 'localhost'
+ CLICKHOUSE_SECURE: 'False'
+ CLICKHOUSE_VERIFY: 'False'
+ # Restricted `autoresearch` user defined in docker/clickhouse/users-dev.xml,
+ # pointed at the CI test DB (posthog_test, not `default` as in regular dev).
+ CLICKHOUSE_TEST_CLUSTER_HOST: 'localhost'
+ CLICKHOUSE_TEST_CLUSTER_DATABASE: 'posthog_test'
+ CLICKHOUSE_TEST_CLUSTER_USER: 'autoresearch'
+ CLICKHOUSE_TEST_CLUSTER_PASSWORD: 'autoresearchpass'
+ CLICKHOUSE_TEST_CLUSTER_SECURE: 'False'
+ CLICKHOUSE_TEST_CLUSTER_VERIFY: 'False'
+ TEST: 1
+ # Depot CI runners expose OTEL_SERVICE_NAME=ci-worker ambient; GitHub Actions test steps do not.
+ # Left set, it leaks into settings.OTEL_SERVICE_NAME (personhog metric client_name label) and
+ # diverges from test assertions. Blank it to match the GHA environment. (GITHUB_TOKEN is also
+ # injected ambient and leaks into plugin download auth headers, but GITHUB_-prefixed vars are
+ # reserved and cannot be overridden via env: — it is unset inside the test run scripts instead.)
+ OTEL_SERVICE_NAME: ''
+ CLICKHOUSE_SERVER_IMAGE_VERSION: ${{ github.event.inputs.clickhouseServerVersion || '' }}
+ CLICKHOUSE_COMPAT_PYTEST_TARGETS: 'posthog/clickhouse ee/clickhouse'
+ OBJECT_STORAGE_ENABLED: 'True'
+ OBJECT_STORAGE_ENDPOINT: 'http://localhost:19000'
+ OBJECT_STORAGE_ACCESS_KEY_ID: 'object_storage_root_user'
+ OBJECT_STORAGE_SECRET_ACCESS_KEY: 'object_storage_root_password'
+ UV_HTTP_TIMEOUT: 120
+ # tests would intermittently fail in GH actions
+ # with exit code 134 _after passing_ all tests
+ # this appears to fix it
+ # absolute wild tbh https://stackoverflow.com/a/75503402
+ DISPLAY: ':99.0'
+ # this is a fake key so this workflow can run for external contributors as they do not have access to secrets (that we don't need here)
+ OIDC_RSA_PRIVATE_KEY: ${{ vars.OIDC_RSA_FAKE_PRIVATE_KEY }}
+ RUNS_ON_INTERNAL_PR: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false }}
+ SANDBOX_JWT_PRIVATE_KEY: ${{ vars.OIDC_RSA_FAKE_PRIVATE_KEY }}
+permissions:
+ contents: read
+ pull-requests: read
+jobs:
+ # Job to decide if we should run backend ci
+ # See https://github.com/dorny/paths-filter#conditional-execution for more details
+ changes:
+ runs-on: depot-ubuntu-latest # was: ubuntu-latest. Mapped standard GitHub runner to Depot equivalent.
+ timeout-minutes: 5
+ name: Determine need to run backend and migration checks
+ # Set job outputs to values from filter step
+ outputs:
+ backend: ${{ steps.filter.outputs.backend || 'true' }}
+ backend_files: ${{ steps.filter.outputs.backend_files }}
+ migrations: ${{ steps.filter.outputs.migrations || 'true' }}
+ migrations_files: ${{ steps.filter.outputs.migrations_files }}
+ tasks_temporal: ${{ steps.filter.outputs.tasks_temporal || 'true' }}
+ openapi_types: ${{ steps.filter.outputs.openapi_types || 'true' }}
+ legacy: ${{ steps.filter.outputs.legacy || 'true' }}
+ 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
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ clean: false
+ - name: Clean up data directories with container permissions
+ run: |
+ # Use docker to clean up files created by containers
+ [ -d "data" ] && docker run --rm -v "$(pwd)/data:/data" alpine sh -c "rm -rf /data/seaweedfs /data/minio" || true
+ continue-on-error: true
+ - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
+ id: filter
+ if: github.event_name != 'push' # Run all tests on master push
+ with:
+ list-files: 'escape'
+ filters: |
+ backend:
+ # Avoid running backend tests for irrelevant changes
+ # NOTE: we are at risk of missing a dependency here. We could make
+ # the dependencies more clear if we separated the backend/frontend
+ # code completely
+ # really we should ignore ee/frontend/** but dorny doesn't support that
+ # - '!ee/frontend/**'
+ # including the negated rule appears to work
+ # but makes it always match because the checked file always isn't `ee/frontend/**` 🙈
+ - 'ee/**/*'
+ - 'common/__init__.py'
+ - 'common/hogql_parser/**'
+ - 'common/hogvm/**'
+ - 'common/ingestion/**'
+ - 'common/migration_utils/**'
+ - 'common/plugin_transpiler/**'
+ - 'posthog/**/*'
+ - 'products/**/backend/**/*'
+ # Python outside backend/ — products like logs and
+ # posthog_ai point `backend:test` at extra roots
+ # (skills/, scripts/). Catch any .py change so the
+ # backend job triggers when only those files move.
+ - 'products/**/*.py'
+ # Each product's package.json declares the per-product
+ # backend:test script that turbo-discover reads to
+ # compose the Product matrix. Without this entry,
+ # widening or fixing the script doesn't trigger
+ # tests it controls.
+ - 'products/*/package.json'
+ - bin/build-schema-latest-versions.py
+ - bin/build-taxonomy-json.py
+ - bin/check_uv_python_compatibility.py
+ - bin/find_python_dependencies.py
+ - bin/unit_metrics.py
+ - pyproject.toml
+ - uv.lock
+ - requirements.txt
+ - requirements-dev.txt
+ - mypy.ini
+ - pytest.ini
+ - .test_durations # Used for pytest-split sharding
+ # generates posthog/schema.py
+ - frontend/src/queries/schema.json
+ # Operator parity check
+ - rust/feature-flags/src/properties/property_models.rs
+ - frontend/src/products.json # Loaded at runtime by posthog/products.py
+ - 'products/*/manifest.tsx' # Generates products.json
+ # hogli db commands used for test database setup
+ - 'tools/hogli-commands/hogli_commands/**'
+ - 'tools/hogli/**'
+ - hogli.yaml
+ # Make sure we run if someone is explicitly changing the workflow
+ - .depot/workflows/ci-backend.yml
+ - .github/clickhouse-versions.json
+ # We use docker compose for tests, make sure we rerun on
+ # changes to docker-compose.dev.yml e.g. dependency
+ # version changes
+ - docker-compose.dev.yml
+ - docker-compose.profiles.yml
+ - docker-compose.base.yml
+ - bin/wait-for-docker
+ - bin/ci-wait-for-docker
+ - frontend/public/email/*
+ - 'docker/clickhouse/**'
+ legacy:
+ # Non-product backend code — when only products/ change,
+ # turbo-discover uses Turbo query affectedness to detect changed
+ # products and decide whether Django runs.
+ # Everything from backend: EXCEPT products/**/backend/**/*
+ - 'ee/**/*'
+ - 'common/__init__.py'
+ - 'common/hogql_parser/**'
+ - 'common/hogvm/**'
+ - 'common/ingestion/**'
+ - 'common/migration_utils/**'
+ - 'common/plugin_transpiler/**'
+ - 'posthog/**/*'
+ - bin/build-schema-latest-versions.py
+ - bin/build-taxonomy-json.py
+ - bin/check_uv_python_compatibility.py
+ - bin/find_python_dependencies.py
+ - bin/unit_metrics.py
+ - pyproject.toml
+ - uv.lock
+ - requirements.txt
+ - requirements-dev.txt
+ - 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
+ - .depot/workflows/ci-backend.yml
+ - .github/clickhouse-versions.json
+ - docker-compose.dev.yml
+ - docker-compose.profiles.yml
+ - docker-compose.base.yml
+ - bin/wait-for-docker
+ - bin/ci-wait-for-docker
+ - frontend/public/email/*
+ - 'docker/clickhouse/**'
+ migrations:
+ - 'docker/clickhouse/**'
+ - 'posthog/migrations/*.py'
+ - 'products/*/backend/migrations/*.py'
+ - 'products/*/migrations/*.py' # Legacy structure
+ # persons-SQL folded into migrations here (see header deltas):
+ # depot strips canonical's separate persons-migration job
+ - 'rust/persons_migrations/*.sql'
+ - 'rust/bin/migrate-persons'
+ tasks_temporal:
+ - 'products/tasks/backend/temporal/**/*'
+ openapi_types:
+ # Generated OpenAPI types - validate they match schema
+ - 'frontend/src/generated/**/*'
+ - 'products/*/frontend/generated/**/*'
+ - 'services/mcp/src/generated/**/*'
+ - 'services/mcp/src/api/generated.ts'
+ # Generation tooling - changes here could affect output
+ - 'tools/openapi-codegen/**/*'
+ - 'services/mcp/scripts/lib/**'
+ - 'frontend/bin/generate-openapi-types.mjs'
+ - 'frontend/src/lib/api-orval-mutator.ts'
+ - 'services/mcp/scripts/**/*'
+ # MCP tool config sources - feed generate-tools.ts
+ - 'services/mcp/definitions/**/*.yaml'
+ - 'services/mcp/definitions/prompts/**/*.md'
+ - 'products/*/mcp/**/*.yaml'
+ - 'products/*/mcp/prompts/**/*.md'
+ - 'services/mcp/schema/tool-definitions.json'
+ - 'services/mcp/schema/tool-definitions-v2.json'
+ - 'services/mcp/src/tools/generated/**/*'
+ - 'services/mcp/schema/generated-tool-definitions.json'
+ - 'services/mcp/schema/tool-definitions-all.json'
+ # Fast pre-job: determines which products need testing and if Django should run
+ # Only needs pnpm + node — no Python, Docker, or services
+ # Runs on depot for turbo remote cache access (cache status drives Django gating)
+ turbo-discover:
+ needs: changes
+ if: needs.changes.outputs.backend == 'true'
+ runs-on: depot-ubuntu-latest
+ timeout-minutes: 20
+ name: Discover product tests
+ outputs:
+ run_legacy: ${{ steps.discover.outputs.run_legacy }}
+ matrix: ${{ steps.discover.outputs.matrix }}
+ schema_cache_key: ${{ steps.schema-key.outputs.key }}
+ django_shards: ${{ steps.discover.outputs.django_shards }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 1000
+ filter: blob:none
+ - name: Fetch current PR base for Turbo affected diff
+ if: github.event_name == 'pull_request'
+ env:
+ BASE_REF: ${{ github.event.pull_request.base.ref }}
+ run: git fetch --no-tags --depth=1000 --filter=blob:none origin "$BASE_REF:refs/remotes/origin/$BASE_REF"
+ - name: Compute schema cache key from merge-base
+ id: schema-key
+ if: github.event_name == 'pull_request'
+ env:
+ BASE_REF: ${{ github.event.pull_request.base.ref }}
+ run: |
+ # HEAD is the synthetic merge commit; HEAD^2 is the PR branch tip.
+ # The fetch-depth:1000 checkout + base-ref fetch above ensure the
+ # full ancestry needed to find the divergence point is available.
+ MERGE_BASE=$(git merge-base HEAD^2 "origin/${BASE_REF}" 2>/dev/null || echo "")
+ if [ -n "$MERGE_BASE" ]; then
+ echo "key=posthog-schema-master-${MERGE_BASE}" >> $GITHUB_OUTPUT
+ else
+ echo "key=" >> $GITHUB_OUTPUT
+ echo "::notice::merge-base not found (branch too stale?) — schema cache will be skipped"
+ fi
+ - name: Setup pnpm
+ uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
+ - name: Setup Node.js
+ uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ with:
+ node-version-file: .nvmrc
+ cache: pnpm
+ cache-dependency-path: |
+ pnpm-lock.yaml
+ .depot/workflows/ci-backend.yml
+ - name: Install pnpm dependencies
+ run: pnpm install --frozen-lockfile --filter=@posthog/root
+ - name: Discover products to test
+ id: discover
+ env:
+ # 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 }}
+ TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.event.pull_request.base.ref) || '' }}
+ TURBO_SCM_HEAD: ${{ github.sha }}
+ run: |
+ # turbo-discover.js uses Turbo's Git affectedness to detect
+ # changed products. Non-isolated product changes trigger the
+ # full suite (all products + Django).
+ RESULT=$(node .github/scripts/turbo-discover.js)
+ echo "Result: $RESULT"
+ echo "matrix=$(echo "$RESULT" | jq -c '.matrix')" >> $GITHUB_OUTPUT
+ echo "run_legacy=$(echo "$RESULT" | jq -r '.run_legacy')" >> $GITHUB_OUTPUT
+ echo "django_shards=$(echo "$RESULT" | jq -c '.django_shards // empty')" >> $GITHUB_OUTPUT
+ # Runs product tests in parallel — one matrix job per group
+ # Each job gets its own runner + Docker stack, so no shared DB conflicts
+ # Small products (< 50 tests) are grouped into a single job to avoid setup overhead
+ turbo-tests:
+ needs: [changes, turbo-discover]
+ if: >-
+ always() && needs.turbo-discover.result == 'success' && needs.turbo-discover.outputs.matrix != '[]' && needs.turbo-discover.outputs.matrix != ''
+ runs-on: depot-ubuntu-latest
+ timeout-minutes: 60
+ name: Product tests (${{ matrix.group }})
+ strategy:
+ fail-fast: false
+ matrix:
+ include: ${{ fromJson(needs.turbo-discover.outputs.matrix) }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ # Start Docker early (before dependency installs) so containers can pull
+ # images and initialize while we install deps. This matches the pattern
+ # used by core-tests/django which achieves ~1s wait times.
+ - name: Clean up data directories
+ run: |
+ [ -d "data" ] && docker run --rm -v "$(pwd)/data:/data" alpine sh -c "rm -rf /data/seaweedfs /data/minio" || true
+ continue-on-error: true
+ - name: Start services
+ env:
+ COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml
+ COMPOSE_PROFILES: temporal,azure
+ CLICKHOUSE_SERVER_IMAGE: clickhouse/clickhouse-server:26.3.10.60
+ run: |
+ cp posthog/user_scripts/latest_user_defined_function.xml docker/clickhouse/user_defined_function.xml
+ # nohup detaches the launch so it survives Depot's step-shell teardown
+ # (which SIGHUPs a plain `&` subshell). Isolated here; bin/ci-wait-for-docker stays == master.
+ nohup bin/ci-wait-for-docker launch --background --down \
+ db redis7 clickhouse zookeeper kafka objectstorage feature-flags \
+ temporal elasticsearch objectstorage-azure \
+ </dev/null >"${RUNNER_TEMP:-/tmp}/compose-launch.log" 2>&1
+ - name: Setup pnpm
+ uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
+ - name: Setup Node.js
+ uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ with:
+ node-version-file: .nvmrc
+ cache: pnpm
+ cache-dependency-path: |
+ pnpm-lock.yaml
+ .depot/workflows/ci-backend.yml
+ - name: Install pnpm dependencies
+ run: pnpm install --frozen-lockfile --filter=@posthog/root
+ - name: Set up Python
+ uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
+ with:
+ python-version: 3.12.12
+ token: ${{ secrets.POSTHOG_BOT_PAT }}
+ - name: Install uv
+ id: setup-uv
+ uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
+ with:
+ version: '0.11.14' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit
+ enable-cache: true
+ cache-dependency-glob: uv.lock
+ save-cache: ${{ github.ref == 'refs/heads/master' }}
+ - name: Install SAML dependencies
+ if: steps.setup-uv.outputs.cache-hit != 'true'
+ run: sudo apt-get update && sudo apt-get install -y libxml2-dev libxmlsec1-dev libxmlsec1-openssl
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
+ with:
+ toolchain: 1.91.1
+ components: cargo
+ - name: Cache Rust dependencies
+ uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
+ with:
+ shared-key: 'v2-rust-backend'
+ workspaces: rust
+ save-if: ${{ github.ref == 'refs/heads/master' }}
+ - name: Install sqlx-cli
+ uses: ./.depot/actions/setup-sqlx-cli
+ - name: Install Python dependencies
+ run: UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
+ - name: Add service hostnames to /etc/hosts
+ run: echo "127.0.0.1 db redis7 kafka clickhouse clickhouse-coordinator objectstorage temporal" | sudo tee -a /etc/hosts
+ - name: Set up needed files
+ run: |
+ mkdir -p frontend/dist
+ touch frontend/dist/index.html frontend/dist/layout.html frontend/dist/exporter.html
+ ./bin/download-mmdb
+ - name: Wait for Docker services
+ env:
+ COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml
+ COMPOSE_PROFILES: temporal,azure
+ CLICKHOUSE_SERVER_IMAGE: clickhouse/clickhouse-server:26.3.10.60
+ WAIT_FOR_DOCKER_TIMEOUT: 900
+ run: |
+ bin/ci-wait-for-docker wait objectstorage \
+ || { echo "::group::compose launch log"; cat "${RUNNER_TEMP:-/tmp}/compose-launch.log" 2>/dev/null || true; echo "::endgroup::"; exit 1; }
+ - name: Register Temporal search attributes
+ env:
+ WAIT_FOR_DOCKER_TIMEOUT: 900
+ run: |
+ bin/ci-wait-for-docker wait temporal
+ python manage.py register_temporal_search_attributes
+ - name: Restore schema cache from master
+ if: ${{ github.event_name == 'pull_request' && needs.turbo-discover.outputs.schema_cache_key != '' }}
+ uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: schema.sql.gz
+ key: ${{ needs.turbo-discover.outputs.schema_cache_key }}
+ - name: Prime test_posthog from cached schema
+ # No-op on cache miss; pytest --reuse-db falls back to a full migrate.
+ if: ${{ github.event_name == 'pull_request' }}
+ run: |
+ if [ ! -f schema.sql.gz ]; then
+ echo "::notice::Schema cache miss — pytest --reuse-db will run full migrations"
+ exit 0
+ fi
+ mkdir -p .postgres-backups
+ mv schema.sql.gz .postgres-backups/schema-latest.sql.gz
+ ./bin/hogli db:restore-test-db
+ - name: Run product tests
+ # --force: discover already decided this product needs testing, skip turbo cache
+ # --log-order=stream: stream pytest output live instead of buffering until completion
+ # pytest_args: optional pytest-split flags for sharded products (e.g. "-- --splits 3 --group 1")
+ env:
+ # --reuse-db: keep the test database between sequential product runs to avoid
+ # ClickHouse drop/create race conditions with ReplicatedMergeTree ZK metadata.
+ # Shadow trial: no snapshot-update / store-durations side effects.
+ PYTEST_ADDOPTS: --reuse-db
+ run: pnpm turbo run backend:test ${{ matrix.filters }} --concurrency=1 --output-logs=full --force --log-order=stream ${{ matrix.pytest_args }}
+ # Lightweight repo-wide checks that only need Python + uv (no Docker/DB).
+ # Consolidates checks that previously each spun up their own runner.
+ repo-checks:
+ needs: [changes]
+ if: needs.changes.outputs.backend == 'true'
+ timeout-minutes: 10
+ name: Repo checks (depot-ubuntu-latest)
+ runs-on: depot-ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Set up Python
+ uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
+ with:
+ python-version: 3.12.12
+ - name: Install uv
+ uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
+ with:
+ version: '0.11.14' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit
+ - name: Install Python dependencies
+ run: UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
+ - name: Bootstrap scaffold product
+ run: ./bin/hogli product:bootstrap spline_reticulator --non-interactive
+ - name: Lint product structure
+ run: ./bin/hogli product:lint --all
+ - name: Check version specifiers
+ run: python .github/scripts/check-version-specifiers.py
+ - name: Check IDOR model coverage
+ run: python .github/scripts/check-idor-model-coverage.py
+ - name: Check operator parity
+ run: python .github/scripts/check-operator-parity.py
+ - name: Check module boundaries (tach)
+ run: tach check --dependencies --interfaces
+ - name: Check product facade enforcement (import-linter)
+ run: lint-imports
+ # Migration validation and OpenAPI type generation.
+ # This job needs Docker + DB — it checks out master first to run baseline
+ # migrations, then checks out the PR branch. All steps after the PR checkout
+ # require Django + DB. Lightweight checks belong in repo-checks above.
+ check-migrations:
+ needs: [changes]
+ if: needs.changes.outputs.backend == 'true' || needs.changes.outputs.openapi_types == 'true'
+ timeout-minutes: 60
+ name: Validate migrations and OpenAPI types
+ runs-on: depot-ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ clean: false
+ - name: Clean up data directories with container permissions
+ run: |
+ # Use docker to clean up files created by containers
+ [ -d "data" ] && docker run --rm -v "$(pwd)/data:/data" alpine sh -c "rm -rf /data/seaweedfs /data/minio" || true
+ continue-on-error: true
+ - name: Stop/Start stack with Docker Compose
+ env:
+ COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml
+ COMPOSE_PROFILES: temporal,azure
+ run: |
+ # nohup detaches the launch so it survives Depot's step-shell teardown
+ # (which SIGHUPs a plain `&` subshell). Isolated here; bin/ci-wait-for-docker stays == master.
+ nohup bin/ci-wait-for-docker launch --background --down \
+ </dev/null >"${RUNNER_TEMP:-/tmp}/compose-launch.log" 2>&1
+ - name: Set up Python
+ uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
+ with:
+ python-version: 3.12.12
+ - name: Install uv
+ id: setup-uv
+ uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
+ with:
+ version: '0.11.14' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit
+ enable-cache: true
+ cache-dependency-glob: uv.lock
+ save-cache: ${{ github.ref == 'refs/heads/master' }}
+ - name: Install SAML (python3-saml) dependencies
+ if: steps.setup-uv.outputs.cache-hit != 'true'
+ run: |
+ sudo apt-get update
+ sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
+ with:
+ toolchain: 1.91.1
+ components: cargo
+ - name: Cache Rust dependencies
+ uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
+ with:
+ shared-key: 'v2-rust-backend'
+ workspaces: rust
+ save-if: ${{ github.ref == 'refs/heads/master' }}
+ - name: Install sqlx-cli
+ uses: ./.depot/actions/setup-sqlx-cli
+ # First running migrations from master, to simulate the real-world scenario
+ - name: Checkout master
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ ref: master
+ clean: false
+ - name: Install python dependencies for master
+ run: |
+ UV_PROJECT_ENVIRONMENT=.venv-master uv sync --frozen --dev
+ - name: Wait for Docker services
+ env:
+ COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml
+ COMPOSE_PROFILES: temporal,azure
+ run: |
+ bin/ci-wait-for-docker wait objectstorage \
+ || { echo "::group::compose launch log"; cat "${RUNNER_TEMP:-/tmp}/compose-launch.log" 2>/dev/null || true; echo "::endgroup::"; exit 1; }
+ - name: Run migrations up to master
+ run: |
+ # Run Django migrations first (excluding managed=False models)
+ .venv-master/bin/python manage.py migrate
+ # Then run persons migrations using sqlx; comment out until we've merged
+ # DATABASE_URL="postgres://posthog:posthog@localhost:5432/posthog_persons" \
+ # sqlx database create
+ # DATABASE_URL="postgres://posthog:posthog@localhost:5432/posthog_persons" \
+ # sqlx migrate run --source rust/persons_migrations/
+ # Shadow trial: OpenAPI app-token step stripped (secret not available on Depot).
+ - name: Checkout this PR
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog') && github.event.pull_request.head.ref || github.ref }}
+ clean: false
+ token: ${{ github.token }}
+ - name: Install python dependencies for this PR
+ run: |
+ UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
+ # Shadow trial: migration SQL-comment + risk-analysis-comment steps stripped.
+ # Keep the risk check itself so blocked migrations still fail the job.
+ - name: Run migration risk analysis
+ if: github.event_name == 'pull_request'
+ run: python manage.py analyze_migration_risk --fail-on-blocked
+ - name: Run migrations for this PR
+ run: |
+ # Run Django migrations first (excluding managed=False models)
+ python manage.py migrate
+ # Then run persons migrations using sqlx
+ DATABASE_URL="postgres://posthog:posthog@localhost:5432/posthog_persons" \
+ sqlx migrate run --source rust/persons_migrations/
+ - name: Dump migrated schema
+ if: github.event_name == 'push'
+ run: |
+ set -e
+ set -o pipefail
+ # Dump schema + django_migrations data so Django knows which migrations are applied
+ # Run pg_dump inside container to ensure version match (host has pg_dump 16, container has 15)
+ (docker compose -f docker-compose.dev.yml exec -T db pg_dump --schema-only --clean --if-exists -U posthog posthog && \
+ docker compose -f docker-compose.dev.yml exec -T db pg_dump --data-only --table=django_migrations -U posthog posthog) | gzip > schema.sql.gz
+ # Verify the dump is valid
+ gunzip -t schema.sql.gz
+ - name: Save schema to Actions cache for PR shards
+ if: github.event_name == 'push'
+ uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: schema.sql.gz
+ key: posthog-schema-master-${{ github.sha }}
+ - name: Check migrations
+ # Skip migration safety check on master push (no migration_files from path filter)
+ if: github.event_name != 'push'
+ env:
+ MIGRATIONS_FILES: ${{ needs.changes.outputs.migrations_files }}
+ run: |
+ DATABASE_URL="postgres://posthog:posthog@localhost:5432/posthog_persons" \
+ sqlx migrate info --source rust/persons_migrations/
+ python manage.py makemigrations --check --dry-run
+ - name: Check CH migrations
+ run: |
+ # Same as above, except now for CH looking at files that were added in posthog/clickhouse/migrations/
+ git diff --name-status origin/master..HEAD | grep "A\sposthog/clickhouse/migrations/" | grep -v README | awk '{print $2}' | python manage.py test_ch_migrations_are_safe
+ - name: Install pnpm
+ uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
+ - name: Fix node-gyp permissions
+ # Depot CI's restored pnpm store can land node-gyp's gyp_main.py without +x.
+ # Locate it across pnpm/action-setup layouts and never fail if it is absent.
+ run: find ~/setup-pnpm -name gyp_main.py -path '*/node-gyp/*' -exec chmod +x {} + 2>/dev/null || true
+ - name: Set up Node.js
+ uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
+ with:
+ node-version-file: .nvmrc
+ cache: pnpm
+ cache-dependency-path: |
+ pnpm-lock.yaml
+ .depot/workflows/ci-backend.yml
+ - name: Install package.json dependencies with pnpm
+ env:
+ npm_config_fetch_retries: 3
+ npm_config_fetch_retry_mintimeout: 10000
+ npm_config_fetch_retry_maxtimeout: 60000
+ run: pnpm --filter=@posthog/root --filter=@posthog/frontend... --filter=@posthog/mcp... install --frozen-lockfile
+ - name: Add OpenAPI Problem Matcher
+ run: echo "::add-matcher::.github/openapi-problem-matcher.json"
+ # Shadow trial: OpenAPI types are check-only — no auto-commit side effect.
+ - name: Check OpenAPI types
+ run: |
+ ./bin/hogli build:openapi
+ pnpm --filter=@posthog/mcp run scaffold-yaml -- --sync-all
+ if git diff --exit-code; then
+ echo "OpenAPI types are up to date"
+ exit 0
+ fi
+ echo "::error::OpenAPI types are out of date — run 'hogli build:openapi' locally and commit the result."
+ exit 1
+ build_django_matrix:
+ name: Build Django matrix
+ needs: [changes, get_clickhouse_versions, turbo-discover]
+ if: |
+ always() &&
+ needs.changes.outputs.backend == 'true' &&
+ needs.get_clickhouse_versions.result == 'success'
+ runs-on: depot-ubuntu-latest # was: ubuntu-latest. Mapped standard GitHub runner to Depot equivalent.
+ timeout-minutes: 5
+ outputs:
+ include: ${{ steps.build.outputs.include }}
+ steps:
+ - name: Build matrix include list
+ id: build
+ env:
+ OLDEST_SUPPORTED_IMAGE: ${{ needs.get_clickhouse_versions.outputs.oldest_supported_image }}
+ COMPAT_MATRIX_JSON: ${{ needs.get_clickhouse_versions.outputs.compat_matrix }}
+ DJANGO_SHARDS_JSON: ${{ needs.turbo-discover.outputs.django_shards }}
+ run: |
+ # Auto-shard counts from turbo-discover (Amdahl's law on .test_durations).
+ # Falls back to hardcoded defaults if turbo-discover failed or data is missing.
+ CORE_SHARDS=38
+ CORE_POE_SHARDS=7
+ TEMPORAL_SHARDS=7
+ if [ -n "$DJANGO_SHARDS_JSON" ] && echo "$DJANGO_SHARDS_JSON" | jq -e '.Core.shards' > /dev/null 2>&1; then
+ CORE_SHARDS=$(echo "$DJANGO_SHARDS_JSON" | jq -r '.Core.shards')
+ CORE_POE_SHARDS=$(echo "$DJANGO_SHARDS_JSON" | jq -r '.CorePOE.shards')
+ TEMPORAL_SHARDS=$(echo "$DJANGO_SHARDS_JSON" | jq -r '.Temporal.shards')
+ echo "Auto-sharding: Core=$CORE_SHARDS, CorePOE=$CORE_POE_SHARDS, Temporal=$TEMPORAL_SHARDS"
+ else
+ echo "::warning::Django shard auto-sizing unavailable, using defaults: Core=$CORE_SHARDS, CorePOE=$CORE_POE_SHARDS, Temporal=$TEMPORAL_SHARDS"
+ fi
+
+ core=$(jq -cn --arg image "$OLDEST_SUPPORTED_IMAGE" --argjson shards "$CORE_SHARDS" '
+ [range(1; $shards + 1) | {
+ segment: "Core",
+ "person-on-events": false,
+ "python-version": "3.12.12",
+ "clickhouse-server-image": $image,
+ concurrency: $shards,
+ group: .,
+ artifact_key: ("core-" + (.|tostring)),
+ compat: false
+ }]
+ ')
+
+ core_persons_on_events=$(jq -cn --arg image "$OLDEST_SUPPORTED_IMAGE" --argjson shards "$CORE_POE_SHARDS" '
+ [range(1; $shards + 1) | {
+ segment: "Core",
+ "person-on-events": true,
+ "python-version": "3.12.12",
+ "clickhouse-server-image": $image,
+ concurrency: $shards,
+ group: .,
+ artifact_key: ("core-poe-" + (.|tostring)),
+ compat: false
+ }]
+ ')
+
+ temporal=$(jq -cn --arg image "$OLDEST_SUPPORTED_IMAGE" --argjson shards "$TEMPORAL_SHARDS" '
+ [range(1; $shards + 1) | {
+ segment: "Temporal",
+ "person-on-events": false,
+ "python-version": "3.12.12",
+ "clickhouse-server-image": $image,
+ concurrency: $shards,
+ group: .,
+ artifact_key: ("temporal-" + (.|tostring)),
+ compat: false
+ }]
+ ')
+
+ compat_source="${COMPAT_MATRIX_JSON:-[]}"
+ compat=$(jq -cn --argjson compat "$compat_source" '
+ [
+ $compat
+ | to_entries[]
+ | .value + {
+ segment: "Core",
+ "person-on-events": false,
+ "python-version": "3.12.12",
+ compat: true,
+ artifact_key: ("compat-" + ((.key + 1)|tostring))
+ }
+ ]
+ ')
+
+ include=$(jq -cn \
+ --argjson core "$core" \
+ --argjson core_persons_on_events "$core_persons_on_events" \
+ --argjson temporal "$temporal" \
+ --argjson compat "$compat" \
+ '$core + $core_persons_on_events + $temporal + $compat')
+
+ echo "include=$include" >> "$GITHUB_OUTPUT"
+ echo "Django matrix size: $(jq -r 'length' <<< "$include")"
+ django:
+ needs: [changes, turbo-discover, get_clickhouse_versions, build_django_matrix]
+ # Run legacy pytest if:
+ # 1. Legacy code directly changed (ee/, posthog/)
+ # 2. OR product changes affect legacy code (turbo-discover outputs run_legacy=true)
+ # 3. OR turbo-discover itself failed (conservative: run Django on detection failure)
+ if: |
+ always() &&
+ needs.changes.outputs.backend == 'true' &&
+ needs.build_django_matrix.result == 'success' &&
+ (needs.changes.outputs.legacy == 'true' ||
+ needs.turbo-discover.outputs.run_legacy == 'true' ||
+ (needs.turbo-discover.result != 'success' && needs.turbo-discover.result != 'skipped'))
+ # increase for tmate testing
+ timeout-minutes: 60
+ name: Django tests – ${{ matrix.segment }}${{ matrix.compat && ' compat' || '' }} (persons-on-events ${{ matrix.person-on-events && 'on' || 'off' }}), Py ${{ matrix.python-version }}, ${{ matrix.clickhouse-server-image }} (${{matrix.group}}/${{ matrix.concurrency }})
+ # Match canonical's runner size. The shadow restores the same master-primed
+ # schema cache (turbo-discover key + check-migrations save), so shards skip
+ # migrations exactly like canonical once Depot's cache is warmed by a master run.
+ runs-on: depot-ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ include: ${{ fromJson(needs.build_django_matrix.outputs.include) }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 1
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
+ ref: ${{ github.event.pull_request.head.ref }}
+ lfs: true
+ clean: false
+ - name: Clean up data directories with container permissions
+ run: |
+ # Use docker to clean up files created by containers
+ [ -d "data" ] && docker run --rm -v "$(pwd)/data:/data" alpine sh -c "rm -rf /data/seaweedfs /data/minio" || true
+ continue-on-error: true
+ - name: 'Safeguard: ensure no stray Python modules at product root'
+ run: |
+ echo "Checking that products/* only contain backend/, frontend/, or shared/ as Python code roots..."
+ BAD_FILES=$(find products -maxdepth 2 -type f -name "*.py" ! -path "*/backend/*" ! -name "__init__.py" ! -name "conftest.py" -o -maxdepth 2 -type d -name "migrations" ! -path "*/backend/*")
+ if [ -n "$BAD_FILES" ]; then
+ echo "❌ Found Python code or migrations outside backend/:"
+ echo "$BAD_FILES"
+ echo "Please move these into the appropriate backend/ folder."
+ exit 1
+ fi
+ echo "✅ No stray Python files or migrations found at product roots."
+ # Pre-tests
+ # Copies the fully versioned UDF xml file for use in CI testing
+ - name: Stop/Start stack with Docker Compose
+ shell: bash
+ env:
+ COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml
+ COMPOSE_PROFILES: temporal,azure
+ CLICKHOUSE_SERVER_IMAGE: ${{ matrix.clickhouse-server-image || needs.get_clickhouse_versions.outputs.oldest_supported_image }}
+ WAIT_FOR_DOCKER_LAUNCH_RETRIES: 3
+ WAIT_FOR_DOCKER_LAUNCH_RETRY_DELAY: 5
+ run: |
+ cp posthog/user_scripts/latest_user_defined_function.xml docker/clickhouse/user_defined_function.xml
+ # nohup detaches the launch so it survives Depot's step-shell teardown
+ # (which SIGHUPs a plain `&` subshell). Isolated here; bin/ci-wait-for-docker stays == master.
+ nohup bin/ci-wait-for-docker launch --background --down-all-profiles \
+ </dev/null >"${RUNNER_TEMP:-/tmp}/compose-launch.log" 2>&1
+ - name: Add service hostnames to /etc/hosts
+ shell: bash
+ run: echo "127.0.0.1 db redis7 kafka clickhouse clickhouse-coordinator objectstorage seaweedfs temporal" | sudo tee -a /etc/hosts
+ - name: Set up Python
+ uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Install uv
+ id: setup-uv-tests
+ uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
+ with:
+ version: '0.11.14' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit
+ enable-cache: true
+ cache-dependency-glob: uv.lock
+ save-cache: ${{ github.ref == 'refs/heads/master' }}
+ - name: Install SAML (python3-saml) dependencies
+ if: ${{ needs.changes.outputs.backend == 'true' && steps.setup-uv-tests.outputs.cache-hit != 'true' }}
+ shell: bash
+ run: |
+ sudo apt-get update && sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
+ - name: Install Rust
+ if: needs.changes.outputs.backend == 'true'
+ uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
+ with:
+ toolchain: 1.91.1
+ components: cargo
+ - name: Cache Rust dependencies
+ if: needs.changes.outputs.backend == 'true'
+ uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
+ with:
+ shared-key: 'v2-rust-backend'
+ workspaces: rust
+ save-if: ${{ github.ref == 'refs/heads/master' }}
+ - name: Install sqlx-cli
+ if: needs.changes.outputs.backend == 'true'
+ uses: ./.depot/actions/setup-sqlx-cli
+ - name: Determine if hogql-parser has changed compared to master
+ shell: bash
+ id: hogql-parser-diff
+ run: |
+ git fetch --no-tags --prune --depth=1 origin master
+ changed=$(git diff --quiet HEAD origin/master -- common/hogql_parser/ && echo "false" || echo "true")
+ echo "changed=$changed" >> $GITHUB_OUTPUT
+ # tests would intermittently fail in GH actions
+ # with exit code 134 _after passing_ all tests
+ # this appears to fix it
+ # absolute wild tbh https://stackoverflow.com/a/75503402
+
+ # Cache Qt library packages to reduce network dependency and flakiness
+ # Using cache-apt-pkgs-action instead of setup-qt-libs to avoid network issues
+ - name: Cache and install Qt libraries
+ uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
+ with:
+ packages: libegl1 libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 x11-utils libxcb-cursor0 libopengl0
+ version: 1.0
+ - name: Install Python dependencies
+ shell: bash
+ run: |
+ UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
+ - name: Install the working version of hogql-parser
+ if: ${{ needs.changes.outputs.backend == 'true' && steps.hogql-parser-diff.outputs.changed == 'true' }}
+ shell: bash
+ # This is not cached currently, as it's important to build the current HEAD version of hogql-parser if it has
+ # changed (requirements.txt has the already-published version)
+ run: |
+ sudo apt-get install unzip cmake curl uuid pkg-config
+ curl --fail --location https://www.antlr.org/download/antlr4-cpp-runtime-4.13.1-source.zip --output antlr4-source.zip || curl --fail --location https://raw.githubusercontent.com/antlr/website-antlr4/gh-pages/download/antlr4-cpp-runtime-4.13.1-source.zip --output antlr4-source.zip
+ # Check that the downloaded archive is the expected runtime - a security measure
+ anltr_known_md5sum="c875c148991aacd043f733827644a76f"
+ antlr_found_ms5sum="$(md5sum antlr4-source.zip | cut -d' ' -f1)"
+ if [[ "$anltr_known_md5sum" != "$antlr_found_ms5sum" ]]; then
+ echo "Unexpected MD5 sum of antlr4-source.zip!"
+ echo "Known: $anltr_known_md5sum"
+ echo "Found: $antlr_found_ms5sum"
+ exit 64
+ fi
+ unzip antlr4-source.zip -d antlr4-source && cd antlr4-source
+ cmake .
+ DESTDIR=out make install
+ sudo cp -r out/usr/local/include/antlr4-runtime /usr/include/
+ sudo cp out/usr/local/lib/libantlr4-runtime.so* /usr/lib/
+ sudo ldconfig
+ cd ..
+ pip install ./common/hogql_parser
+ - name: Set up needed files
+ shell: bash
+ run: |
+ mkdir -p frontend/dist
+ touch frontend/dist/index.html
+ touch frontend/dist/layout.html
+ touch frontend/dist/exporter.html
+ ./bin/download-mmdb
+ - name: Wait for Docker services
+ shell: bash
+ # Read-only health poll for core services only. Can't use --wait here
+ # because it blocks on ALL project containers including temporal, which
+ # boots slowly (auto-setup runs DB migrations). Temporal was started in
+ # background above and will be ready by the time temporal tests run.
+ env:
+ COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml
+ COMPOSE_PROFILES: temporal,azure
+ CLICKHOUSE_SERVER_IMAGE: ${{ matrix.clickhouse-server-image || needs.get_clickhouse_versions.outputs.oldest_supported_image }}
+ WAIT_FOR_DOCKER_TIMEOUT: 900
+ run: |
+ bin/ci-wait-for-docker wait objectstorage \
+ || { echo "::group::compose launch log"; cat "${RUNNER_TEMP:-/tmp}/compose-launch.log" 2>/dev/null || true; echo "::endgroup::"; exit 1; }
+ - name: Wait for Temporal
+ # Some Core tests reach Temporal indirectly (batch_exports, etc). On
+ # slower Depot runners Temporal is not ready when tests start, so
+ # block here instead of racing in pytest.
+ env:
+ WAIT_FOR_DOCKER_TIMEOUT: 900
+ run: bin/ci-wait-for-docker wait temporal
+ - name: Restore schema cache from master
+ if: ${{ github.event_name == 'pull_request' && needs.turbo-discover.outputs.schema_cache_key != '' }}
+ uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: schema.sql.gz
+ key: ${{ needs.turbo-discover.outputs.schema_cache_key }}
+ - name: Prime test_posthog from cached schema
+ # No-op on cache miss; pytest --reuse-db falls back to a full migrate.
+ if: ${{ github.event_name == 'pull_request' }}
+ run: |
+ if [ ! -f schema.sql.gz ]; then
+ echo "::notice::Schema cache miss — pytest --reuse-db will run full migrations"
+ exit 0
+ fi
+ mkdir -p .postgres-backups
+ mv schema.sql.gz .postgres-backups/schema-latest.sql.gz
+ ./bin/hogli db:restore-test-db
+ # Tests
+ - name: Log test environment diagnostics
+ if: ${{ needs.changes.outputs.backend == 'true' && matrix.segment == 'Core' }}
+ shell: bash
+ env:
+ SHARD_GROUP: ${{ matrix.group }}
+ SHARD_CONCURRENCY: ${{ matrix.concurrency }}
+ CLICKHOUSE_IMAGE: ${{ matrix.clickhouse-server-image }}
+ COMMIT_SHA: ${{ github.sha }}
+ BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
+ run: |
+ echo "=== Test Environment Diagnostics ==="
+ echo "Shard: $SHARD_GROUP/$SHARD_CONCURRENCY"
+ echo "Python version: $(python --version)"
+ echo "ClickHouse version: $CLICKHOUSE_IMAGE"
+ echo "Commit: $COMMIT_SHA"
+ echo "Branch: $BRANCH_NAME"
+ echo "Runner: $(uname -a)"
+ echo "Memory: $(free -h | head -2)"
+ echo "Disk: $(df -h / | tail -1)"
+ echo "Docker containers:"
+ docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" || true
+ echo "==================================="
+ - name: Run Core tests
+ id: run-core-tests
+ if: ${{ needs.changes.outputs.backend == 'true' && matrix.segment == 'Core' }}
+ env:
+ PERSON_ON_EVENTS_V2_ENABLED: ${{ matrix.person-on-events && 'true' || 'false' }}
+ shell: bash
+ run: | # async_migrations covered in ci-async-migrations.yml
+ unset GITHUB_TOKEN # reserved var injected by Depot CI; can't override via env: (see workflow env note)
+ set +e
+ pytest -v --tb=short --reuse-db -o junit_duration_report=call ${{
+ matrix.compat
+ && env.CLICKHOUSE_COMPAT_PYTEST_TARGETS
+ || (
+ matrix.person-on-events
+ && './posthog/clickhouse/ ./posthog/queries/ ./products/product_analytics/backend/api/test/ ./posthog/api/test/dashboards/test_dashboard.py'
+ || 'posthog'
+ )
+ }} ${{ matrix.compat && '' || (matrix.person-on-events && 'ee/clickhouse/' || 'ee/') }} -m "not async_migrations" \
+ --ignore=posthog/temporal \
+ --ignore=posthog/dags \
+ --ignore=common/hogvm/python/test \
+ ${{ matrix.person-on-events && '--ignore=posthog/hogql_queries' || '' }} \
+ ${{ matrix.person-on-events && '--ignore=posthog/hogql' || '' }} \
+ --snapshot-update --snapshot-warn-unused \
+ --splits ${{ matrix.concurrency }} --group ${{ matrix.group }} \
+ --durations=1000 --durations-min=1.0 \
+ --splitting-algorithm=duration_based_chunks \
+ --reruns 2 --reruns-delay 1 \
+ -r fEsxX \
+ --junitxml=junit-core.xml
+ exit_code=$?
+ set -e
+ if [ $exit_code -eq 5 ]; then
+ echo "No tests collected for this shard, this is expected when splitting tests"
+ exit 0
+ else
+ exit $exit_code
+ fi
+ # Uncomment this code to create an ssh-able console so you can debug issues with github actions
+ # (Consider changing the timeout in ci-backend.yml to have more time)
+ # - name: Setup tmate session
+ # if: failure()
+ # uses: mxschmitt/action-tmate@v3
+ - name: Log test environment diagnostics
+ if: ${{ needs.changes.outputs.backend == 'true' && matrix.segment == 'Temporal' }}
+ shell: bash
+ env:
+ SHARD_GROUP: ${{ matrix.group }}
+ SHARD_CONCURRENCY: ${{ matrix.concurrency }}
+ COMMIT_SHA: ${{ github.sha }}
+ BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
+ run: |
+ echo "=== Test Environment Diagnostics ==="
+ echo "Shard: $SHARD_GROUP/$SHARD_CONCURRENCY"
+ echo "Python version: $(python --version)"
+ echo "Commit: $COMMIT_SHA"
+ echo "Branch: $BRANCH_NAME"
+ echo "Runner: $(uname -a)"
+ echo "Memory: $(free -h | head -2)"
+ echo "Disk: $(df -h / | tail -1)"
+ echo "Docker containers:"
+ docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" || true
+ echo "==================================="
+ - name: Run Temporal tests
+ id: run-temporal-tests
+ if: ${{ needs.changes.outputs.backend == 'true' && matrix.segment == 'Temporal' }}
+ shell: bash
+ env:
+ AWS_S3_ALLOW_UNSAFE_RENAME: 'true'
+ MODAL_TOKEN_ID: ${{ needs.changes.outputs.tasks_temporal == 'true' && secrets.MODAL_TOKEN_ID || '' }}
+ MODAL_TOKEN_SECRET: ${{ needs.changes.outputs.tasks_temporal == 'true' && secrets.MODAL_TOKEN_SECRET || '' }}
+ run: |
+ unset GITHUB_TOKEN # reserved var injected by Depot CI; can't override via env: (see workflow env note)
+ set +e
+ # Depot-only quarantine: the data-modeling materialize path (get_s3_client) 403s on
+ # MinIO on Depot-native CI only — MinIO itself is reachable with the standard test creds
+ # (verified via boto3 LIST/CREATE/HEAD), so root cause is env-specific and not yet
+ # isolated (tracked for follow-up). All three tests below run that materialize path; the
+ # two timeout tests fail downstream (hogql_table never reached). Canonical GHA still runs them.
+ # No per-test pytest --timeout; rely on the job-level timeout-minutes as the single
+ # safety net (matches canonical — the per-test guillotine added nothing over it,
+ # since --timeout-method=thread os._exit()s the whole process anyway).
+ pytest -v --tb=short --reuse-db -o junit_duration_report=call posthog/temporal products/batch_exports/backend/tests/temporal products/tasks/backend/temporal -m "not async_migrations" \
+ --deselect "posthog/temporal/tests/data_modeling/test_run_workflow.py::test_run_workflow_with_minio_bucket" \
+ --deselect "posthog/temporal/tests/data_modeling/test_run_workflow.py::test_run_workflow_timeout_does_not_pause_schedule_without_consecutive_failures" \
+ --deselect "posthog/temporal/tests/data_modeling/test_run_workflow.py::test_run_workflow_timeout_pauses_schedule_after_5_consecutive_failures" \
+ --snapshot-update --snapshot-warn-unused \
+ --splits ${{ matrix.concurrency }} --group ${{ matrix.group }} \
+ --durations=100 --durations-min=1.0 \
+ --splitting-algorithm=duration_based_chunks \
+ --reruns 2 --reruns-delay 1 \
+ -r fEsxX \
+ --junitxml=junit-temporal.xml
+ exit_code=$?
+ set -e
+ if [ $exit_code -eq 5 ]; then
+ echo "No tests collected for this shard, this is expected when splitting tests"
+ exit 0
+ else
+ exit $exit_code
+ fi
+ # Post tests
+ - name: Show docker compose logs on failure
+ if: failure() && (needs.changes.outputs.backend == 'true' && steps.run-core-tests.outcome != 'failure' && steps.run-decide-read-replica-tests.outcome != 'failure' && steps.run-temporal-tests.outcome != 'failure')
+ shell: bash
+ run: docker compose -f docker-compose.dev.yml logs
+ # Aggregate and commit snapshot changes from all matrix jobs
+ get_clickhouse_versions:
+ name: Get ClickHouse versions
+ needs: [changes]
+ if: needs.changes.outputs.backend == 'true'
+ runs-on: depot-ubuntu-latest # was: ubuntu-latest. Mapped standard GitHub runner to Depot equivalent.
+ timeout-minutes: 5
+ outputs:
+ # Oldest supported version for main Django tests (JSON array for matrix)
+ oldest_supported: ${{ steps.read-versions.outputs.oldest_supported }}
+ # Oldest supported version as plain string (for comparisons)
+ oldest_supported_image: ${{ steps.read-versions.outputs.oldest_supported_image }}
+ # Fully expanded compat matrix (version x shard group)
+ compat_matrix: ${{ steps.read-versions.outputs.compat_matrix }}
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ sparse-checkout: .github/clickhouse-versions.json
+ sparse-checkout-cone-mode: false
+ - name: Read ClickHouse versions from JSON
+ id: read-versions
+ run: |
+ compat_shards="2"
+ echo "Using $compat_shards shard(s) per compat version"
+
+ # Oldest supported version for main Django tests (for max compatibility, as JSON array for matrix)
+ oldest_supported=$(jq -r '.oldest_supported' .github/clickhouse-versions.json)
+ if [ -z "$oldest_supported" ] || [ "$oldest_supported" = "null" ]; then
+ echo "::error::No oldest_supported version found in .github/clickhouse-versions.json"
+ exit 1
+ fi
+ echo "oldest_supported=[\"$oldest_supported\"]" >> $GITHUB_OUTPUT
+ echo "oldest_supported_image=$oldest_supported" >> $GITHUB_OUTPUT
+ echo "Oldest supported version for Django tests: $oldest_supported"
+
+ # Read all unique versions so we can derive compat coverage.
+ all=$(jq -c '[.[]] | unique' .github/clickhouse-versions.json)
+ if [ "$all" = "[]" ] || [ -z "$all" ]; then
+ echo "::error::No versions found in .github/clickhouse-versions.json"
+ exit 1
+ fi
+ echo "All CH versions found: $all"
+
+ # Compat coverage is only needed for non-oldest versions.
+ compat_versions=$(jq -c --arg oldest "$oldest_supported" '[.[]] | unique | map(select(. != $oldest))' .github/clickhouse-versions.json)
+ echo "Compat versions (excluding oldest): $compat_versions"
+
+ compat_count=$(jq -r 'length' <<< "$compat_versions")
+ echo "compat_count=$compat_count" >> $GITHUB_OUTPUT
+
+ if [ "$compat_count" -eq 0 ]; then
+ echo "compat_matrix=[]" >> $GITHUB_OUTPUT
+ echo "No non-oldest CH versions found — compat tests provide no additional coverage, skipping"
+ else
+ compat_matrix=$(jq -cn --argjson versions "$compat_versions" --argjson shards "$compat_shards" '
+ [
+ $versions[] as $version
+ | range(1; $shards + 1) as $group
+ | {
+ "clickhouse-server-image": $version,
+ "concurrency": $shards,
+ "group": $group
+ }
+ ]
+ ')
+ echo "compat_matrix=$compat_matrix" >> $GITHUB_OUTPUT
+ echo "Compat matrix: $compat_matrix"
+ fi
+ # Job just to collate the status of the matrix jobs for requiring passing status
+ django_tests:
+ needs: [django, check-migrations, async-migrations, turbo-discover, turbo-tests, repo-checks]
+ name: Django Tests Pass
+ runs-on: depot-ubuntu-latest # was: ubuntu-latest. Mapped standard GitHub runner to Depot equivalent.
+ timeout-minutes: 5
+ if: always()
+ steps:
+ - name: Check matrix outcome
+ run: |
+ # The `needs.django.result` will be 'success' only if all jobs in the matrix succeeded.
+ # Otherwise, it will be 'failure'.
+ if [[ "${{ needs.django.result }}" != "success" && "${{ needs.django.result }}" != "skipped" ]]; then
+ echo "One or more jobs in the Django test matrix failed."
+ exit 1
+ fi
+
+ # Check migration validation - must pass for Django Tests to be green
+ if [[ "${{ needs.check-migrations.result }}" != "success" && "${{ needs.check-migrations.result }}" != "skipped" ]]; then
+ echo "Migration checks failed."
+ exit 1
+ fi
+
+ # Check async migrations - must pass for Django Tests to be green
+ if [[ "${{ needs.async-migrations.result }}" != "success" && "${{ needs.async-migrations.result }}" != "skipped" ]]; then
+ echo "Async migrations tests failed."
+ exit 1
+ fi
+
+ # Check repo checks (product lint, IDOR, operator parity, tach)
+ if [[ "${{ needs.repo-checks.result }}" != "success" && "${{ needs.repo-checks.result }}" != "skipped" ]]; then
+ echo "Repo checks failed."
+ exit 1
+ fi
+
+ # Check Turbo discover - must pass for Django Tests to be green
+ if [[ "${{ needs.turbo-discover.result }}" != "success" && "${{ needs.turbo-discover.result }}" != "skipped" ]]; then
+ echo "Turbo discover failed."
+ exit 1
+ fi
+
+ # Check Turbo tests (products) - must pass for Django Tests to be green
+ if [[ "${{ needs.turbo-tests.result }}" != "success" && "${{ needs.turbo-tests.result }}" != "skipped" ]]; then
+ echo "Turbo tests failed."
+ exit 1
+ fi
+
+ echo "All checks passed."
+ async-migrations:
+ name: Async migrations tests - ${{ matrix.clickhouse-server-image }} (depot-ubuntu-latest)
+ needs: [changes, turbo-discover, get_clickhouse_versions]
+ strategy:
+ fail-fast: false
+ matrix:
+ clickhouse-server-image: ${{ fromJson(needs.get_clickhouse_versions.outputs.oldest_supported) }}
+ # Run if legacy code changed, product changes affect legacy, or turbo-discover failed
+ if: |
+ always() &&
+ needs.changes.outputs.backend == 'true' &&
+ (needs.changes.outputs.legacy == 'true' ||
+ needs.turbo-discover.outputs.run_legacy == 'true' ||
+ (needs.turbo-discover.result != 'success' && needs.turbo-discover.result != 'skipped'))
+ runs-on: depot-ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - name: 'Checkout repo'
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 1
+ clean: false
+ - name: Clean up data directories with container permissions
+ run: |
+ # Use docker to clean up files created by containers
+ [ -d "data" ] && docker run --rm -v "$(pwd)/data:/data" alpine sh -c "rm -rf /data/seaweedfs /data/minio" || true
+ continue-on-error: true
+ - name: Start stack with Docker Compose
+ env:
+ COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml
+ COMPOSE_PROFILES: temporal,azure
+ CLICKHOUSE_SERVER_IMAGE: ${{ matrix.clickhouse-server-image || needs.get_clickhouse_versions.outputs.oldest_supported_image }}
+ run: |
+ # nohup detaches the launch so it survives Depot's step-shell teardown
+ # (which SIGHUPs a plain `&` subshell). Isolated here; bin/ci-wait-for-docker stays == master.
+ nohup bin/ci-wait-for-docker launch --background --down \
+ </dev/null >"${RUNNER_TEMP:-/tmp}/compose-launch.log" 2>&1
+ - name: Set up Python
+ uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
+ with:
+ python-version-file: 'pyproject.toml'
+ - name: Install uv
+ id: setup-uv-async
+ uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
+ with:
+ version: '0.11.14' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit
+ enable-cache: true
+ cache-dependency-glob: uv.lock
+ save-cache: ${{ github.ref == 'refs/heads/master' }}
+ - name: Install SAML (python3-saml) dependencies
+ if: steps.setup-uv-async.outputs.cache-hit != 'true'
+ run: |
+ sudo apt-get update
+ sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
+ with:
+ toolchain: 1.91.1
+ components: cargo
+ - name: Cache Rust dependencies
+ uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
+ with:
+ shared-key: 'v2-rust-backend'
+ workspaces: rust
+ save-if: ${{ github.ref == 'refs/heads/master' }}
+ - name: Install sqlx-cli
+ uses: ./.depot/actions/setup-sqlx-cli
+ - name: Install python dependencies
+ shell: bash
+ run: |
+ UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
+ - name: Add service hostnames to /etc/hosts
+ run: sudo echo "127.0.0.1 db redis7 kafka clickhouse clickhouse-coordinator objectstorage seaweedfs temporal" | sudo tee -a /etc/hosts
+ - name: Set up needed files
+ run: |
+ mkdir -p frontend/dist
+ touch frontend/dist/index.html
+ touch frontend/dist/layout.html
+ touch frontend/dist/exporter.html
+ - name: Wait for Docker services
+ shell: bash
+ env:
+ COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml
+ COMPOSE_PROFILES: temporal,azure
+ CLICKHOUSE_SERVER_IMAGE: ${{ matrix.clickhouse-server-image || needs.get_clickhouse_versions.outputs.oldest_supported_image }}
+ run: |
+ bin/ci-wait-for-docker wait objectstorage \
+ || { echo "::group::compose launch log"; cat "${RUNNER_TEMP:-/tmp}/compose-launch.log" 2>/dev/null || true; echo "::endgroup::"; exit 1; }
+ - name: Restore schema cache from master
+ if: ${{ github.event_name == 'pull_request' && needs.turbo-discover.outputs.schema_cache_key != '' }}
+ uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
+ with:
+ path: schema.sql.gz
+ key: ${{ needs.turbo-discover.outputs.schema_cache_key }}
+ - name: Prime test_posthog from cached schema
+ # No-op on cache miss; pytest --reuse-db falls back to a full migrate.
+ if: ${{ github.event_name == 'pull_request' }}
+ run: |
+ if [ ! -f schema.sql.gz ]; then
+ echo "::notice::Schema cache miss — pytest --reuse-db will run full migrations"
+ exit 0
+ fi
+ mkdir -p .postgres-backups
+ mv schema.sql.gz .postgres-backups/schema-latest.sql.gz
+ ./bin/hogli db:restore-test-db
+ - name: Run async migrations tests
+ run: |
+ # Scope async migration tests directly and reuse the primed test database.
+ pytest posthog/async_migrations/test -m "async_migrations" --reuse-db --reruns 2 --reruns-delay 1 --durations=100 --durations-min=1.0 --junitxml=junit.xml
+ # Shadow trial: calculate-running-time job stripped (would poison trial metrics).
diff --git a/.github/workflows/ci-backend-shadow-drift.yml b/.github/workflows/ci-backend-shadow-drift.yml
new file mode 100644
index 000000000000..def77251641a
--- /dev/null
+++ b/.github/workflows/ci-backend-shadow-drift.yml
@@ -0,0 +1,57 @@
+name: Backend CI shadow drift check
+
+# Fails when .github/workflows/ci-backend.yml changes without a matching update
+# to .depot/workflows/ci-backend.yml. The depot file is a hand-maintained shadow
+# of canonical (see header comment in the depot file for the intentional deltas);
+# without this check, canonical drifts silently and the depot timing trial stops
+# measuring the same work.
+#
+# Cheap to run — only triggers when one of the two files changes.
+
+on:
+ pull_request:
+ paths:
+ - .github/workflows/ci-backend.yml
+ - .depot/workflows/ci-backend.yml
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ check:
+ name: Both ci-backend files updated together
+ runs-on: ubuntu-latest
+ # 5 min absorbs cold-runner startup + the explicit depth=100 fetch of BASE_SHA below.
+ # `actions/checkout` defaults to depth=1 (HEAD only); a full-history clone is unnecessary
+ # — we only need to diff two SHAs.
+ timeout-minutes: 5
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ - name: Compare PR diff scope
+ env:
+ BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ run: |
+ set -euo pipefail
+ # actions/checkout checks out refs/pull/<n>/merge by default, so HEAD
+ # is the merge commit — diffing BASE_SHA..HEAD gives the PR's effective
+ # changes. We only need to fetch BASE_SHA (HEAD is already local).
+ git fetch --no-tags --depth=100 origin "$BASE_SHA"
+ changed=$(git diff --name-only "$BASE_SHA" HEAD -- \
+ .github/workflows/ci-backend.yml \
+ .depot/workflows/ci-backend.yml)
+ if echo "$changed" | grep -q '^.github/workflows/ci-backend.yml$' && \
+ ! echo "$changed" | grep -q '^.depot/workflows/ci-backend.yml$'; then
+ echo "::error::Canonical .github/workflows/ci-backend.yml changed without a matching update to .depot/workflows/ci-backend.yml."
+ echo "The depot shadow must stay apples-to-apples with canonical. Mirror the change into the depot file"
+ echo "(or, if the change is one of the intentional deltas listed in the depot file header, document why it is depot-exempt)."
+ exit 1
+ fi
+ if echo "$changed" | grep -q '^.depot/workflows/ci-backend.yml$' && \
+ ! echo "$changed" | grep -q '^.github/workflows/ci-backend.yml$'; then
+ echo "::notice::Only the depot shadow changed. That is allowed (e.g. tuning a depot-only knob), but worth a glance from the reviewer."
+ fi
+ echo "Shadow drift check passed."
diff --git a/products/batch_exports/backend/tests/temporal/destinations/file_download/conftest.py b/products/batch_exports/backend/tests/temporal/destinations/file_download/conftest.py
index c795bf7ac06d..b1439ce51c74 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/file_download/conftest.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/file_download/conftest.py
@@ -73,7 +73,11 @@ async def s3_bucket(bucket_name, s3_client, region):
Bucket=bucket_name,
ACL="private",
)
- except botocore.exceptions.ClientError:
+ except (
+ botocore.exceptions.NoCredentialsError,
+ botocore.exceptions.PartialCredentialsError,
+ botocore.exceptions.ClientError,
+ ):
raise pytest.skip("Could not setup S3 bucket")
yield bucket_name
@@ -88,9 +92,9 @@ async def s3_bucket(bucket_name, s3_client, region):
@pytest_asyncio.fixture(scope="module")
async def aws_role_arn(session, bucket_name, role_name):
async with session.client("iam") as iam, session.client("sts") as sts:
- identity = await sts.get_caller_identity()
- identity_role_name = identity["Arn"].split("/")[-2]
try:
+ identity = await sts.get_caller_identity()
+ identity_role_name = identity["Arn"].split("/")[-2]
resp = await iam.create_role(
RoleName=role_name,
MaxSessionDuration=3600,
@@ -111,7 +115,11 @@ async def aws_role_arn(session, bucket_name, role_name):
),
Description="Role assumed by the file download batch export during testing",
)
- except botocore.exceptions.ClientError:
+ except (
+ botocore.exceptions.NoCredentialsError,
+ botocore.exceptions.PartialCredentialsError,
+ botocore.exceptions.ClientError,
+ ):
raise pytest.skip("Could not create test role")
s3_policy = {
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py b/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py
index b5f1ab3f6990..7a8a0cd4b3ed 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py
@@ -85,7 +85,11 @@ async def check_valid_credentials() -> bool:
async with session.client("sts") as sts:
try:
await sts.get_caller_identity()
- except botocore.exceptions.ClientError:
+ except (
+ botocore.exceptions.NoCredentialsError,
+ botocore.exceptions.PartialCredentialsError,
+ botocore.exceptions.ClientError,
+ ):
return False
else:
return True