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-build-graph-plugin] Add plugin for generating a build graph file for the given command #4626

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
01eae1c
Add rush-build-graph-plugin and a test repo for it
BPapp-MS Apr 8, 2024
6bd00f0
add api-extractor file
BPapp-MS Apr 8, 2024
3a18ab6
ran rush change
BPapp-MS Apr 8, 2024
1d5e9cd
Remove unnecessary props from package.json
BPapp-MS Apr 9, 2024
67f63c7
Update common/changes/@microsoft/rush/user-bpapp-ms-add-graph-plugin_…
BPapp-MS Apr 9, 2024
96fc859
remove private property from package.json
BPapp-MS Apr 9, 2024
4dc7574
remove some files
BPapp-MS Apr 9, 2024
d7c28a2
Add info to package.json
BPapp-MS Apr 9, 2024
2817b4e
Readability in DropBuildGraphPlugin.ts
BPapp-MS Apr 9, 2024
c7e99e3
Remove deep imports
BPapp-MS Apr 9, 2024
441d45c
rm extra graph file
BPapp-MS Apr 9, 2024
f116124
remove checked-in tsdoc-metadata
BPapp-MS Apr 9, 2024
4c44915
Use JsonFile.saveAsync rather than writeFileAsync
BPapp-MS Apr 9, 2024
798faa4
Apply Ian's join suggestion to DropGraph.ts
BPapp-MS Apr 9, 2024
95f79d0
Fix typo in suggestion to DropGraph.ts
BPapp-MS Apr 9, 2024
cb85924
Make test describe pull from name property
BPapp-MS Apr 9, 2024
8f3db69
Fix and organize imports
BPapp-MS Apr 9, 2024
c537284
Rename Params to Options and add Async to dropGraph name
BPapp-MS Apr 9, 2024
07fed01
processOperations Set -> Iterable
BPapp-MS Apr 9, 2024
4eae0e9
Optimize dependency initialization
BPapp-MS Apr 9, 2024
05bfee6
Improve operations map creation
BPapp-MS Apr 9, 2024
85452ff
Create _pruneNoOps result in loop rather than Array.from
BPapp-MS Apr 9, 2024
4eef03f
Take iterable in graph validator
BPapp-MS Apr 9, 2024
cd53c9f
clean up validateGraph
BPapp-MS Apr 9, 2024
6489298
fix type in processOperations
BPapp-MS Apr 9, 2024
676c231
rm rush update files from test repo
BPapp-MS Apr 11, 2024
1a705f5
Refactor test to drop example graph and test it
BPapp-MS Apr 11, 2024
fe98a6b
Update test repo
BPapp-MS Apr 11, 2024
1c18a1f
Adjust imports
BPapp-MS Apr 11, 2024
be406f6
Rename interfaces, add plugin name parameter
BPapp-MS Apr 11, 2024
a294cc0
update test repo
BPapp-MS Apr 11, 2024
42f5e42
Revert pluginName logic
BPapp-MS Apr 11, 2024
70deea5
Add test comments
BPapp-MS Apr 11, 2024
4a5d48d
bump eslint version
BPapp-MS Apr 11, 2024
e1e6e2f
RUSH UPDATE
BPapp-MS Apr 11, 2024
d3efcab
Make the paths agnostic to the rushJsonFolder root
BPapp-MS Apr 12, 2024
1ed5a86
Set stdio inherit
BPapp-MS Apr 12, 2024
f29598f
Add rush autoinstaller flag
BPapp-MS Apr 12, 2024
9724b71
remove unnecessary output
BPapp-MS Apr 29, 2024
0fa80ee
Remove running rush subprocess at jest time
BPapp-MS Apr 29, 2024
9721632
Add documentation to interface properties
BPapp-MS Apr 29, 2024
b413ed7
add license file
BPapp-MS Apr 29, 2024
756a250
add readme
BPapp-MS Apr 29, 2024
d7f6e97
Update repo readme
BPapp-MS Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/rigs/heft-web-rig](./rigs/heft-web-rig/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-web-rig.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-web-rig) | [changelog](./rigs/heft-web-rig/CHANGELOG.md) | [@rushstack/heft-web-rig](https://www.npmjs.com/package/@rushstack/heft-web-rig) |
| [/rush-plugins/rush-amazon-s3-build-cache-plugin](./rush-plugins/rush-amazon-s3-build-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-amazon-s3-build-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-amazon-s3-build-cache-plugin) | | [@rushstack/rush-amazon-s3-build-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-amazon-s3-build-cache-plugin) |
| [/rush-plugins/rush-azure-storage-build-cache-plugin](./rush-plugins/rush-azure-storage-build-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-azure-storage-build-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-azure-storage-build-cache-plugin) | | [@rushstack/rush-azure-storage-build-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-azure-storage-build-cache-plugin) |
| [/rush-plugins/rush-build-graph-plugin](./rush-plugins/rush-build-graph-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-build-graph-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-build-graph-plugin) | | [@rushstack/rush-build-graph-plugin](https://www.npmjs.com/package/@rushstack/rush-build-graph-plugin) |
| [/rush-plugins/rush-http-build-cache-plugin](./rush-plugins/rush-http-build-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-http-build-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-http-build-cache-plugin) | | [@rushstack/rush-http-build-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-http-build-cache-plugin) |
| [/rush-plugins/rush-redis-cobuild-plugin](./rush-plugins/rush-redis-cobuild-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-redis-cobuild-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-redis-cobuild-plugin) | | [@rushstack/rush-redis-cobuild-plugin](https://www.npmjs.com/package/@rushstack/rush-redis-cobuild-plugin) |
| [/rush-plugins/rush-serve-plugin](./rush-plugins/rush-serve-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-serve-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-serve-plugin) | | [@rushstack/rush-serve-plugin](https://www.npmjs.com/package/@rushstack/rush-serve-plugin) |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Introduce the `@rushstack/rush-build-graph-plugin` plugin.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
24 changes: 24 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.

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

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

```ts

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

// @beta
class DropBuildGraphPlugin implements IRushPlugin {
// (undocumented)
apply(session: RushSession, configuration: RushConfiguration): void;
}
export default DropBuildGraphPlugin;

// @beta
export interface IBuildXLRushGraph {
nodes: IGraphNode[];
repoSettings: {
commonTempFolder: string;
};
}

// @beta
export interface IGraphNode {
command: string;
dependencies: string[];
id: string;
package: string;
task: string;
workingDirectory: string;
}

// (No @packageDocumentation comment for this package)

```
12 changes: 12 additions & 0 deletions rush-plugins/rush-build-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 }
};
1 change: 1 addition & 0 deletions rush-plugins/rush-build-graph-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tsdoc-metadata.json
24 changes: 24 additions & 0 deletions rush-plugins/rush-build-graph-plugin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@rushstack/rush-build-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.
8 changes: 8 additions & 0 deletions rush-plugins/rush-build-graph-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Overview
This plugin is used to create json files representing the build graph of a rush action. When used, it only runs through the process of generating Rush's version of the graph, which is then processed and dropped as a file before exiting the process.

## Usage
The plugin is invoked via the `--drop-graph [file]` parameter to rush, which says to run the command as otherwise given, but to drop the graph to the given file and exit before executing the build tasks. The graph is represented as a json object which can be seen under `examples/graph.json`.

## Limitations
It currently only supports shell operations, which is to say that the only supported runner to be passed in from Rush is the ShellOperationRunner.
16 changes: 16 additions & 0 deletions rush-plugins/rush-build-graph-plugin/config/api-extractor.json
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"
}
}
44 changes: 44 additions & 0 deletions rush-plugins/rush-build-graph-plugin/config/heft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json",

"extends": "local-node-rig/profiles/default/config/heft.json",

"phasesByName": {
"build": {
"tasksByName": {
"copy-rush-build-graph-plugin": {
"taskDependencies": ["typescript"],
"taskPlugin": {
"pluginPackage": "@rushstack/heft",
"pluginName": "copy-files-plugin",
"options": {
"copyOperations": [
{
"sourcePath": "lib",
"destinationFolders": [
"rushBuildGraphPluginTestRepo/common/autoinstallers/plugins/node_modules/@rushstack/rush-build-graph-plugin/lib"
],
"fileExtensions": [".json", ".js", ".map"],
"hardlink": true
},
{
"sourcePath": ".",
"includeGlobs": ["rush-plugin-manifest.json"],
"destinationFolders": [
"rushBuildGraphPluginTestRepo/common/autoinstallers/plugins/node_modules/@rushstack/rush-build-graph-plugin/"
]
},
{
"sourcePath": "rushBuildGraphPluginTestRepo/node_modules_mock/",
"destinationFolders": [
"rushBuildGraphPluginTestRepo/common/autoinstallers/plugins/node_modules/"
]
}
]
}
}
}
}
}
}
}
7 changes: 7 additions & 0 deletions rush-plugins/rush-build-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-build-graph-plugin/examples/graph.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"nodes": [
{
"id": "package-a#_phase:build",
"task": "_phase:build",
"package": "package-a",
"dependencies": [],
"workingDirectory": "a",
"command": "heft run build command "
},
{
"id": "package-b#_phase:build",
"task": "_phase:build",
"package": "package-b",
"dependencies": ["package-a#_phase:build"],
"workingDirectory": "b",
"command": "heft run a different build command "
},
{
"id": "package-b#_phase:test",
"task": "_phase:test",
"package": "package-b",
"dependencies": ["package-b#_phase:build"],
"workingDirectory": "b",
"command": "heft run a test command "
}
],
"repoSettings": {
"commonTempFolder": "common/temp"
}
}
33 changes: 33 additions & 0 deletions rush-plugins/rush-build-graph-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@rushstack/rush-build-graph-plugin",
BPapp-MS marked this conversation as resolved.
Show resolved Hide resolved
"version": "0.1.0",
"description": "Plugin for providing access to Rush build graph.",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/rushstack",
"directory": "rush-plugins/rush-build-graph-plugin"
},
"homepage": "https://rushjs.io",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"license": "MIT",
"scripts": {
"build": "heft build --clean",
"test": "heft test --clean",
"clean": "heft clean",
"start": "heft build --clean --watch",
"test-watch": "heft test-watch",
"_phase:build": "heft run --only build -- --clean",
"_phase:test": "heft run --only test -- --clean"
},
"devDependencies": {
"@rushstack/heft": "workspace:*",
"@rushstack/node-core-library": "workspace:*",
"@rushstack/rush-sdk": "workspace:*",
"@rushstack/terminal": "workspace:*",
"local-node-rig": "workspace:*",
"@microsoft/rush-lib": "workspace:*",
"eslint": "~8.57.0"
},
"sideEffects": false
}
10 changes: 10 additions & 0 deletions rush-plugins/rush-build-graph-plugin/rush-plugin-manifest.json
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": "@rushstack/rush-build-graph-plugin",
"description": "Plugin for providing access to Rush build graph.",
"entryPoint": "lib/index.js"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "package-a",
"version": "1.0.0",
"description": "Test package a",
"scripts": {
"_phase:build": "heft run build command"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "package-b",
"version": "1.0.0",
"description": "Test package b",
"dependencies": {
"package-a": "1.0.0"
},
"scripts": {
"_phase:build": "heft run a different build command",
"_phase:test": "heft run a test command"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "plugins",
"version": "1.0.0",
"private": true,
"dependencies": {}
}
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": "@rushstack/rush-build-graph-plugin",
"description": "Plugin for providing access to Rush build graph.",
"entryPoint": "lib/index.js"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* This configuration file defines custom commands for the "rush" command-line.
* More documentation is available on the Rush website: https://rushjs.io
*/
{
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/command-line.schema.json",

/**
* Custom "commands" introduce new verbs for the command-line. To see the help for these
* example commands, try "rush --help", "rush my-bulk-command --help", or
* "rush my-global-command --help".
*/
"commands": [
{
"commandKind": "phased",
"name": "build",
"summary": "run build phases",
"enableParallelism": false,
BPapp-MS marked this conversation as resolved.
Show resolved Hide resolved
"phases": ["_phase:build"],
"watchOptions": {
"alwaysWatch": false,
"watchPhases": ["_phase:build"]
}
},
{
"commandKind": "phased",
"name": "test",
"summary": "run build and test phases",
"enableParallelism": false,
"phases": ["_phase:build", "_phase:test"],
"watchOptions": {
"alwaysWatch": false,
"watchPhases": ["_phase:build", "_phase:test"]
}
}
],

"phases": [
{
"name": "_phase:build",
"dependencies": {
"upstream": ["_phase:build"]
},
// Enforcing this script exists is handled via static validation pipeline
"missingScriptBehavior": "silent"
},
{
"name": "_phase:test",
"dependencies": {
"self": ["_phase:build"]
},
// Enforcing this script exists is handled via static validation pipeline
"missingScriptBehavior": "silent"
}
],

/**
* Custom "parameters" introduce new parameters for specified Rush command-line commands.
* For example, you might define a "--production" parameter for the "rush build" command.
*/
"parameters": [
{
"longName": "--drop-graph",
"parameterKind": "string",
"description": "Drops the build graph to the specified file",
"argumentName": "FILE_PATH",
"associatedCommands": ["build", "test"]
}
]
}