Skip to content

ci: optimize PR workflow — deduplicate build, shallow clones - #1379

Merged
cixzhang merged 4 commits into
mainfrom
navi/ci-optimize
Apr 15, 2026
Merged

cixzhang merged 4 commits into
mainfrom
navi/ci-optimize

Conversation

@cixzhang

@cixzhang cixzhang commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reduces CI overhead with two targeted changes:

1. Deduplicate yarn build from test job

The test job was running yarn test → yarn build → verify-exports → typechecks.
The build job was also running yarn build → verify-exports.

Now:

  • test — only runs yarn test + sync-exports --check
  • build — runs yarn build + verify-exports + typechecks + Storybook + Sandbox

Removes ~1 min of duplicate build work from the test job, and typecheck steps move to build where the output already exists.

2. Shallow clones instead of full history

build and check-components were using fetch-depth: 0 (full clone, ~40s).
Now they do a shallow checkout + targeted git fetch origin main --depth=1 to get just the base ref needed for git diff analysis.

Results

Job Before After
test ~6m50s ~6m12s
build ~6m30s ~6m47s (adds ~4s typecheck, saves ~40s clone)
check-components ~45s ~6s

- Remove duplicate `yarn build` + `verify-exports` from test job
  (already runs in build job). Saves ~1 min on the test critical path.

- Move typecheck steps (component docs, template docs) into build job
  where the build output already exists.

- Replace fetch-depth: 0 with shallow checkout + targeted base fetch
  in both build and check-components jobs. Only fetches what's needed
  for git diff analysis (~40s → ~2s).

Co-authored-by: Navi <[email protected]>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 15, 2026
@github-actions

github-actions Bot commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 15.3KB 24.0KB 3.6KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

Split the monolithic build job into a pipeline:
  build (core) → build-storybook + build-sandbox (parallel) → deploy

Before: build job ran core → Storybook → Sandbox serially (6m27s)
After:  core build (~2m) uploads dist artifact, then Storybook (~1m)
        and Sandbox (~3m) build in parallel on separate runners.

The critical path to PR deploy drops from ~6.5min to ~5min since
Sandbox (3min) and Storybook (1min) now overlap instead of stacking.

PR comment still fires immediately after core build (no wait for
Storybook/Sandbox), so analysis feedback arrives even earlier.

Co-authored-by: Navi <[email protected]>
@cixzhang cixzhang changed the title ci: optimize PR workflow — deduplicate build, shallow clones ci: optimize PR pipeline — parallel builds + dedup + shallow clones Apr 15, 2026
cixzhang and others added 2 commits April 15, 2026 07:34
The artifact sharing approach didn't work — upload-artifact strips
directory prefixes, so dist/ files landed at the wrong paths.

Instead, each parallel job (build-storybook, build-sandbox) runs
yarn build (~1m) locally. Still wins time from parallelism since
Sandbox (3m) and Storybook (1m) overlap.

Co-authored-by: Navi <[email protected]>
The parallel Storybook/Sandbox split added runner overhead that
ate the parallelism gain. Reverted to single build job.

Kept the wins that actually help:
- Removed duplicate yarn build from test job (~1m saved)
- Moved typechecks into build job (where build output exists)
- Shallow clones in build + check-components (~40s saved)

Co-authored-by: Navi <[email protected]>
@cixzhang
cixzhang merged commit 6b498b4 into main Apr 15, 2026
16 checks passed
@cixzhang cixzhang changed the title ci: optimize PR pipeline — parallel builds + dedup + shallow clones ci: optimize PR workflow — deduplicate build, shallow clones Apr 15, 2026
cixzhang added a commit that referenced this pull request Apr 26, 2026
…1379)

* ci: optimize PR workflow — deduplicate build, shallow clones

- Remove duplicate `yarn build` + `verify-exports` from test job
  (already runs in build job). Saves ~1 min on the test critical path.

- Move typecheck steps (component docs, template docs) into build job
  where the build output already exists.

- Replace fetch-depth: 0 with shallow checkout + targeted base fetch
  in both build and check-components jobs. Only fetches what's needed
  for git diff analysis (~40s → ~2s).

Co-authored-by: Navi <[email protected]>

* ci: parallelize Storybook + Sandbox builds for faster PR deploy

Split the monolithic build job into a pipeline:
  build (core) → build-storybook + build-sandbox (parallel) → deploy

Before: build job ran core → Storybook → Sandbox serially (6m27s)
After:  core build (~2m) uploads dist artifact, then Storybook (~1m)
        and Sandbox (~3m) build in parallel on separate runners.

The critical path to PR deploy drops from ~6.5min to ~5min since
Sandbox (3min) and Storybook (1min) now overlap instead of stacking.

PR comment still fires immediately after core build (no wait for
Storybook/Sandbox), so analysis feedback arrives even earlier.

Co-authored-by: Navi <[email protected]>

* fix: build core locally in each parallel job

The artifact sharing approach didn't work — upload-artifact strips
directory prefixes, so dist/ files landed at the wrong paths.

Instead, each parallel job (build-storybook, build-sandbox) runs
yarn build (~1m) locally. Still wins time from parallelism since
Sandbox (3m) and Storybook (1m) overlap.

Co-authored-by: Navi <[email protected]>

* ci: revert parallel split, keep dedup + shallow clones

The parallel Storybook/Sandbox split added runner overhead that
ate the parallelism gain. Reverted to single build job.

