: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
fix(ci): fail hogbox preview open so infra errors don't red the PR (#71622)
Raúl Negrón-Oteroe0d772166a83
diff --git a/.github/workflows/hogbox-preview-env.yml b/.github/workflows/hogbox-preview-env.ymlindex 4d2a99c5f8c1..c7f0904c181d 100644--- a/.github/workflows/hogbox-preview-env.yml+++ b/.github/workflows/hogbox-preview-env.yml@@ -57,7 +57,14 @@# The box is driven entirely by the posthog-hogland SDK (pip-installable, keyless# over hogplane's HTTP API) — no `hogland` CLI binary and no box SSH key needed.-name: Hogbox Preview Environment+# --- OPTIONAL BY DESIGN ---------------------------------------------------------+# A preview never gates a PR: all preview infra (tailnet, hogland, GitHub API, the+# reporters) fails open and reports via the Deployment + sticky comment. Only+# `build-frontend` (PR code — deploy reads its conclusion) and the fork guards still+# red. There is no "yellow" to use instead, and job-level `continue-on-error` still+# reds the PR, so fail-open means step-level. The name prefix is on the JOBS because+# a check run is named after the job, not the workflow.+name: '[Optional] Hogbox Preview Environment'on:pull_request:@@ -107,7 +114,7 @@ jobs:# unlabeled-cancel trap: a no-op event runs only this job, never touches the# `preview`/`teardown` concurrency group, so it can't cancel an active build.decide:- name: decide eligibility+ name: '[Optional] decide eligibility'runs-on: ubuntu-24.04timeout-minutes: 5permissions:@@ -117,8 +124,10 @@ jobs:build: ${{ steps.decide.outputs.build }}teardown: ${{ steps.decide.outputs.teardown }}steps:+ # A blip empties the outputs, so every downstream job skips: no preview, still green.- name: Decide build vs teardown vs skipid: decide+ continue-on-error: trueuses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0with:script: |@@ -206,7 +215,7 @@ jobs:# per-PR concurrency group: announcing must never cancel an in-flight# deploy; build-frontend/deploy below do the coalescing.announce:- name: announce build+ name: '[Optional] announce build'needs: decideif: needs.decide.outputs.build == 'true'runs-on: ubuntu-24.04@@ -219,8 +228,10 @@ jobs:sha: ${{ steps.start.outputs.sha }}deployment_id: ${{ steps.start.outputs.deployment_id }}steps:+ # Cosmetic: on a blip sha/deployment_id go empty, which deploy already tolerates.- name: Announce (deployment + building comment)id: start+ continue-on-error: trueuses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0with:script: |@@ -269,8 +280,10 @@ jobs:# completion wasted (~3.5 min of runner time). No correctness impact — its# artifact is namespaced to its own run_id, so a stale build can't leak into# the winning run's swap.+ # Hard-fails on purpose: it runs PR code, and deploy reads its conclusion to tell+ # a broken FE build from a backend-only PR. deploy matches this `name` literally.build-frontend:- name: build PR frontend+ name: '[Optional] build PR frontend'needs: decideif: needs.decide.outputs.build == 'true'runs-on: ubuntu-24.04@@ -381,8 +394,12 @@ jobs:# "ready" — a reviewer must never open a green link and get :master's# frontend for their frontend PR. The FE build (~3m27s) hides entirely under# the longer bring-up (~6m), so the pipeline is bring-up-bound, not their sum.+ #+ # FAIL-OPEN, so infra failures leave this job green: success()/failure() are+ # meaningless here, the `outcome` step is the verdict. The fork guard is exempt —+ # it must hard-stop before the tailnet and token come online.deploy:- name: deploy preview+ name: '[Optional] deploy preview'needs: [decide, announce]# Runs whenever an eligible build was attempted — even if announce# failed, so the failure reporter below still flips the Deployment +@@ -428,11 +445,15 @@ jobs:# Trusted checkout: the tool code that runs with HOG_TOKEN comes from# the default branch, never the PR.+ # A blip is infra: bring-up then fails into the failure reporter, not a red X.- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ continue-on-error: truewith:ref: ${{ github.event.repository.default_branch }}- name: Connect to Tailscale (tag:hogland-ci)+ id: tailnet+ continue-on-error: trueuses: tailscale/github-action@306e68a486fd2350f2bfc3b19fcd143891a4a2d8 # v4.1.2with:oauth-client-id: ${{ vars.TS_HOGLAND_CI_CLIENT_ID }}@@ -440,6 +461,9 @@ jobs:tags: tag:hogland-ci- name: Mint hogland OIDC token+ id: token+ if: steps.tailnet.outcome == 'success'+ continue-on-error: true# Retry the mint across transient GitHub OIDC hiccups (a ~12-min# outage on 2026-07-09 leaked two preview pens). curl -sf makes an# HTTP error a non-zero exit, but a `curl | jq` pipe takes jq's exit@@ -463,11 +487,16 @@ jobs:# the SDK into an ephemeral env. posthog-hogland is first-party and# exempted from the 7-day soak in [tool.uv].- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0+ id: uv+ if: steps.token.outcome == 'success'+ continue-on-error: truewith:version: '0.11.28' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit- name: Bring up previewid: build+ if: steps.uv.outcome == 'success'+ continue-on-error: truerun: |# Restore the golden, check out the PR, mount its backend source# (posthog/ee/products) over the :master image's /code,@@ -501,10 +530,13 @@ jobs:# FE build has usually long finished, so this returns near-instantly.- name: Wait for the PR frontend buildid: fe+ if: steps.build.outcome == 'success'+ continue-on-error: trueuses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0with:script: |- const jobName = 'build PR frontend';+ // Must match the build-frontend job's `name:` exactly.+ const jobName = '[Optional] build PR frontend';// Ceiling must cover build-frontend's own 30m timeout PLUS// queue time, minus the ~6m of bring-up already elapsed;// 32m keeps us inside deploy's 40m job timeout with margin.@@ -540,14 +572,18 @@ jobs:core.setOutput('swap', swap ? 'true' : 'false');- name: Download frontend dist+ id: distif: steps.fe.outputs.swap == 'true'+ continue-on-error: trueuses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0with:name: hogbox-preview-frontend-distpath: ${{ runner.temp }}/fe-dist- name: Swap in the PR frontend- if: steps.fe.outputs.swap == 'true'+ id: swap+ if: steps.dist.outcome == 'success'+ continue-on-error: trueworking-directory: tools/hogbox-previewrun: |# Lay the freshly-built dist over the running box + re-collectstatic.@@ -558,8 +594,29 @@ jobs:--name "preview-pr-${PR}" \swap-frontend --frontend-dist "${RUNNER_TEMP}/fe-dist/frontend-dist.tgz"+ # dist/swap are 'skipped' on a backend-only PR, which passes; 'failure'+ # would serve :master under a comment claiming the PR's frontend.+ - name: Decide preview outcome+ id: outcome+ if: ${{ !cancelled() }}+ env:+ BRING_UP: ${{ steps.build.outcome }}+ FE_WAIT: ${{ steps.fe.outcome }}+ DIST: ${{ steps.dist.outcome }}+ SWAP: ${{ steps.swap.outcome }}+ run: |+ ok=false+ if [ "$BRING_UP" = success ] && [ "$FE_WAIT" = success ] \+ && [ "$DIST" != failure ] && [ "$SWAP" != failure ]; then+ ok=true+ fi+ echo "bring-up=$BRING_UP fe-wait=$FE_WAIT dist=$DIST swap=$SWAP -> ok=$ok"+ echo "ok=$ok" >> "$GITHUB_OUTPUT"++ # Reporting is auxiliary: an API blip must not red a preview that came up.- name: Report ready (deployment + comment)- if: success()+ if: steps.outcome.outputs.ok == 'true'+ continue-on-error: trueuses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0# SHA + DEP come from the job env (announce job outputs).env:@@ -621,8 +678,11 @@ jobs:if (ex) await github.rest.issues.updateComment({ ...context.repo, comment_id: ex.id, body });else await github.rest.issues.createComment({ ...context.repo, issue_number: pr, body });+ # Load-bearing: runs on the very failures the chain above swallows, so an+ # unguarded API call would hand the red X straight back.- name: Report failure (deployment + comment)- if: failure()+ if: steps.outcome.outputs.ok != 'true'+ continue-on-error: trueuses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0with:script: |@@ -639,7 +699,9 @@ jobs:const body =`${marker}\n### 🦔 Hogbox preview · ❌ build failed\n\n` +`The preview didn't come up for commit \`${(process.env.SHA || '').slice(0, 7)}\`. ` +- `See the **[build log](${runUrl})** for the failing step. It'll retry on the next push.`;+ `See the **[build log](${runUrl})** for the failing step. It'll retry on the next push.\n\n` ++ `<sub>Previews are optional and never block merging. A failure here is often a hogland or tailnet ` ++ `hiccup rather than anything in your PR, so the check stays green and this comment is the status.</sub>`;const { data: comments } = await github.rest.issues.listComments({ ...context.repo, issue_number: pr });const ex = comments.find(c => c.body.includes(marker));if (ex) await github.rest.issues.updateComment({ ...context.repo, comment_id: ex.id, body });@@ -652,7 +714,7 @@ jobs:# nothing is up). The daily stale-sweep in hogbox-preview-cleanup.yml is the# backstop; PR *close* teardown lives in pr-closed.yml.teardown:- name: tear down preview+ name: '[Optional] tear down preview'needs: decideif: needs.decide.outputs.teardown == 'true'# Share the preview job's per-PR group so the latest intent wins: a@@ -674,16 +736,21 @@ jobs:# the trusted default branch, not the PR's (possibly modified) code —# same reasoning as pr-closed.yml's cleanup. Only a destroy call is# needed, so master's copy is correct.+ # Fails open throughout: a missed destroy is reaped by the daily sweep in+ # hogbox-preview-cleanup.yml, so hogland being down never reds the PR.- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ continue-on-error: truewith:ref: ${{ github.event.repository.default_branch }}- name: Connect to Tailscale (tag:hogland-ci)+ continue-on-error: trueuses: tailscale/github-action@306e68a486fd2350f2bfc3b19fcd143891a4a2d8 # v4.1.2with:oauth-client-id: ${{ vars.TS_HOGLAND_CI_CLIENT_ID }}audience: ${{ vars.TS_HOGLAND_CI_AUDIENCE }}tags: tag:hogland-ci- name: Mint hogland OIDC token+ continue-on-error: true# Same retry + empty-token guard as the deploy job: a mint that# silently yields an empty token here would make the destroy fail# with "no API token provided" and leak the box + pen.@@ -700,9 +767,11 @@ jobs:echo "::add-mask::$token"echo "HOG_TOKEN=$token" >> "$GITHUB_ENV"- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0+ continue-on-error: truewith:version: '0.11.28' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit- name: Destroy preview box + pen+ continue-on-error: trueworking-directory: tools/hogbox-previewrun: uv run --no-project --with posthog-hogland==0.3.0 --python 3.12 python -m hogbox_preview --host "$HOG_HOST" --name "preview-pr-${PR}" destroy@@ -712,6 +781,7 @@ jobs:# gets the same treatment from pr-cleanup.yml's deployment reaper.)- name: Deactivate deployment + update commentif: always()+ continue-on-error: trueuses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0with:script: |