Skip to content
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

[rush] Introduce a Rush plugin for generating a BuildXL operation graph. #5101

Merged
merged 19 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9c45425
Introduce a NoOpTerminalProvider.
iclanton Feb 11, 2025
e5afa25
Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
09beee4
Introduce a way to test the build graph plugin.
iclanton Feb 11, 2025
a2a39db
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
0458737
Revert "Introduce a way to test the build graph plugin."
iclanton Feb 11, 2025
bc58348
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
70a600c
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
6565fab
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
18e74e1
Document IGraphNode.
iclanton Feb 11, 2025
0c8fc3c
fixup! Document IGraphNode.
iclanton Feb 11, 2025
a1ffc14
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
7e22074
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
3664149
Hold off on publishing the BXL plugin.
iclanton Feb 11, 2025
5776490
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
2713872
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
e04d811
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
07f85e4
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
81668dd
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
b381d47
fixup! Introduce the @rushstack/rush-buildxl-graph-plugin plugin.
iclanton Feb 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/repo-scripts/repo-toolbox](./repo-scripts/repo-toolbox/) | Used to execute various operations specific to this repo |
| [/rigs/local-node-rig](./rigs/local-node-rig/) | A rig package for Node.js projects that build using Heft inside the RushStack repository. |
| [/rigs/local-web-rig](./rigs/local-web-rig/) | A rig package for Web projects that build using Heft inside the RushStack repository. |
| [/rush-plugins/rush-buildxl-graph-plugin](./rush-plugins/rush-buildxl-graph-plugin/) | Rush plugin for generating a BuildXL graph. |
| [/rush-plugins/rush-litewatch-plugin](./rush-plugins/rush-litewatch-plugin/) | An experimental alternative approach for multi-project watch mode |
| [/vscode-extensions/rush-vscode-command-webview](./vscode-extensions/rush-vscode-command-webview/) | Part of the Rush Stack VSCode extension, provides a UI for invoking Rush commands |
| [/vscode-extensions/rush-vscode-extension](./vscode-extensions/rush-vscode-extension/) | Enhanced experience for monorepos that use the Rush Stack toolchain |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/terminal",
"comment": "Introduce a NoOpTerminalProvider.",
"type": "minor"
}
],
"packageName": "@rushstack/terminal"
}
25 changes: 25 additions & 0 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions common/reviews/api/rush-buildxl-graph-plugin.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## API Report File for "@rushstack/rush-buildxl-graph-plugin"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import { IRushPlugin } from '@rushstack/rush-sdk';
import { RushConfiguration } from '@rushstack/rush-sdk';
import { RushSession } from '@rushstack/rush-sdk';

// @public
class DropBuildGraphPlugin implements IRushPlugin {
// (undocumented)
apply(session: RushSession, rushConfiguration: RushConfiguration): void;
// (undocumented)
readonly pluginName: string;
}
export default DropBuildGraphPlugin;

// @public
export interface IBuildXLRushGraph {
// (undocumented)
nodes: IGraphNode[];
// (undocumented)
repoSettings: {
commonTempFolder: string;
};
}

// @public (undocumented)
export interface IGraphNode {
command: string;
dependencies: string[];
id: string;
package: string;
task: string;
workingDirectory: string;
}

// (No @packageDocumentation comment for this package)

```
7 changes: 7 additions & 0 deletions common/reviews/api/terminal.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ export class MockWritable extends TerminalWritable {
reset(): void;
}

// @beta
export class NoOpTerminalProvider implements ITerminalProvider {
get eolCharacter(): string;
get supportsColor(): boolean;
write(data: string, severity: TerminalProviderSeverity): void;
}

// @public
export class NormalizeNewlinesTextRewriter extends TextRewriter {
constructor(options: INormalizeNewlinesTextRewriterOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class ShellOperationRunner implements IOperationRunner {
public readonly silent: boolean = false;
public readonly cacheable: boolean = true;
public readonly warningsAreAllowed: boolean;
public readonly commandToRun: string;

private readonly _commandToRun: string;
private readonly _commandForHash: string;

private readonly _rushProject: RushConfigurationProject;
Expand All @@ -47,7 +47,7 @@ export class ShellOperationRunner implements IOperationRunner {
this.warningsAreAllowed =
EnvironmentConfiguration.allowWarningsInSuccessfulBuild || phase.allowWarningsOnSuccess || false;
this._rushProject = options.rushProject;
this._commandToRun = options.commandToRun;
this.commandToRun = options.commandToRun;
this._commandForHash = options.commandForHash;
}

Expand All @@ -69,14 +69,14 @@ export class ShellOperationRunner implements IOperationRunner {
let hasWarningOrError: boolean = false;

// Run the operation
terminal.writeLine(`Invoking: ${this._commandToRun}`);
terminal.writeLine(`Invoking: ${this.commandToRun}`);

const { rushConfiguration, projectFolder } = this._rushProject;

const { environment: initialEnvironment } = context;

const subProcess: child_process.ChildProcess = Utilities.executeLifecycleCommandAsync(
this._commandToRun,
this.commandToRun,
{
rushConfiguration: rushConfiguration,
workingDirectory: projectFolder,
Expand Down
34 changes: 34 additions & 0 deletions libraries/terminal/src/NoOpTerminalProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import type { ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider';

/**
* Terminal provider that stores written data in buffers separated by severity.
* This terminal provider is designed to be used when code that prints to a terminal
* is being unit tested.
*
* @beta
*/
export class NoOpTerminalProvider implements ITerminalProvider {
/**
* {@inheritDoc ITerminalProvider.write}
*/
public write(data: string, severity: TerminalProviderSeverity): void {
// no-op
}

/**
* {@inheritDoc ITerminalProvider.eolCharacter}
*/
public get eolCharacter(): string {
return '\n';
}

/**
* {@inheritDoc ITerminalProvider.supportsColor}
*/
public get supportsColor(): boolean {
return false;
}
}
1 change: 1 addition & 0 deletions libraries/terminal/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ export {
type IPrefixProxyTerminalProviderOptionsBase,
type IStaticPrefixProxyTerminalProviderOptions
} from './PrefixProxyTerminalProvider';
export { NoOpTerminalProvider } from './NoOpTerminalProvider';
export { TerminalStreamWritable, type ITerminalStreamWritableOptions } from './TerminalStreamWritable';
12 changes: 12 additions & 0 deletions rush-plugins/rush-buildxl-graph-plugin/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');

module.exports = {
extends: [
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
],
parserOptions: { tsconfigRootDir: __dirname }
};
35 changes: 35 additions & 0 deletions rush-plugins/rush-buildxl-graph-plugin/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# THIS IS A STANDARD TEMPLATE FOR .npmignore FILES IN THIS REPO.

# Ignore all files by default, to avoid accidentally publishing unintended files.
*

# Use negative patterns to bring back the specific things we want to publish.
!/bin/**
!/lib/**
!/lib-*/**
!/dist/**

!CHANGELOG.md
!CHANGELOG.json
!heft-plugin.json
!rush-plugin-manifest.json
!ThirdPartyNotice.txt

# Ignore certain patterns that should not get published.
/dist/*.stats.*
/lib/**/test/
/lib-*/**/test/
*.test.js

# NOTE: These don't need to be specified, because NPM includes them automatically.
#
# package.json
# README.md
# LICENSE

# ---------------------------------------------------------------------------
# DO NOT MODIFY ABOVE THIS LINE! Add any project-specific overrides below.
# ---------------------------------------------------------------------------

lib/examples/**
lib-*/examples/**
24 changes: 24 additions & 0 deletions rush-plugins/rush-buildxl-graph-plugin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@rushstack/rush-buildxl-graph-plugin

Copyright (c) Microsoft Corporation. All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
"apiReport": {
"enabled": true,
"reportFolder": "../../../common/reviews/api"
},
"docModel": {
"enabled": false
},
"dtsRollup": {
"enabled": true,
"betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "local-node-rig/profiles/default/config/jest.config.json"
}
7 changes: 7 additions & 0 deletions rush-plugins/rush-buildxl-graph-plugin/config/rig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// The "rig.json" file directs tools to look for their config files in an external package.
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",

"rigPackageName": "local-node-rig"
}
31 changes: 31 additions & 0 deletions rush-plugins/rush-buildxl-graph-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@rushstack/rush-buildxl-graph-plugin",
"version": "5.148.0",
"description": "Rush plugin for generating a BuildXL graph.",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/rushstack",
"directory": "rush-plugins/rush-buildxl-graph-plugin"
},
"homepage": "https://rushjs.io",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"license": "MIT",
"scripts": {
"build": "heft build --clean",
"start": "heft test --clean --watch",
"_phase:build": "heft run --only build -- --clean",
"_phase:test": "heft run --only test -- --clean"
},
"dependencies": {
"@rushstack/node-core-library": "workspace:*",
"@rushstack/rush-sdk": "workspace:*",
"@rushstack/terminal": "workspace:*",
"@rushstack/ts-command-line": "workspace:*"
},
"devDependencies": {
"@microsoft/rush-lib": "workspace:*",
"@rushstack/heft": "workspace:*",
"local-node-rig": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-plugin-manifest.schema.json",
"plugins": [
{
"pluginName": "rush-buildxl-graph-plugin",
"description": "Plugin for providing access to Rush build graph.",
"entryPoint": "lib/index.js"
}
]
}
Loading
Loading