Repository navigation
[CLOV-1868]Part2: extract Backpack Adoption Analyzer - #4915
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]>
- 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]>
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]>
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]>
9e5de33 to
f3b31b6
Compare
Iris Li (wpe1arhy)
left a comment
There was a problem hiding this comment.
Code review
Found 1 issue (reviewed by 5/6 agents — Constitution, A11y/Testing, History, Bug Scanner, Learned Patterns; Sass N/A — no .scss files).
🤖 Generated with Claude Code
| projectResults: Record<string, GuardResult>, | ||
| ): GuardStatus => { | ||
| const statuses = Object.values(projectResults).map((result) => result.status); | ||
| if (statuses.some((status) => status === "fail")) return "fail"; | ||
| if (statuses.some((status) => status === "warn")) return "warn"; | ||
| return overall.status; | ||
| }; |
There was a problem hiding this comment.
combineGuardStatuses masks an overall "fail" as "warn"
When overall is "fail" but no project fails (at most one warns), the function returns "warn" — overall.status is only used in the fallthrough. A real overall failure gets silently downgraded, letting a regressing PR pass the guard.
Fix: include overall.status in the comparison:
const statuses = [overall.status, ...Object.values(projectResults).map((r) => r.status)];
if (statuses.some((s) => s === "fail")) return "fail";
if (statuses.some((s) => s === "warn")) return "warn";
return overall.status;There was a problem hiding this comment.
Thanks — fixed in the merge-resolution update. combineGuardStatuses now evaluates overall.status together with all project statuses, and a regression test verifies that an overall fail cannot be downgraded by project warnings.
| @@ -0,0 +1,28 @@ | |||
| { | |||
| "name": "@skyscanner/backpack-adoption-analyzer", | |||
There was a problem hiding this comment.
If this is shareable code and doesn't deploy it should be in libs/
There was a problem hiding this comment.
Thanks — addressed by moving the reusable Analyzer workspace package to libs/backpack-adoption-analyzer in the merge-resolution update.
|
Visit https://backpack.github.io/storybook-prs/4915 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.
Extracts shared repository-analysis and guard-evaluation logic into the new @skyscanner/backpack-adoption-analyzer library, updates the existing GitHub Action guard to consume it, and aligns non-Backpack visual-component classification with ds-analyser to avoid wrapper double-counting.
Changes:
- Introduces
libs/backpack-adoption-analyzerwith exported analysis + guard APIs and Nx wiring. - Updates
backpack-adoption-guardaction code to import analyzer APIs/types and trims dependencies accordingly. - Revises non-Backpack “visual” counting rules (now based on call-site styling such as
className/ inlinestyle) and updates tests.
Reviewed changes
Copilot reviewed 16 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/backpack-adoption-guard/src/guard/evaluate-guard.ts | Adds project-level guard evaluation and status aggregation helpers. |
| packages/backpack-adoption-guard/src/guard/evaluate-guard-test.ts | Adds a unit test for combineGuardStatuses. |
| packages/backpack-adoption-guard/src/analysis/visual-components.ts | Removes previous visual-component registry implementation. |
| packages/backpack-adoption-guard/src/analysis/jsx-helpers.ts | Adds inline-style attribute detection helper. |
| packages/backpack-adoption-guard/src/analysis/analyze-repository.ts | Switches “visual” classification away from registry to call-site styling checks. |
| packages/backpack-adoption-guard/src/analysis/analyze-repository-test.ts | Updates expectations and adds coverage for new “visual” counting behavior. |
| packages/backpack-adoption-guard/src/action/summary.ts | Switches action types import to analyzer package. |
| packages/backpack-adoption-guard/src/action/run.ts | Switches analysis + evaluateGuard imports to analyzer package. |
| packages/backpack-adoption-guard/package.json | Replaces parser/glob deps with dependency on analyzer workspace package. |
| packages/backpack-adoption-guard/.eslintrc | Disables Nx buildable-lib dependency enforcement for this package. |
| libs/backpack-adoption-analyzer/tsconfig.json | Adds analyzer TS config (noEmit, bundler resolution). |
| libs/backpack-adoption-analyzer/src/index.ts | Exposes analyzer public API surface (analysis, guard, config, types). |
| libs/backpack-adoption-analyzer/project.json | Adds Nx targets for lint/test/typecheck. |
| libs/backpack-adoption-analyzer/package.json | Declares analyzer as build-less TS-source package with exports pointing at TS. |
| libs/backpack-adoption-analyzer/jest.config.js | Adds Jest config for analyzer tests (babel-jest). |
| libs/backpack-adoption-analyzer/.eslintrc | Adds analyzer-specific ESLint config. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Visit https://backpack.github.io/storybook-prs/4915 to see this build running in a browser. |
Summary
backpack-adoption-analyzer.backpack-adoption-guardat its existing GitHub Action path; it consumes the analyzer and remains repository-wide only.ds-analyser, restoring Carhire adoption from 58.38% to 74.45%. Carhire testing PR https://github.com/Skyscanner/carhire-homepage/actions/runs/29815905872/job/88815261254Review order
PR 2 of 3. Base: #4909. The public Nx plugin follows in PR 3.
Validation
ds-analyser