Skip to content

chore(ci): ignore tool caches when listing products for lane names - #76610

Merged
trunk-io[bot] merged 2 commits into
fix/tach-depends-on-comment-parsefrom
trunk-lanes-product-listing
Aug 3, 2026
Merged

chore(ci): ignore tool caches when listing products for lane names#76610
trunk-io[bot] merged 2 commits into
fix/tach-depends-on-comment-parsefrom
trunk-lanes-product-listing

Conversation

@gantoine

@gantoine gantoine commented Aug 3, 2026

Copy link
Copy Markdown
Member

Problem

listProducts treats every directory under products/ as a product, so a local run of the target script picks up the caches that sit beside them and invents a lane for each:

products listed locally: 87
junk entries           : [ '.ruff_cache', '__pycache__' ]

Nothing downstream rejects a nonsense target name, so py:product:.ruff_cache and py:product:__pycache__ end up in the target set and every widened change reports two lanes more than it should.

Note

CI is not affected, so this is hardening rather than a bug fix. A fresh checkout contains only tracked directories, both of these are untracked (git ls-files products/.ruff_cache is empty), and the compute job runs no Python — it checks out, fetches, sets up Node, and runs the script. I checked that before writing the fix, because the fix would otherwise have been justified on a false premise.

What it does cost is that a local run disagrees with CI, which matters because the script is the thing you run by hand to reason about lane behavior. Numbers I gathered locally while working on #76481 and #76483 were inflated by these two entries. The comparisons in those PRs are unaffected — both sides of every diff used the same context — but the absolute lane counts quoted there run about two high.

Changes

Skip directories whose names start with . or __, plus node_modules.

products listed now: 85
junk remaining     : []

A denylist rather than a marker-file allowlist on purpose. Missing a new kind of junk leaves a harmless extra lane that overlaps consistently; excluding a real product would send all of that product's PRs to ALL. Given the two failure modes, the cheap one is the right one to risk.

The filter is also safe in the direction it can be wrong: an unrecognized product name falls through to ALL, so a product that this wrongly dropped would widen rather than narrow.

How did you test this code?

node --test .github/scripts/trunk-impacted-targets.test.js — 37 pass, 1 new.

The new case asserts the four cache names are rejected and three real products accepted. It earns its place because the symptom is silent: no consumer validates target names, so the only way this surfaces is someone puzzling over a local run that disagrees with CI.

Also re-ran buildContext against the working tree before and after, which is where the 87 → 85 numbers above come from.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

Not applicable.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Spotted by Claude (Claude Code) while dry-running the telemetry payload in #76593 and flagged there as a follow-up; this is that follow-up.

Branched off master rather than stacked. It touches listProducts, while #76481 and #76483 touch the workspace and product-classification code further down the same file, so the hunks don't overlap.

Worth a reviewer knowing: four more directories under products/ have no tracked files on master either (deployments, desktop_recordings, discord_app, query_performance_ai). Those are indistinguishable from real products by name, they don't exist in a CI checkout, and they look like leftovers from other branches in a local tree — so this filter deliberately does not try to catch them.

/writing-tests invoked before adding the test case.

@gantoine gantoine self-assigned this Aug 3, 2026
@trunk-io

trunk-io Bot commented Aug 3, 2026

Copy link
Copy Markdown

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@gantoine
gantoine marked this pull request as ready for review August 3, 2026 12:24
Copilot AI review requested due to automatic review settings August 3, 2026 12:24
@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore(ci): ignore tool caches when listi..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens the merge-queue lane target script so local runs don’t invent extra “product” lanes from untracked tool cache directories that can exist alongside real products under products/.

Changes:

  • Add isProductDirectory() and use it in listProducts() to ignore directories starting with . or __, plus node_modules.
  • Add a unit test asserting common cache directory names are rejected while real product names are accepted.
  • Minor formatting change in compileContractMatcher (no functional change intended).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.github/scripts/trunk-impacted-targets.js Filters out cache-like directories when enumerating products; exports helper for test coverage.
.github/scripts/trunk-impacted-targets.test.js Adds regression test to ensure cache directories are not treated as products.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/scripts/trunk-impacted-targets.js Outdated
ruff and pytest leave .ruff_cache and __pycache__ next to the products, so a
local run of the target script invented a lane for each. CI is unaffected: a
fresh checkout holds only tracked directories and the compute job runs no
Python. This keeps a local run answering the same as CI.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gantoine
gantoine force-pushed the trunk-lanes-product-listing branch from f215ebb to 82588e2 Compare August 3, 2026 12:43
@gantoine
gantoine changed the base branch from master to fix/tach-depends-on-comment-parse August 3, 2026 12:44
@gantoine
gantoine requested a review from a team August 3, 2026 13:01
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@trunk-io
trunk-io Bot merged commit d3ee838 into master Aug 3, 2026
195 checks passed
@trunk-io
trunk-io Bot deleted the trunk-lanes-product-listing branch August 3, 2026 16:10
@trunk-io

trunk-io Bot commented Aug 3, 2026

Copy link
Copy Markdown

This pull request was merged into master as part of stacked PR 76483.

@deployment-status-posthog

deployment-status-posthog Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-08-03 16:39 UTC Run
prod-us ✅ Deployed 2026-08-03 16:54 UTC Run
prod-eu ✅ Deployed 2026-08-03 16:57 UTC Run

joethreepwood added a commit that referenced this pull request Aug 5, 2026
…76610)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants