-
Notifications
You must be signed in to change notification settings - Fork 1
ci: build, test, lint only changed packages and dependants #48
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
mikesposito
wants to merge
2
commits into
main
Choose a base branch
from
me/cherry-pick-9373
base: main
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.
Draft
Changes from all commits
Commits
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
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,50 @@ | ||
| import { | ||
| getTypeScriptWorkspaces, | ||
| computeChangedWorkspaces, | ||
| } from './lib/workspaces.mjs'; | ||
|
|
||
| /** | ||
| * Generate a filtered tsconfig.build.json for partial CI builds. | ||
| * | ||
| * Given a merge base SHA, outputs a tsconfig that references only the | ||
| * TypeScript packages that changed since that commit plus their transitive | ||
| * dependants and dependencies. Pipe the output to a temp file and pass it | ||
| * to `ts-bridge --project`. | ||
| * | ||
| * Dependencies are always included because TypeScript project references | ||
| * require every referenced project's dist output to already exist on disk. | ||
| * | ||
| * Usage: `tsx scripts/generate-partial-build-tsconfig.mts <merge-base-sha> [<head-sha>]` | ||
| */ | ||
| async function main(): Promise<void> { | ||
| const mergeBase = process.argv[2]; | ||
| if (!mergeBase) { | ||
| console.error( | ||
| 'Usage: generate-partial-build-tsconfig.mts <merge-base-sha> [<head-sha>]', | ||
| ); | ||
| process.exitCode = 1; | ||
| return; | ||
| } | ||
|
|
||
| const headRef = process.argv[3] ?? 'HEAD'; | ||
|
|
||
| const typeScriptWorkspaces = await getTypeScriptWorkspaces(); | ||
| const { workspaces: packagesToBuild } = await computeChangedWorkspaces({ | ||
| includeDependencies: true, | ||
| mergeBase, | ||
| headRef, | ||
| }); | ||
|
|
||
| const packagesToBuildNames = new Set(packagesToBuild.map(({ name }) => name)); | ||
| const references = typeScriptWorkspaces | ||
| .filter(({ name }) => packagesToBuildNames.has(name)) | ||
| .map(({ location }) => ({ path: `./${location}/tsconfig.build.json` })); | ||
|
|
||
| if (references.length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| console.log(JSON.stringify({ files: [], include: [], references }, null, 2)); | ||
| } | ||
|
|
||
| await main(); |
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,50 @@ | ||
| import yargs from 'yargs'; | ||
| import { hideBin } from 'yargs/helpers'; | ||
|
|
||
| import { computeChangedWorkspaces } from './lib/workspaces.mjs'; | ||
|
|
||
| /** | ||
| * List workspaces that need to be checked given a merge base. | ||
| * | ||
| * Outputs a JSON object to stdout: | ||
| * - `names`: package names of changed workspaces and their transitive dependants | ||
| * - `locations`: workspace-relative paths (e.g. `packages/foo`) for the same set | ||
| * - `hasRootChange`: true if any non-ignored root file changed (triggers a full run) | ||
| * | ||
| * Usage: `tsx scripts/get-changed-workspaces.mts --merge-base <sha> [--head-ref <ref>] [--include-dependencies]` | ||
| */ | ||
| const argv = await yargs(hideBin(process.argv)) | ||
| .usage('$0 --merge-base <sha> [--head-ref <ref>] [--include-dependencies]') | ||
| .option('merge-base', { | ||
| type: 'string', | ||
| describe: 'Merge base SHA', | ||
| demandOption: true, | ||
| }) | ||
| .option('head-ref', { | ||
| type: 'string', | ||
| describe: 'PR branch tip SHA (defaults to HEAD)', | ||
| }) | ||
| .option('include-dependencies', { | ||
| type: 'boolean', | ||
| default: false, | ||
| describe: | ||
| 'Also expand to transitive dependencies (needed for TypeScript builds)', | ||
| }) | ||
| .help() | ||
| .parseAsync(); | ||
|
|
||
| const { mergeBase, headRef = 'HEAD', includeDependencies } = argv; | ||
|
|
||
| const { workspaces, hasRootChange } = await computeChangedWorkspaces({ | ||
| includeDependencies, | ||
| mergeBase, | ||
| headRef, | ||
| }); | ||
|
|
||
| console.log( | ||
| JSON.stringify({ | ||
| names: workspaces.map(({ name }) => name), | ||
| locations: workspaces.map(({ location }) => location), | ||
| hasRootChange, | ||
| }), | ||
| ); |
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.