Repository navigation
[CLOV-1868] Part 1: Add opt-in Nx analysis foundation - #4909
Conversation
Ports ds-analyser's NX project detection into backpack-adoption-guard so a high-adoption project's improvement can no longer mask a regression in a smaller project sharing the same repo. Adds per-project adoption reporting (PR summary tables, Cortex payload) and makes the guard fail when any individual NX project regresses past the threshold, even if the repo-wide percentage is unchanged. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Visit https://backpack.github.io/storybook-prs/4909 to see this build running in a browser. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Ports NX project detection and per-project guard evaluation into backpack-adoption-guard, so adoption regressions in any single NX project can fail the guard even if the repo-wide percentage improves.
Changes:
- Add NX workspace detection + project ownership attribution for analyzed files, including an
(unassigned)bucket. - Evaluate guard status per NX project and combine with repo-wide guard result.
- Emit per-project tables in the PR summary and lightweight per-project metrics in the Cortex payload; document v2 behavior change.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/backpack-adoption-guard/src/shared/types.ts | Extend report/guard/metrics types to include optional per-project NX data. |
| packages/backpack-adoption-guard/src/guard/evaluate-guard.ts | Add per-project guard evaluation and combined status logic. |
| packages/backpack-adoption-guard/src/guard/evaluate-guard-test.ts | Add tests covering per-project guard evaluation and status combining. |
| packages/backpack-adoption-guard/src/analysis/nx-projects.ts | New NX project discovery + longest-prefix resolution utilities. |
| packages/backpack-adoption-guard/src/analysis/nx-projects-test.ts | Add filesystem-based tests for NX detection and resolution. |
| packages/backpack-adoption-guard/src/analysis/analyze-repository.ts | Attribute each file’s results to an NX project bucket and return isNx/projects. |
| packages/backpack-adoption-guard/src/analysis/analyze-repository-test.ts | Add tests ensuring repo totals match per-project totals and non-NX behavior is unchanged. |
| packages/backpack-adoption-guard/src/action/summary.ts | Render per-project adoption tables in the GitHub step summary. |
| packages/backpack-adoption-guard/src/action/run.ts | Include per-project metrics in output and combine guard statuses with per-project results. |
| packages/backpack-adoption-guard/src/action/run-test.ts | Add test verifying per-project metrics are written for NX workspaces. |
| packages/backpack-adoption-guard/README.md | Document per-project NX semantics and v2 migration/pass-fail behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Count every matched file (including parse-error failures) toward its NX project's filesAnalyzed, so per-project totals stay in sync with the repo-wide filesAnalyzed even when analysis fails partway through. - Only attach `projects` to the combined guard result when per-project evaluation actually produced entries, matching the optional typing and the documented non-NX behaviour. - Fix finalizeBucket's stale docstring (no longer converts Set->array). - Use dirname instead of join(path, "..") in the new NX test helper. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Visit https://backpack.github.io/storybook-prs/4909 to see this build running in a browser. |
The repo-wide `pnpm typecheck` runs a bare `tsc` against the root tsconfig (target es5, no downlevelIteration) before running each package's own typecheck target. Iterating a Set directly with for...of isn't allowed under that config (TS2802); collect the project names into an array first, matching the Array.from(new Set(...)) pattern already used elsewhere in this package. Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Visit https://backpack.github.io/storybook-prs/4909 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4909 to see this build running in a browser. |
486c04e to
b9c5a79
Compare
|
Visit https://backpack.github.io/storybook-prs/4909 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4909 to see this build running in a browser. |
Iris Li (wpe1arhy)
left a comment
There was a problem hiding this comment.
LGTM.
Title says Add Nx project-level support, but the description says Removes it. Worth fixing before merge.
👍 update description and let the title more clear. |
Gert-Jan Vercauteren (gert-janvercauteren)
left a comment
There was a problem hiding this comment.
LGTM
* Split Backpack Adoption Guard by NX project Ports ds-analyser's NX project detection into backpack-adoption-guard so a high-adoption project's improvement can no longer mask a regression in a smaller project sharing the same repo. Adds per-project adoption reporting (PR summary tables, Cortex payload) and makes the guard fail when any individual NX project regresses past the threshold, even if the repo-wide percentage is unchanged. Co-Authored-By: Claude Sonnet 5 <[email protected]> * Address Copilot review feedback on PR #4909 - Count every matched file (including parse-error failures) toward its NX project's filesAnalyzed, so per-project totals stay in sync with the repo-wide filesAnalyzed even when analysis fails partway through. - Only attach `projects` to the combined guard result when per-project evaluation actually produced entries, matching the optional typing and the documented non-NX behaviour. - Fix finalizeBucket's stale docstring (no longer converts Set->array). - Use dirname instead of join(path, "..") in the new NX test helper. Co-Authored-By: Claude Sonnet 5 <[email protected]> * Fix React19 typecheck failure in evaluateProjectGuards The repo-wide `pnpm typecheck` runs a bare `tsc` against the root tsconfig (target es5, no downlevelIteration) before running each package's own typecheck target. Iterating a Set directly with for...of isn't allowed under that config (TS2802); collect the project names into an array first, matching the Array.from(new Set(...)) pattern already used elsewhere in this package. Co-Authored-By: Claude Sonnet 5 <[email protected]> * Limit adoption guard to repository metrics * Split analysis/guard logic into backpack-adoption-analyzer package Extracts the pure JSX-analysis engine and pass/fail guard-decision logic (ported from ds-analyser) out of backpack-adoption-guard into a new @skyscanner/backpack-adoption-analyzer package with no @actions/core or GitHub-Actions-specific dependencies. This lets the same core logic be reused by a future NX plugin without pulling in the action's git-worktree/step-summary/env-var-reading concerns. backpack-adoption-guard now depends on the analyzer as a workspace package (TS-source-only, no dist/, consumed via pnpm workspace linking like libs/backpack-storybook-host) and only handles the GitHub Action orchestration: inputs, git worktree checkout, step summary rendering, and exit codes. No behaviour change — verified by inspecting dist/index.js to confirm esbuild inlined the analyzer's source, and all 40 existing tests pass unchanged across both packages. Co-Authored-By: Claude Sonnet 5 <[email protected]> * Keep Nx guard helpers in adoption analyzer * Sync adoption analyzer with ds-analyser visual usage rules * Document analyzer bundling constraint --------- Co-authored-by: Vincent Liu <[email protected]> Co-authored-by: Claude Sonnet 5 <[email protected]>
Summary
project discovery, file-to-project mapping, per-project metric buckets, and
an
(unassigned)bucket.backpack-adoption-guardrepository-wide: the GitHub Action does notenable Nx analysis and does not produce per-project summaries, thresholds, or
blocking decisions.
backpack-adoption-analyzer; the public Nx plugin will enable and consumethe per-project capability separately.
Review order
PR 1 of 3. This introduces the opt-in Nx analysis foundation in the current
Guard codebase. PR #4915 extracts it into
backpack-adoption-analyzer; thepublic Nx plugin follows in PR 3.
Validation