Skip to content

chore: add Lage for dependency-aware incremental builds and tests#7426

Open
janechu wants to merge 9 commits intomainfrom
users/janechu/only-test-what-has-changed
Open

chore: add Lage for dependency-aware incremental builds and tests#7426
janechu wants to merge 9 commits intomainfrom
users/janechu/only-test-what-has-changed

Conversation

@janechu
Copy link
Copy Markdown
Collaborator

@janechu janechu commented Apr 10, 2026

Pull Request

📖 Description

Currently, the CI PR gates run all tests for all packages regardless of what changed. This wastes CI time when only a subset of packages are affected by a PR.

This change integrates Lage as the monorepo task runner to enable dependency-aware, incremental build and test execution. Lage understands the package dependency graph and can selectively run tasks only for changed packages and their dependents using the --since flag.

Key behaviors:

  • For pull requests: CI uses lage --since origin/<base-branch> to only build and test packages that changed or have a changed dependency
  • For pushes to main and scheduled runs: all packages are built and tested (no --since)
  • If Rust crate files (crates/) change, the --since flag is omitted to force a full rebuild (since Rust source lives outside npm workspaces)

🎫 Issues

N/A

👩‍💻 Reviewer Notes

  • lage.config.js defines the task pipeline: build runs in topological order (^build), and test tasks (test:node, test:playwright, test:chromium) depend on build
  • New test:chromium scripts were added to fast-element, fast-html, and fast-ssr to enable Chromium-only test runs without lage passthrough arg conflicts with Rust/cargo builds
  • The fast-html test server was moved to port 5174 to avoid port conflicts when lage runs tests in parallel (fast-element uses 5173)
  • The site package (sites/website) gained explicit devDependencies on @microsoft/fast-build and @microsoft/fast-element — its generate-docs.cjs already imported from these packages, but the implicit dependency was masked by npm's sequential workspace ordering. Lage's parallel builds require the dependency to be declared explicitly
  • The "Detect changed scope" CI step uses shell: bash to ensure the bash script runs correctly on Windows runners (which default to PowerShell)
  • Lage is only used for build/test orchestration; lint/format commands still use biome-changed (already optimized for changed files)

📑 Test Plan

  • Verified lage build correctly builds all packages in dependency order
  • Verified lage test:chromium runs Chromium Playwright tests for affected packages without port conflicts
  • Verified lage --since origin/main correctly scopes to changed packages and their dependents
  • Verified npm run checkchange passes with the included change files
  • CI validated on Linux, macOS, and Windows runners

✅ Checklist

General

  • I have included a change request file using $ npm run change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

⏭ Next Steps

  • Consider adding a remote lage cache (e.g., Azure Blob Storage) for faster CI runs across PRs
  • Monitor CI run times to measure improvement from incremental testing

@janechu janechu force-pushed the users/janechu/only-test-what-has-changed branch from d22d1a0 to 3b038b0 Compare April 10, 2026 22:47
@janechu janechu changed the title feat: add Lage for dependency-aware incremental builds and tests chore: add Lage for dependency-aware incremental builds and tests Apr 11, 2026
janechu and others added 9 commits April 10, 2026 22:28
Integrate Lage as the monorepo task runner to enable incremental,
dependency-aware build and test execution. This replaces the
previous approach of running all tests regardless of what changed.

Changes:
- Add lage.config.js with pipeline for build, test:node,
  test:playwright, test:chromium, and test:rules tasks
- Update root package.json scripts to use lage
- Add test:chromium scripts to fast-element, fast-html, and
  fast-ssr packages for Chromium-only test runs
- Update ci-validate-pr.yml and ci-validate-platforms.yml to
  use lage --since for incremental PR validation
- Add Rust crate change detection to force full builds when
  crates/ files change
- Update CONTRIBUTING.md and copilot-instructions.md with
  lage commands and documentation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lage is installed as a local devDependency and is not available on
the runner PATH. Use npx to resolve it from node_modules/.bin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The site's generate-docs.cjs imports from @microsoft/fast-build
and resolves @microsoft/fast-element, but neither was declared as
a dependency. With npm workspaces this worked because packages
built sequentially before the site. With lage's parallel builds,
the site needs explicit dependencies so lage knows to build
fast-element and fast-build first.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
With lage running tests in parallel, fast-element and fast-html
both used port 5173 for their Vite test servers. When fast-element
tests completed first, Playwright shut down the shared server,
causing all fast-html tests to fail with ERR_CONNECTION_REFUSED.

Assign fast-html to port 5174 so each package has its own server.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The 'Detect changed scope' step uses bash syntax (if/then) which
fails on Windows runners that default to PowerShell.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the multi-step crate detection + output variable approach
with inline GitHub Actions expressions. The --since flag is applied
for pull_request events and omitted for push/schedule events.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu force-pushed the users/janechu/only-test-what-has-changed branch from 387a48b to 4bf13e9 Compare April 11, 2026 05:28
@janechu janechu marked this pull request as ready for review April 11, 2026 05:29
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.

1 participant