Kept the wins that actually help:
- Removed duplicate yarn build from test job (~1m saved)
- Moved typechecks into build job (where build output exists)
- Shallow clones in build + check-components (~40s saved)

Co-authored-by: Navi <[email protected]>

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
…1379)

* ci: optimize PR workflow — deduplicate build, shallow clones

- Remove duplicate `yarn build` + `verify-exports` from test job
  (already runs in build job). Saves ~1 min on the test critical path.

- Move typecheck steps (component docs, template docs) into build job
  where the build output already exists.

- Replace fetch-depth: 0 with shallow checkout + targeted base fetch
  in both build and check-components jobs. Only fetches what's needed
  for git diff analysis (~40s → ~2s).

Co-authored-by: Navi <[email protected]>

* ci: parallelize Storybook + Sandbox builds for faster PR deploy

Split the monolithic build job into a pipeline:
  build (core) → build-storybook + build-sandbox (parallel) → deploy

Before: build job ran core → Storybook → Sandbox serially (6m27s)
After:  core build (~2m) uploads dist artifact, then Storybook (~1m)
        and Sandbox (~3m) build in parallel on separate runners.

The critical path to PR deploy drops from ~6.5min to ~5min since
Sandbox (3min) and Storybook (1min) now overlap instead of stacking.

PR comment still fires immediately after core build (no wait for
Storybook/Sandbox), so analysis feedback arrives even earlier.

Co-authored-by: Navi <[email protected]>

* fix: build core locally in each parallel job

The artifact sharing approach didn't work — upload-artifact strips
directory prefixes, so dist/ files landed at the wrong paths.

Instead, each parallel job (build-storybook, build-sandbox) runs
yarn build (~1m) locally. Still wins time from parallelism since
Sandbox (3m) and Storybook (1m) overlap.

Co-authored-by: Navi <[email protected]>

* ci: revert parallel split, keep dedup + shallow clones

The parallel Storybook/Sandbox split added runner overhead that
ate the parallelism gain. Reverted to single build job.

Kept the wins that actually help:
- Removed duplicate yarn build from test job (~1m saved)
- Moved typechecks into build job (where build output exists)
- Shallow clones in build + check-components (~40s saved)

Co-authored-by: Navi <[email protected]>

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
…1379)

* ci: optimize PR workflow — deduplicate build, shallow clones

- Remove duplicate `yarn build` + `verify-exports` from test job
  (already runs in build job). Saves ~1 min on the test critical path.

- Move typecheck steps (component docs, template docs) into build job
  where the build output already exists.

- Replace fetch-depth: 0 with shallow checkout + targeted base fetch
  in both build and check-components jobs. Only fetches what's needed
  for git diff analysis (~40s → ~2s).


* ci: parallelize Storybook + Sandbox builds for faster PR deploy

Split the monolithic build job into a pipeline:
  build (core) → build-storybook + build-sandbox (parallel) → deploy

Before: build job ran core → Storybook → Sandbox serially (6m27s)
After:  core build (~2m) uploads dist artifact, then Storybook (~1m)
        and Sandbox (~3m) build in parallel on separate runners.

The critical path to PR deploy drops from ~6.5min to ~5min since
Sandbox (3min) and Storybook (1min) now overlap instead of stacking.

PR comment still fires immediately after core build (no wait for
Storybook/Sandbox), so analysis feedback arrives even earlier.


* fix: build core locally in each parallel job

The artifact sharing approach didn't work — upload-artifact strips
directory prefixes, so dist/ files landed at the wrong paths.

Instead, each parallel job (build-storybook, build-sandbox) runs
yarn build (~1m) locally. Still wins time from parallelism since
Sandbox (3m) and Storybook (1m) overlap.


* ci: revert parallel split, keep dedup + shallow clones

The parallel Storybook/Sandbox split added runner overhead that
ate the parallelism gain. Reverted to single build job.

Kept the wins that actually help:
- Removed duplicate yarn build from test job (~1m saved)
- Moved typechecks into build job (where build output exists)
- Shallow clones in build + check-components (~40s saved)


---------
cixzhang pushed a commit that referenced this pull request Jul 19, 2026
…nes (#3865)

The shallow-clone optimization in #1379 (5cf9420) set the default
fetch-depth of 1 on the check-components and build jobs while their
change detection still uses three-dot diffs (origin/main...HEAD), which
require the merge base to exist locally. On a depth-1 clone the diff
fails with "fatal: no merge base" and both consumers swallowed it:

- check-components: the failed diff piped through grep/head yields an
  empty string, so has_components=false and pr-a11y is silently skipped
  on every PR.
- build: analyze-pr.js caught the error and returned [], so the PR
  Analysis Report always posted "New components: none / Modified
  components: none".

Fix, following the depth-50 pattern already proven by check-scope in
the same file:

- check-components + build: fetch-depth: 50 on checkout and --depth=50
  on the base fetch.
- check-components: explicit merge-base guard that fails open
  (has_components=true, with a ::warning) instead of silently skipping
  the a11y audit if the clone is ever too shallow again.
- analyze-pr.js: a failed diff now exits non-zero with ::error instead
  of being reported as "no changes".

Verified with a local bare-repo simulation replicating the
actions/checkout fetch pattern: depth 1 reproduces "fatal: no merge
base" -> has_components=false; depth 50 finds the merge base and
detects the changed component.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant