Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

[CLOV-1868]Part2: extract Backpack Adoption Analyzer - #4915

Merged
Vincent Liu (xiaogliu) merged 9 commits into
mainfrom
xiaogliu/adoption-analyzer
Jul 22, 2026
Merged

Vincent Liu (xiaogliu) merged 9 commits into
mainfrom
xiaogliu/adoption-analyzer

Conversation

@xiaogliu

@xiaogliu Vincent Liu (xiaogliu) commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

image - Keeps both distributable consumers self-contained through esbuild bundling.

Review order

PR 2 of 3. Base: #4909. The public Nx plugin follows in PR 3.

Validation

  • Analyzer lint, 28 tests, and typecheck
  • Guard lint, 5 tests, typecheck, and bundle build
  • Carhire existing Guard job: 74.45%, matching ds-analyser

Vincent Liu and others added 6 commits July 20, 2026 10:16
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]>
@xiaogliu
Vincent Liu (xiaogliu) force-pushed the xiaogliu/adoption-analyzer branch from 9e5de33 to f3b31b6 Compare July 21, 2026 08:38
@xiaogliu Vincent Liu (xiaogliu) added the minor Non breaking change label Jul 22, 2026
@xiaogliu
Vincent Liu (xiaogliu) marked this pull request as ready for review July 22, 2026 02:27
@xiaogliu Vincent Liu (xiaogliu) changed the title Extract Backpack Adoption Analyzer [CLOV-1868]Part2: extract Backpack Adoption Analyzer Jul 22, 2026

@wpe1arhy Iris Li (wpe1arhy) 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.

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

Comment on lines +190 to +196
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;
};

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.

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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Base automatically changed from xiaogliu/implement-part-a to main July 22, 2026 03:47
@@ -0,0 +1,28 @@
{
"name": "@skyscanner/backpack-adoption-analyzer",

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.

If this is shareable code and doesn't deploy it should be in libs/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks — addressed by moving the reusable Analyzer workspace package to libs/backpack-adoption-analyzer in the merge-resolution update.

Copilot AI review requested due to automatic review settings July 22, 2026 04:09
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

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

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-analyzer with exported analysis + guard APIs and Nx wiring.
  • Updates backpack-adoption-guard action 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 / inline style) 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.

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@wpe1arhy Iris Li (wpe1arhy) 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.

LGTM

@xiaogliu
Vincent Liu (xiaogliu) merged commit d47ce22 into main Jul 22, 2026
15 checks passed
@xiaogliu
Vincent Liu (xiaogliu) deleted the xiaogliu/adoption-analyzer branch July 22, 2026 06:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

minor Non breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants