-
Notifications
You must be signed in to change notification settings - Fork 625
[Incomplete - for discussion] Add bridge-cache plugin to populate cache without running action #5190
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
Open
benkeen
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
benkeen:benkeen/cache-bridge-plugin
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.
Open
[Incomplete - for discussion] Add bridge-cache plugin to populate cache without running action #5190
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,13 @@ | ||
// 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', | ||
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals', | ||
'local-node-rig/profiles/default/includes/eslint/mixins/tsdoc' | ||
], | ||
parserOptions: { tsconfigRootDir: __dirname } | ||
}; |
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,24 @@ | ||
@rushstack/rush-serve-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. |
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,45 @@ | ||
# @rushstack/rush-bridge-cache-plugin | ||
|
||
This is a Rush plugin that adds an optional `--set-cache-only` flag to Rush's phased commands, so you can other tools to actual run the scripts and generate the build artifacts on disk, then separately populate the Rush cache for particular actions(s). For integrations with other build orchestrators, this allows the best of both worlds: using a different build tool to orchestrate the work, but still populate the Rush cache for benefiting local use of Rush. | ||
|
||
## Here be dragons! | ||
|
||
This is a power-user sort of plugin. It assumes that the work for a particular task has already been completed and the build artifacts have been generated on disk. **If you run this command on a package where the command hasn't already been ran and the build artifacts are missing or incorrect, you will cache invalid content**. Be careful and beware! | ||
|
||
|
||
## Installation | ||
|
||
(TODO) | ||
|
||
`npm install @rushstack/rush-bridge-cache-plugin` | ||
|
||
|
||
## Configuration | ||
|
||
First you need to update your `command-line.json` file to add the new flag. Configure it to target whatever specific commands you want to have this feature. Example: | ||
|
||
```json | ||
{ | ||
"associatedCommands": ["build", "test", "lint", "a11y", "typecheck"], | ||
"description": "When the flag is added to any associated command, it'll bypass running the command itself, but cache the result of a previous run. Beware! Only run when you know the build artifacts are in a valid state for the command.", | ||
"parameterKind": "flag", | ||
"longName": "--set-cache-only", | ||
"required": false | ||
} | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
Any of the rush command can now just be given a `--set-cache-only` property, e.g. | ||
|
||
`rush build --to your-packageX --set-cache-only` | ||
|
||
That will examine `your-packageX` and all of its dependencies, then populate the cache. | ||
|
||
|
||
## Performance | ||
|
||
When running within a pipeline, you'll want to populate the cache as fast as possible. So instead of waiting until the full build graph has been processed, you'll wnt to run it after each successful task. For that, just use Rush's `--only` and target whatever task had just completed, for example: | ||
|
||
`rush lint --only your-packageY --set-cache-only` |
3 changes: 3 additions & 0 deletions
3
rush-plugins/rush-bridge-cache-plugin/config/jest.config.json
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,3 @@ | ||
{ | ||
"extends": "local-node-rig/profiles/default/config/jest.config.json" | ||
} |
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,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" | ||
} |
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,26 @@ | ||
{ | ||
"name": "@rushstack/rush-bridge-cache-plugin", | ||
"version": "0.0.1", | ||
"private": true, | ||
"description": "Rush plugin that provides a --set-cache-only command flag to populates the cache from previous runs.", | ||
"license": "MIT", | ||
"main": "./lib/index.js", | ||
"repository": { | ||
"url": "https://github.com/microsoft/rushstack.git", | ||
"type": "git", | ||
"directory": "rush-plugins/rush-bridge-cache-plugin" | ||
}, | ||
"scripts": { | ||
"build": "heft test --clean", | ||
"_phase:build": "heft run --only build -- --clean", | ||
"_phase:test": "heft run --only test -- --clean" | ||
}, | ||
"devDependencies": { | ||
"@rushstack/node-core-library": "workspace:*", | ||
"@microsoft/rush-lib": "workspace:*", | ||
"@rushstack/rush-sdk": "workspace:*", | ||
"@rushstack/terminal": "workspace:*", | ||
"@rushstack/heft": "workspace:*", | ||
"local-node-rig": "workspace:*" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
rush-plugins/rush-bridge-cache-plugin/rush-plugin-manifest.json
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,10 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-plugin-manifest.schema.json", | ||
"plugins": [ | ||
{ | ||
"pluginName": "rush-bridge-cache-plugin", | ||
"description": "Rush plugin that provides a --set-cache-only command flag to populates the cache from previous runs.", | ||
"entryPoint": "./lib/index.js" | ||
} | ||
] | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This plugin shouldn't be installed by default, so make sure this gets removed before checkin.