: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
perf(ci): stop checking out full history to gate the nodejs suite (#126087)
James Greenhill327ba7b2aa83
diff --git a/.agents/skills/authoring-ci-workflows/SKILL.md b/.agents/skills/authoring-ci-workflows/SKILL.mdindex 0aa6b309107a..a4ddd38091da 100644--- a/.agents/skills/authoring-ci-workflows/SKILL.md+++ b/.agents/skills/authoring-ci-workflows/SKILL.md@@ -284,6 +284,10 @@ Measured checkout-step durations, from the GitHub API on real runs:The only reason to check out is that a local action must exist on disk, so sparse-checkout `.github/actions/paths-filter` plus any file the job's own steps read.**Never pass `base: HEAD` to paths-filter from a sparse job** — that routes it to `git diff HEAD`, which a sparse worktree makes return nothing, so every downstream job silently skips green.+- **If one step in a gating job needs history, check the history out in a second, conditional step.**+ `ci-nodejs.yml`'s affected-crate detection diffs the merge base, so its `changes` job used to carry a full-history checkout: 75s of an 80s job (median of 12 runs), and every job in the workflow waits on it.+ A sparse filter-action checkout for the gate first, then a `fetch-depth: 0` + `filter: blob:none` + sparse `rust/ proto/ .github/` checkout behind `steps.filter.outputs.rust == 'true'`, puts the ~2s path on every run that does not touch Rust and leaves Rust runs paying what they paid before.+- **Foot-gun:** `git fetch --deepen=N` with **no refspec** falls back to the wildcard `refs/heads/*` and pulls _every branch_.Always pass an explicit, `--no-tags`, `--filter=blob:none` refspec scoped to the base ref.(Bumping `actions/checkout`'s own `fetch-depth` is safe — it uses a scoped `refs/pull/N/merge` refspec.)diff --git a/.github/workflows/ci-nodejs.yml b/.github/workflows/ci-nodejs.ymlindex 7472e5b708ce..13d7736cff4d 100644--- a/.github/workflows/ci-nodejs.yml+++ b/.github/workflows/ci-nodejs.yml@@ -77,13 +77,16 @@ jobs:test_reason: ${{ steps.select-tests.outputs.reason }}test_file_count: ${{ steps.select-tests.outputs.file_count }}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+ # Only the filter action is read from the tree. The change set itself comes from the+ # pull-request files API, so this step needs no history: reading the whole tree with+ # full history here measured 75s (median of 12 runs) of an 80s job, and every job in+ # this workflow waits on it.- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:clean: falsefilter: blob:none- fetch-depth: 0+ sparse-checkout: .github/actions/paths-filter+ sparse-checkout-cone-mode: false- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1id: app-token@@ -184,6 +187,23 @@ jobs:- '.github/workflows/ci-nodejs.yml'- '.github/actions/setup-uv/**'+ # Affected-crate detection is the only step below that reads the tree, and only a+ # rust/ or proto/ change reaches it. It diffs the merge base, so it needs the full+ # commit graph; it checks that out on its own rather than making every run pay for it.+ # The cone is a superset of the tree ci-rust.yml's affected job gives the same binary.+ - name: Check out the Rust tree for affected-crate detection+ if: github.event_name != 'push' && github.event_name != 'schedule' && steps.filter.outputs.rust == 'true'+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ clean: false+ fetch-depth: 0+ filter: blob:none+ sparse-checkout: |+ .github/+ proto/+ rust/+ sparse-checkout-cone-mode: false+- name: Install rust for affected-crate detection# Not needed on schedule either: the decision step below already returns# nodejs=true there without consulting the affected-crate set.