Repository navigation
perf(ci): Build SDK dependencies within CI jobs #26732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
nicohrubec
wants to merge
11
commits into
develop
Choose a base branch
from
feat/benchmark-local-sdk-builds
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+424
−255
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
407d54b
perf(ci): Benchmark building SDKs directly in test jobs
nicohrubec 31bfdc0
perf(ci): Expand independent SDK build comparisons
nicohrubec c5cbfd9
perf(ci): Benchmark complete integration and browser matrices
nicohrubec b8318b7
perf(ci): Build SDK outputs directly in all test jobs
nicohrubec f55dc80
perf(ci): Scope local builds to each test job dependency graph
nicohrubec b68b96f
perf(ci): Include nested app dependencies and custom Nx targets
nicohrubec 66efa20
fix(ci): Build SDK dependencies for bundler compatibility tests
nicohrubec 5d8302d
perf(ci): Cache a standalone Nx runtime for planning
nicohrubec f4f9c59
fix(ci): Dereference planner runtime dependencies when copying
nicohrubec a42ac66
refactor(ci): Remove obsolete shared-build setup
nicohrubec 2dfa1dd
refactor(ci): Share SDK build execution with the central build
nicohrubec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: 'Build SDK packages locally' | ||
| description: 'Restore workspace dependencies and build the SDK outputs needed by this job.' | ||
| inputs: | ||
| setup: | ||
| description: 'Set up the build Node version and restore workspace dependencies.' | ||
| default: 'true' | ||
| package-path: | ||
| description: 'Comma-separated package paths whose SDK dependencies to build; use . only for repo-wide checks.' | ||
| default: '' | ||
| targets: | ||
| description: 'Nx targets to build for the selected packages and their dependencies.' | ||
| default: 'build:transpile build:types' | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Set up build Node | ||
| if: inputs.setup == 'true' | ||
| uses: ./.github/actions/setup-node | ||
| - name: Restore workspace dependencies | ||
| if: inputs.setup == 'true' | ||
| uses: ./.github/actions/install-dependencies | ||
| - name: Select SDK packages | ||
| id: projects | ||
| env: | ||
| INPUT_PACKAGE_PATH: ${{ inputs.package-path }} | ||
| run: node "$GITHUB_ACTION_PATH/select-projects.mjs" >> "$GITHUB_OUTPUT" | ||
| shell: bash | ||
| - name: Build SDK packages | ||
| env: | ||
| BUILD_PROJECTS: ${{ steps.projects.outputs.projects }} | ||
| run: | | ||
| node scripts/verify-packages-versions.js | ||
| pnpm exec nx run-many -t ${{ inputs.targets }} --projects="$BUILD_PROJECTS" --parallel=4 | ||
| shell: bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { execFileSync } from 'node:child_process'; | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
|
|
||
| const readPackage = directory => JSON.parse(fs.readFileSync(path.join(directory, 'package.json'), 'utf8')); | ||
| const workspaces = readPackage('.').workspaces; | ||
| const names = new Set(workspaces.map(directory => readPackage(directory).name)); | ||
| const packagePath = process.env.INPUT_PACKAGE_PATH; | ||
| if (!packagePath) { | ||
| throw new Error('Select a package path, or explicitly use . for repo-wide checks.'); | ||
| } | ||
| const roots = [ | ||
| ...new Set( | ||
| packagePath.split(',').flatMap(directory => { | ||
| if (directory === '.') { | ||
| return [...names]; | ||
| } | ||
| if (workspaces.includes(directory)) { | ||
| return [readPackage(directory).name]; | ||
| } | ||
| return fs.globSync('**/package.json', { cwd: directory, exclude: ['**/node_modules/**'] }).flatMap(file => { | ||
| const manifest = readPackage(path.join(directory, path.dirname(file))); | ||
| return Object.keys({ ...manifest.dependencies, ...manifest.devDependencies }).filter(name => names.has(name)); | ||
| }); | ||
| }), | ||
| ), | ||
| ]; | ||
| if (!roots.length) { | ||
| throw new Error(`No workspace dependencies found for ${packagePath}`); | ||
| } | ||
|
|
||
| // pnpm's ... selector includes workspace dependencies, including shared test runners and build tools. | ||
| const packages = JSON.parse( | ||
| execFileSync('pnpm', [...roots.flatMap(name => ['--filter', `${name}...`]), '-r', 'list', '--depth=-1', '--json'], { | ||
| encoding: 'utf8', | ||
| }), | ||
| ); | ||
| const projects = packages.map(pkg => pkg.name); | ||
| if (!projects.length) { | ||
| throw new Error(`No SDK build projects selected for ${packagePath}`); | ||
| } | ||
| process.stderr.write(`Selected ${projects.length} workspace projects for ${packagePath}: ${projects.join(', ')}\n`); | ||
| process.stdout.write(`projects=${projects.join(',')}\n`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: 'Set up Nx planner' | ||
| description: 'Restores only the locked Nx runtime needed for affected-project selection.' | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Compute planner cache key | ||
| id: dependencies | ||
| shell: bash | ||
| run: | | ||
| node scripts/dependency-hash-key.js >> "$GITHUB_OUTPUT" | ||
| if [ -x node_modules/.bin/nx ]; then echo 'installed=true' >> "$GITHUB_OUTPUT"; fi | ||
|
|
||
| - name: Restore Nx runtime | ||
| id: cache | ||
| uses: actions/cache@v6.1.0 | ||
| with: | ||
| path: ${{ runner.temp }}/nx-planner | ||
| key: nx-planner-v2-${{ steps.dependencies.outputs.hash }}-${{ runner.os }}-${{ runner.arch }} | ||
|
|
||
| # A miss uses the regular install; develop also seeds this cache from its existing install. | ||
| - name: Install dependencies on cache miss | ||
| if: steps.cache.outputs.cache-hit != 'true' && steps.dependencies.outputs.installed != 'true' | ||
| uses: ./.github/actions/install-dependencies | ||
|
|
||
| - name: Package Nx runtime | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| shell: bash | ||
| run: node "$GITHUB_ACTION_PATH/package-runtime.mjs" "$RUNNER_TEMP/nx-planner" | ||
|
|
||
| - name: Use cached Nx runtime | ||
| if: steps.cache.outputs.cache-hit == 'true' && steps.dependencies.outputs.installed != 'true' | ||
| shell: bash | ||
| run: ln -s "$RUNNER_TEMP/nx-planner/node_modules" node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import fs from 'node:fs'; | ||
| import { execFileSync } from 'node:child_process'; | ||
| import path from 'node:path'; | ||
| import { createRequire } from 'node:module'; | ||
|
|
||
| const require = createRequire(path.join(process.cwd(), 'package.json')); | ||
| const nxPackage = fs.realpathSync(require.resolve('nx/package.json')); | ||
| const destination = path.resolve(process.argv[2]); | ||
| const modules = path.join(destination, 'node_modules'); | ||
|
|
||
| // Nx lists its runtime dependency closure directly; pnpm links it all in this directory. | ||
| const nxDependencies = path.resolve(nxPackage, '../..'); | ||
| fs.rmSync(destination, { recursive: true, force: true }); | ||
| fs.mkdirSync(destination, { recursive: true }); | ||
| execFileSync('cp', ['-RL', nxDependencies, modules]); | ||
| // Nx's pnpm lockfile reader requires the install metadata, even without workspace dependencies. | ||
| fs.copyFileSync('node_modules/.modules.yaml', path.join(modules, '.modules.yaml')); | ||
| fs.mkdirSync(path.join(modules, '.bin'), { recursive: true }); | ||
| fs.symlinkSync('../nx/dist/bin/nx.js', path.join(modules, '.bin/nx')); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.