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): cancel backend run when deterministic checks fail (#62985)

Daniel RC56a70c99110b
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 655a819aca8b..387f54db0002 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -650,6 +650,9 @@ jobs:
needs: [changes]
if: needs.changes.outputs.backend == 'true'
timeout-minutes: 10
+ permissions:
+ contents: read
+ actions: write # to cancel this run when a deterministic check fails
name: Repo checks (depot-ubuntu-latest)
runs-on: depot-ubuntu-latest
steps:
@@ -679,6 +682,13 @@ jobs:
- name: Install Python dependencies
run: UV_PROJECT_ENVIRONMENT=$pythonLocation uv sync --frozen --dev
+ # Boundary between network-dependent setup (can flake) and the pure
+ # static checks below — the cancel step at the end uses it to avoid
+ # canceling the whole run on a transient setup failure.
+ - name: Mark setup complete
+ id: setup-complete
+ run: echo "Setup complete — any failure below is a deterministic check failure"
+
- name: Bootstrap scaffold product
run: ./bin/hogli product:bootstrap spline_reticulator --non-interactive
@@ -700,6 +710,23 @@ jobs:
- name: Check product facade enforcement (import-linter)
run: lint-imports
+ # A failure in the static checks above is deterministic — a retry can
+ # never fix it, so the rest of the run (50+ test shards) is wasted spend.
+ # PR-only: master and merge queue runs must complete (deploy gate,
+ # snapshots). Same-repo only: fork PR tokens are read-only.
+ - name: Cancel run on deterministic check failure
+ if: >
+ failure() &&
+ steps.setup-complete.outcome == 'success' &&
+ github.event_name == 'pull_request' &&
+ github.event.pull_request.head.repo.full_name == github.repository
+ env:
+ GH_TOKEN: ${{ github.token }}
+ GH_REPO: ${{ github.repository }}
+ run: |
+ echo "::notice::Repo checks failed deterministically — canceling the remaining jobs in this run. A retry cannot fix this failure; push a fix to start a new run."
+ gh run cancel ${{ github.run_id }}
+
# Validates product.yaml owners against PostHog/posthog collaborator teams.
# Gated on the product_yamls paths filter so we only spend a GitHub API call
# when ownership actually changes. The scoped form (positional product names)
@@ -1400,6 +1427,7 @@ jobs:
timeout-minutes: 20
permissions:
contents: read
+ actions: write # to cancel this run when the OpenAPI check fails
name: Validate OpenAPI types
runs-on: depot-ubuntu-latest
@@ -1595,6 +1623,23 @@ jobs:
env:
GITHUB_TOKEN: ${{ steps.openapi-app-token.outputs.token }}
+ # Schema generation and type drift failures are deterministic — a retry
+ # can never fix them, so the rest of the run is wasted spend. Keyed on the
+ # check step so transient setup or commit failures don't cancel anything.
+ # PR-only and same-repo only: fork PR tokens are read-only.
+ - name: Cancel run on deterministic check failure
+ if: >
+ failure() &&
+ steps.openapi-check.outcome == 'failure' &&
+ github.event_name == 'pull_request' &&
+ github.event.pull_request.head.repo.full_name == github.repository
+ env:
+ GH_TOKEN: ${{ github.token }}
+ GH_REPO: ${{ github.repository }}
+ run: |
+ echo "::notice::OpenAPI check failed deterministically — canceling the remaining jobs in this run. A retry cannot fix this failure; push a fix to start a new run."
+ gh run cancel ${{ github.run_id }}
+
build_django_matrix:
name: Build Django matrix
needs: [changes, get_clickhouse_versions, turbo-discover]