diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 27b36ed5ff7..71ceac2da9e 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -57,6 +57,9 @@ Run all commands from the monorepo root. Use workspace flags to target a single | Build one package | `npm run build -w @microsoft/fast-element` | | Test all | `npm run test` | | Test one package | `npm run test -w @microsoft/fast-element` | +| Test Chromium only | `npm run test:chromium` | +| Build/test changed only | `lage build --since origin/main` | +| Test changed only | `lage test:node test:chromium --since origin/main` | | Lint | `npm run lint` | | Lint fix | `npm run lint:fix` | | Format check | `npm run format:check` | @@ -68,6 +71,8 @@ Run all commands from the monorepo root. Use workspace flags to target a single | Check change files | `npm run checkchange` | | API docs | `npm run doc -w @microsoft/fast-element` | +Build and test commands use [Lage](https://microsoft.github.io/lage/) for dependency-aware task execution. Lage respects the package dependency graph and can run incrementally with `--since ` to only build/test changed packages and their dependents. The CI pipelines use `--since` for pull requests to skip unchanged packages. + All `lint`, `biome:check`, `biome:fix`, and `biome:ci` commands use `biome-changed`, which runs biome only on files with uncommitted git changes. The `format:check` and `format` commands use biome's own `--changed` flag to compare against the default branch. ## Project Structure @@ -127,6 +132,7 @@ Key constraints (details in [TypeScript skill](./skills/typescript/SKILL.md)): | Tool | Purpose | |---|---| | npm workspaces | Package management | +| Lage | Task runner — dependency-aware builds and incremental testing | | TypeScript | Compilation | | Rollup | Bundling (`fast-element` only) | | Playwright | Testing | diff --git a/.github/workflows/ci-validate-platforms.yml b/.github/workflows/ci-validate-platforms.yml index 1c168a96170..17777d9d80a 100644 --- a/.github/workflows/ci-validate-platforms.yml +++ b/.github/workflows/ci-validate-platforms.yml @@ -33,7 +33,9 @@ jobs: git config --global core.eol lf - name: Checkout Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + fetch-depth: 0 - if: ${{ github.event_name == 'pull_request' }} run: | @@ -66,11 +68,11 @@ jobs: run: cargo install wasm-pack - name: Build workspaces - run: npm run build + run: npx lage build ${{ github.event_name == 'pull_request' && '--since origin/main' || '' }} - name: Install playwright dependencies and browsers run: | npx playwright install --with-deps - name: Run tests in all Packages - run: npm run test + run: npx lage test:node test:playwright ${{ github.event_name == 'pull_request' && '--since origin/main' || '' }} diff --git a/.github/workflows/ci-validate-pr.yml b/.github/workflows/ci-validate-pr.yml index 3747690664c..0abf2e46c2d 100644 --- a/.github/workflows/ci-validate-pr.yml +++ b/.github/workflows/ci-validate-pr.yml @@ -52,14 +52,14 @@ jobs: run: cargo install wasm-pack - name: Build workspaces - run: npm run build + run: npx lage build ${{ github.event_name == 'pull_request' && format('--since origin/{0}', github.event.pull_request.base.ref) || '' }} - name: Install playwright dependencies and browsers run: | npx playwright install --with-deps - name: Testing unit tests - run: npm run test:chromium + run: npx lage test:node test:chromium ${{ github.event_name == 'pull_request' && format('--since origin/{0}', github.event.pull_request.base.ref) || '' }} - name: Testing final validation run: npm run test:validation diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c6f4faae99..b95744d0e5f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,6 +55,12 @@ After the initial install, you can re-build all workspaces in the future with: npm run build ``` +Build and test commands are powered by [Lage](https://microsoft.github.io/lage/), which respects the package dependency graph. To build or test only packages that have changed since a given ref, use the `--since` flag: + +```bash +lage build --since origin/main +``` + ### Testing To run all tests for all packages, use the following command: @@ -63,6 +69,18 @@ To run all tests for all packages, use the following command: npm run test ``` +To run only Chromium tests (faster for local development): + +```bash +npm run test:chromium +``` + +To run tests only for packages changed since the `main` branch: + +```bash +lage test:node test:chromium --since origin/main +``` + This command can also be run from within individual package folders to execute only tests from that package. :::note diff --git a/change/@microsoft-fast-element-1775848507.json b/change/@microsoft-fast-element-1775848507.json new file mode 100644 index 00000000000..4979cc52bbc --- /dev/null +++ b/change/@microsoft-fast-element-1775848507.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Add test:chromium script for Chromium-only Playwright test runs", + "packageName": "@microsoft/fast-element", + "email": "7559015+janechu@users.noreply.github.com", + "dependentChangeType": "none" +} diff --git a/change/@microsoft-fast-html-1775848507.json b/change/@microsoft-fast-html-1775848507.json new file mode 100644 index 00000000000..d28889dfb25 --- /dev/null +++ b/change/@microsoft-fast-html-1775848507.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Add test:chromium script for Chromium-only Playwright test runs", + "packageName": "@microsoft/fast-html", + "email": "7559015+janechu@users.noreply.github.com", + "dependentChangeType": "none" +} diff --git a/change/@microsoft-fast-ssr-1775848507.json b/change/@microsoft-fast-ssr-1775848507.json new file mode 100644 index 00000000000..694a059e0b8 --- /dev/null +++ b/change/@microsoft-fast-ssr-1775848507.json @@ -0,0 +1,7 @@ +{ + "type": "none", + "comment": "Add test:chromium script for Chromium-only Playwright test runs", + "packageName": "@microsoft/fast-ssr", + "email": "7559015+janechu@users.noreply.github.com", + "dependentChangeType": "none" +} diff --git a/lage.config.js b/lage.config.js new file mode 100644 index 00000000000..5c85f35286c --- /dev/null +++ b/lage.config.js @@ -0,0 +1,26 @@ +/** @type {import("lage").ConfigOptions} */ +module.exports = { + pipeline: { + build: { + dependsOn: ["^build"], + outputs: ["dist/**", "wasm/**"], + }, + "test:node": { + dependsOn: ["build"], + outputs: [], + }, + "test:playwright": { + dependsOn: ["build"], + outputs: [], + }, + "test:chromium": { + dependsOn: ["build"], + outputs: [], + }, + }, + cacheOptions: { + outputGlob: ["dist/**", "wasm/**"], + environmentGlob: ["package.json", "tsconfig.json", "lage.config.js"], + }, + ignore: ["change/**", "*.md", ".github/**"], +}; diff --git a/package-lock.json b/package-lock.json index edf0c0ccf22..ee8171b244a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,6 +29,7 @@ "esm": "3.2.25", "express": "4.22.1", "glob": "10.5.0", + "lage": "2.15.8", "lefthook": "2.1.4", "rollup": "4.59.0", "rollup-plugin-filesize": "10.0.0", @@ -5121,6 +5122,108 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob-hasher": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/glob-hasher/-/glob-hasher-1.4.2.tgz", + "integrity": "sha512-wYeJvOixB9iAzNpY94AgK0JvOdOQ7g30U+PN0LGSH9u0Y0WC+jIwukjMZ1JZiSoNzUSyrvABZYCNhXpZEoJ/8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "glob-hasher-darwin-arm64": "1.4.2", + "glob-hasher-darwin-x64": "1.4.2", + "glob-hasher-linux-x64-gnu": "1.4.2", + "glob-hasher-win32-arm64-msvc": "1.4.2", + "glob-hasher-win32-x64-msvc": "1.4.2" + } + }, + "node_modules/glob-hasher-darwin-arm64": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/glob-hasher-darwin-arm64/-/glob-hasher-darwin-arm64-1.4.2.tgz", + "integrity": "sha512-zqCZDkDrgo86UsEbOV5wnfyAVlNQ85clGt9EV4LlskDmv2aeuHD6dFYU8hLbbQSC7nvd90EWewy1WqvV6KsL7A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/glob-hasher-darwin-x64": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/glob-hasher-darwin-x64/-/glob-hasher-darwin-x64-1.4.2.tgz", + "integrity": "sha512-yEmIQyr6pGj2RG6IxUpOiVbbTm+lw5+L6MqxdPJvp+Z96YSUIo7aOkru0M8lgFGTRh5fQNDWdoHM6kgK8USYrA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/glob-hasher-linux-x64-gnu": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/glob-hasher-linux-x64-gnu/-/glob-hasher-linux-x64-gnu-1.4.2.tgz", + "integrity": "sha512-7TT8Wfkw41zwfvkbZJ3M3QqWR4bR9qLnbSzcMFHrOIpJjdnvKzCzrqfi470S8sPb6dyEVyS7s49eP5YB8cSy5A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/glob-hasher-win32-arm64-msvc": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/glob-hasher-win32-arm64-msvc/-/glob-hasher-win32-arm64-msvc-1.4.2.tgz", + "integrity": "sha512-HyNotx1CF0/7ulND7CnbLoyuykGeMIARJRzJK36WlcgR+BqkSfcPJEbsbk7AsHhaBOtlUWAbEX9MDndcx8uguQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/glob-hasher-win32-x64-msvc": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/glob-hasher-win32-x64-msvc/-/glob-hasher-win32-x64-msvc-1.4.2.tgz", + "integrity": "sha512-6mKybe2NwFABUA7ZxiiXurD5RXDrrCWwGA53NasfnO4z+hvH5q4jG6YvVhavf6GdTapJi9WwfMHRKvoSQNUxeQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/glob/node_modules/brace-expansion": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz", @@ -5890,6 +5993,25 @@ "node": ">=6" } }, + "node_modules/lage": { + "version": "2.15.8", + "resolved": "https://registry.npmjs.org/lage/-/lage-2.15.8.tgz", + "integrity": "sha512-BgyOYM5suWMIPegAk9zzi65RebpcrVMErJG4DLQxNkD8DA3vHSNu1DX3uEdsuvUc6c7MxPOIPwiA9/23Eh4deQ==", + "dev": true, + "dependencies": { + "glob-hasher": "^1.4.2" + }, + "bin": { + "lage": "dist/lage.js", + "lage-server": "dist/lage-server.js" + }, + "engines": { + "node": ">=16.14.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/lefthook": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/lefthook/-/lefthook-2.1.4.tgz", @@ -8964,6 +9086,10 @@ "@11ty/eleventy-navigation": "^1.0.5", "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2", "@microsoft/api-documenter": "7.29.7" + }, + "devDependencies": { + "@microsoft/fast-build": "^0.3.2", + "@microsoft/fast-element": "^2.10.3" } }, "sites/website/node_modules/@microsoft/api-documenter": { diff --git a/package.json b/package.json index ded0479976b..80308cfcaee 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "scripts": { "bump": "beachball bump", - "build": "npm run build --workspaces --if-present", + "build": "lage build", "change": "beachball change --dependent-change-type none", "checkchange": "beachball check --scope \"!sites/*\" --changehint \"Run 'npm run change' to generate a change file\"", "check": "beachball check ", @@ -39,8 +39,8 @@ "test:diff:error": "echo \"Untracked files exist, try running npm prepare to identify the culprit.\" && exit 1", "test:diff": "git update-index --refresh && git diff-index --quiet HEAD -- || npm run test:diff:error", "test:validation": "npm run test:diff", - "test": "npm run test:node -ws --if-present && npm run test:playwright -ws --if-present -- --project=*", - "test:chromium": "npm run test:node -ws --if-present && npm run test:playwright -ws --if-present -- --project=chromium", + "test": "lage test:node test:playwright", + "test:chromium": "lage test:node test:chromium", "watch": "tsc -p ./tsconfig.json -w --preserveWatchOutput", "format:check": "biome format --changed --no-errors-on-unmatched .", "format": "biome format --changed --no-errors-on-unmatched --fix --write .", @@ -64,6 +64,7 @@ "esm": "3.2.25", "express": "4.22.1", "glob": "10.5.0", + "lage": "2.15.8", "lefthook": "2.1.4", "rollup": "4.59.0", "rollup-plugin-filesize": "10.0.0", diff --git a/packages/fast-element/package.json b/packages/fast-element/package.json index 2963f9ef6fa..ffed07f8cb5 100644 --- a/packages/fast-element/package.json +++ b/packages/fast-element/package.json @@ -114,6 +114,7 @@ "lint": "biome-changed", "lint:fix": "biome-changed -- --fix", "test:playwright": "playwright test", + "test:chromium": "playwright test --project=chromium", "test-server": "npx vite test/ --clearScreen false", "test": "npm run lint && npm run doc:ci && npm run doc:exports:ci && npm run test:playwright", "test:ci": "npm run doc:ci && npm run doc:exports:ci && npm run test:playwright" diff --git a/packages/fast-html/package.json b/packages/fast-html/package.json index c482724b422..50532c91548 100644 --- a/packages/fast-html/package.json +++ b/packages/fast-html/package.json @@ -33,10 +33,10 @@ "lint:fix": "biome-changed -- --fix", "install-playwright-browsers": "npm run playwright install", "prepublishOnly": "npm run clean && npm run build", - "test-server": "npx vite test/ --clearScreen false", + "test-server": "npx vite test/ --clearScreen false --port 5174", "test:playwright": "playwright test", - "test:rules": "sg test --skip-snapshot-tests", - "test": "npm run test:playwright && npm run test:rules", + "test:chromium": "playwright test --project=chromium", + "test": "npm run test:playwright", "test:ui": "concurrently -k -n fast-element,fast-html,playwright \"npm run dev --workspace=@microsoft/fast-element\" \"npm:watch\" \"npx playwright test --ui\"", "watch": "npm run build:tsc -- -w --preserveWatchOutput" }, diff --git a/packages/fast-html/playwright.config.ts b/packages/fast-html/playwright.config.ts index 915d6fab715..1986274e909 100644 --- a/packages/fast-html/playwright.config.ts +++ b/packages/fast-html/playwright.config.ts @@ -20,7 +20,7 @@ export default defineConfig({ ], webServer: { command: "npm run test-server", - port: 5173, + port: 5174, reuseExistingServer: true, }, }); diff --git a/packages/fast-ssr/package.json b/packages/fast-ssr/package.json index 623e9ced5fa..d33d73dc1a1 100644 --- a/packages/fast-ssr/package.json +++ b/packages/fast-ssr/package.json @@ -29,6 +29,7 @@ "test": "npm run test:node && npm run test:playwright", "test:node": "node scripts/run-tests.mjs", "test:playwright": "npm run pretest && playwright test", + "test:chromium": "npm run pretest && playwright test --project=chromium", "test-server": "node server/dist/server.js" }, "deprecated": "This package is deprecated. Please use @microsoft/fast-build and @microsoft/webui instead.", diff --git a/sites/website/package.json b/sites/website/package.json index 37fbf0648f3..be6802599c0 100644 --- a/sites/website/package.json +++ b/sites/website/package.json @@ -27,5 +27,9 @@ "@11ty/eleventy-navigation": "^1.0.5", "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2", "@microsoft/api-documenter": "7.29.7" + }, + "devDependencies": { + "@microsoft/fast-build": "^0.3.2", + "@microsoft/fast-element": "^2.10.3" } }