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] Implementation of Cobuild feature #3949

Merged
merged 117 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
dc7ad93
feat: AsyncOperationQueue supports remote executing
chengcyber Feb 2, 2023
7b8a521
feat: cobuildlock & cobuildconfiguration
chengcyber Feb 9, 2023
2382a94
chore
chengcyber Feb 10, 2023
fedf61a
fix: async queue
chengcyber Feb 10, 2023
1678c2c
feat: registry of cobuild lock provider & redis cobuild plugin
chengcyber Feb 10, 2023
c2bb3e3
chore
chengcyber Feb 10, 2023
e3839da
feat: rush-redis-cobuild-plugin-integration-test
chengcyber Feb 15, 2023
dbf758f
fix: rush redis cobuild
chengcyber Feb 16, 2023
fe0a50c
fix: changes after rebase
chengcyber Feb 16, 2023
44a1e80
fix: cobuild integration test
chengcyber Feb 17, 2023
662b5ef
:memo: update readme
chengcyber Feb 17, 2023
1a5085f
chore: rush change
chengcyber Feb 17, 2023
d0871f4
chore: tasks.json
chengcyber Feb 17, 2023
c40bfc9
feat: allow failing build to be cached when cobuilding
chengcyber Feb 17, 2023
17754b4
feat: cobuild context id
chengcyber Feb 17, 2023
7c2ec9e
feat: add RUSH_COBUILD_CONTEXT_ID environment variable
chengcyber Feb 17, 2023
64fd7a4
:memo:
chengcyber Feb 17, 2023
e4cfabc
fix: test
chengcyber Feb 17, 2023
e2353fc
chore
chengcyber Feb 20, 2023
27f78f0
chore
chengcyber Feb 22, 2023
afd26fc
refact(ShellOperationRunner): extract build cache related logic to pl…
chengcyber Feb 28, 2023
1daf2bb
chore: improve onComplete in AsyncOperationQueue
chengcyber Mar 14, 2023
6d250a4
chore: use setInterval in PeriodicCallback
chengcyber Mar 14, 2023
00b87cb
refact: CacheableOperationPlugin
chengcyber Mar 14, 2023
67b3c45
chore: store executionQueue in OperationExecutionManager
chengcyber Mar 14, 2023
3649b52
feat: add an unassigned operation in AsyncOperationQueue
chengcyber Mar 14, 2023
c62b646
feat: expand redis-cobuild-plugin configuration with env vars
chengcyber Mar 14, 2023
6f29910
feat: RUSH_COBUILD_CONTEXT_ID is required to opt into running with co…
chengcyber Mar 14, 2023
8b2933a
:memo:
chengcyber Mar 14, 2023
bb6c51a
chore
chengcyber Mar 15, 2023
48cd671
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Mar 15, 2023
6014f5d
chore: update snapshots
chengcyber Mar 15, 2023
e3ce661
Apply suggestions from code review
chengcyber Mar 17, 2023
7e8d793
chore: add catch and reanble no-floating-promise rule
chengcyber Mar 17, 2023
3f40c36
chore: remove DOM lib in tsconfig.json
chengcyber Mar 17, 2023
1cdf9a5
chore: remove context id pattern property in Schema
chengcyber Mar 17, 2023
130bb55
chore: comments the usage of unassigned operation
chengcyber Mar 17, 2023
796aa5d
chore: get projectChangeAnalyzer and selectedPhases from createContext
chengcyber Mar 20, 2023
e0781cd
feat(rush-redis-cobuild-plugin): passwordEnvrionmentVariable
chengcyber Mar 20, 2023
0903eff
feat: always define build cache context, whether shell operation or not
chengcyber Mar 20, 2023
cce3342
refact: before/afterExecuteOperaiton hook
chengcyber Mar 20, 2023
2e99bbf
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Mar 21, 2023
1045680
fix: async operation queue in non cobuild
chengcyber Mar 23, 2023
b2c2e6c
:memo:
chengcyber Mar 27, 2023
51bef48
chore: fix missing exports
chengcyber Apr 3, 2023
4eadd4b
chore: code changes according to code review
chengcyber Apr 3, 2023
30bcc9e
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Apr 3, 2023
a8950a0
feat: cobuild leaf project log only allowed
chengcyber Apr 8, 2023
1c2cae9
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Apr 11, 2023
082f350
chore
chengcyber Apr 11, 2023
c2446d2
Merge remote-tracking branch 'remotes/origin/main' into feat-cobuild
octogonz Apr 22, 2023
820aa3c
Fix merge conflict
octogonz Apr 22, 2023
9c32bf8
chore: connect/disconnect lock provider only cobuild enabled
chengcyber Apr 22, 2023
33182ed
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber May 15, 2023
6358549
feat: cobuild lock provider factory can return promise
chengcyber May 15, 2023
98aeff3
feat: only create cobuild lock provider if needed
chengcyber May 15, 2023
d7a5062
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber May 26, 2023
b0f9700
feat: cobuild runner id
chengcyber May 26, 2023
6f16f27
fix: test
chengcyber May 26, 2023
b1178be
feat: disjoint-set
chengcyber Jun 28, 2023
62930b2
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Jun 28, 2023
9a8fc06
feat: disjointSet getAllSets
chengcyber Jul 10, 2023
e3f116c
refact: clustering operations in cobuilds
chengcyber Jul 11, 2023
b08da17
chore: migrate redis cobuild test repo to use phases
chengcyber Jul 12, 2023
76e968b
:memo:
chengcyber Jul 12, 2023
0b1bb90
chore: comment
chengcyber Jul 19, 2023
e46502c
chore: count on cobuild context id when calculating log only build cache
chengcyber Jul 24, 2023
966b146
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Aug 2, 2023
8392121
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Aug 8, 2023
adac6eb
Apply suggestions from code review
chengcyber Aug 8, 2023
ab678c8
chore: lower the build time of build in the cobuild sandbox repo
chengcyber Aug 8, 2023
7c152ee
chore: housekeeping after suggestion commit
chengcyber Aug 8, 2023
017d01a
chore: remove change json for rush-redis-cobuild-plugin
chengcyber Aug 8, 2023
9b057d0
chore: add a feature note link to change json
chengcyber Aug 8, 2023
a1f232a
chore: remove useless eslint-disable comment
chengcyber Aug 8, 2023
da224ff
chore: set exitCode to 1 before running the logic
chengcyber Aug 8, 2023
c8537a0
chore: merge the assignment
chengcyber Aug 8, 2023
80e39f5
chore: move destroyLockProviderAsync in finally block
chengcyber Aug 8, 2023
70c1add
chore: wrap the lifetime of project writable object between beforeExe…
chengcyber Aug 8, 2023
32b397b
chore: cacheable logic taps to beforeExecuteOperations instead of cre…
chengcyber Aug 8, 2023
4ea76ae
chore: sort grouped operations of each disjoin set
chengcyber Aug 8, 2023
629d864
chore: update comment for isSkipAllowed
chengcyber Aug 8, 2023
c1e8adb
chore: refactor beforeExecute hook of runner to bail hook
chengcyber Aug 8, 2023
80a7990
chore: revert back context.stopWatch to IStopwatchResult
chengcyber Aug 8, 2023
9a5b35e
chore: hoist function definition of beforeExecuteCallback function
chengcyber Aug 8, 2023
d200883
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Aug 8, 2023
6886fb9
Merge remote-tracking branch 'remotes/origin/main' into feat-cobuild
octogonz Aug 8, 2023
eda3e8e
rush update
octogonz Aug 8, 2023
d7ac5f1
refactor: use the operation-level to handle cache interaction
chengcyber Aug 10, 2023
1890144
fix: missing export
chengcyber Aug 10, 2023
fceb88b
fix: Noop command
chengcyber Aug 10, 2023
3c1978b
fix: Noop command
chengcyber Aug 10, 2023
b61235b
feat: throw clear error when writing in the closed project log writer
chengcyber Aug 11, 2023
ba58307
chore: use runner.name to sort operation execution records
chengcyber Aug 11, 2023
19206d2
fix: cache execution logic
chengcyber Aug 11, 2023
a052457
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Aug 14, 2023
6ad5627
Merge remote-tracking branch 'remotes/origin/main' into feat-cobuild
octogonz Aug 16, 2023
9b6b275
Fix build failure
octogonz Aug 16, 2023
c3f9565
rush change
octogonz Aug 16, 2023
32b01df
Regenerate README.md
octogonz Aug 16, 2023
42345f1
TEMPORARY - attempt to highlight a regression.
iclanton Aug 17, 2023
616dee2
fix: log cache/restore in Windows OS
chengcyber Aug 24, 2023
219bc4d
feat: report unhandled exception from afterExecutionOperation
chengcyber Aug 24, 2023
f2539ac
feat: clean up the logReadStream
chengcyber Aug 24, 2023
a4fc098
Merge remote-tracking branch 'origin/main' into feat-cobuild
chengcyber Aug 24, 2023
1df42dd
chore: rush change
chengcyber Aug 24, 2023
5cd047c
Revert "TEMPORARY - attempt to highlight a regression."
octogonz Aug 24, 2023
f5573d2
[rush] Separate Skip and Build Cache, add flag
dmichon-msft Aug 30, 2023
d0a40f1
Merge pull request #7 from dmichon-msft/build-cache-opt-in
chengcyber Aug 30, 2023
eb9a21e
fix: skip cacheable beforeExecution when runner is not cacheable
chengcyber Aug 30, 2023
e65207c
feat: try restore cache once when missing cobuild completed state
chengcyber Aug 30, 2023
996a6b0
Handle async queue being empty
dmichon-msft Aug 30, 2023
655d49c
Merge branch 'main' into feat-cobuild
iclanton Sep 1, 2023
5c659f6
Update changefile.
iclanton Sep 1, 2023
d96b30b
Rename "cobuildEnabled" to "cobuildFeatureEnabled" in "cobuild.json"
iclanton Sep 1, 2023
ff62859
Remove the RUSH_COBUILD_ENABLED env var for now.
iclanton Sep 1, 2023
fac1898
Update the workspace test pnpm-lock.yaml.
iclanton Sep 1, 2023
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ jspm_packages/
*.iml

# Visual Studio Code
.vscode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!*.code-workspace

# Rush temporary files
common/deploy/
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,8 @@ libraries/rush-lib/assets/rush-init/
# These are intentionally invalid files
libraries/heft-config-file/src/test/errorCases/invalidJson/config.json

# common scripts in sandbox repo
build-tests/rush-redis-cobuild-plugin-integration-test/sandbox/repo/common/scripts/

# We'll consider enabling this later; Prettier reformats code blocks, which affects end-user content
*.md
20 changes: 20 additions & 0 deletions .vscode/redis-cobuild.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"folders": [
{
"name": "rush-redis-cobuild-plugin-integration-test",
"path": "../build-tests/rush-redis-cobuild-plugin-integration-test"
},
{
"name": "rush-redis-cobuild-plugin",
"path": "../rush-plugins/rush-redis-cobuild-plugin"
},
{
"name": "rush-lib",
"path": "../libraries/rush-lib"
},
{
"name": ".vscode",
"path": "../.vscode"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('@rushstack/eslint-config/patch/modern-module-resolution');

module.exports = {
extends: ['@rushstack/eslint-config/profile/node'],
parserOptions: { tsconfigRootDir: __dirname }
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
redis-data/dump.rdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cobuild",
"dependsOrder": "sequence",
"dependsOn": ["update", "_cobuild"],
"problemMatcher": []
},
{
"type": "shell",
"label": "_cobuild",
"dependsOn": ["build 1", "build 2"],
"problemMatcher": []
},
{
"type": "shell",
"label": "update",
"command": "node ../../lib/runRush.js update",
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true,
"clear": false
},
"options": {
"cwd": "${workspaceFolder}/sandbox/repo"
}
},
{
"type": "shell",
"label": "build 1",
"command": "node ../../lib/runRush.js --debug cobuild --parallelism 1 --verbose",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/sandbox/repo"
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true,
"clear": true
},
"group": "build"
},
{
"type": "shell",
"label": "build 2",
"command": "node ../../lib/runRush.js --debug cobuild --parallelism 1 --verbose",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/sandbox/repo"
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true,
"clear": true
},
"group": "build"
}
]
}
134 changes: 134 additions & 0 deletions build-tests/rush-redis-cobuild-plugin-integration-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# About

This package enables integration testing of the `RedisCobuildLockProvider` by connecting to an actual Redis created using an [redis](https://hub.docker.com/_/redis) docker image.

# Prerequisites

Docker and docker compose must be installed

# Start the Redis

In this folder run `docker-compose up -d`

# Stop the Redis

In this folder run `docker-compose down`

# Install and build the integration test code

```sh
rush update
rush build -t rush-redis-cobuild-plugin-integration-test
```

# Run the test for lock provider

```sh
# start the docker container: docker-compose up -d
# build the code: rushx build
rushx test-lock-provider
```

# Integration test in sandbox repo

Sandbox repo folder: **build-tests/rush-redis-cobuild-plugin-integration-test/sandbox/repo**

```sh
cd sandbox/repo
rush update
```

## Case 1: Disable cobuild by setting `RUSH_COBUILD_ENABLED=0`

```sh
rm -rf common/temp/build-cache && RUSH_COBUILD_ENABLED=0 node ../../lib/runRush.js --debug cobuild
```

Expected behavior: Cobuild feature is disabled. Run command successfully.

```sh
RUSH_COBUILD_ENABLED=0 node ../../lib/runRush.js --debug cobuild
```

Expected behavior: Cobuild feature is disabled. Build cache was restored successfully.

## Case 2: Cobuild enabled, run one cobuild command only

1. Clear redis server

```sh
(cd ../.. && docker compose down && docker compose up -d)
```

2. Run `rush cobuild` command

```sh
rm -rf common/temp/build-cache && node ../../lib/runRush.js --debug cobuild
```

Expected behavior: Cobuild feature is enabled. Run command successfully.
You can also see cobuild related logs in the terminal.

```sh
Get completed state for cobuild:v1::c2df36270ec5faa8ef6497fa7367a476de3e2861:completed: null
Acquired lock for cobuild:v1::c2df36270ec5faa8ef6497fa7367a476de3e2861:lock: 1, 1 is success
Set completed state for cobuild:v1::c2df36270ec5faa8ef6497fa7367a476de3e2861:completed: SUCCESS;c2df36270ec5faa8ef6497fa7367a476de3e2861
```

## Case 3: Cobuild enabled, run two cobuild commands in parallel

> Note: This test requires Visual Studio Code to be installed.

1. Clear redis server

```sh
(cd ../.. && docker compose down && docker compose up -d)
```

2. Clear build cache

```sh
rm -rf common/temp/build-cache
```

3. Open predefined `.vscode/redis-cobuild.code-workspace` in Visual Studio Code.

4. Open command palette (Ctrl+Shift+P or Command+Shift+P) and select `Tasks: Run Task` and select `cobuild`.

> In this step, two dedicated terminal windows will open. Running `rush cobuild` command under sandbox repo respectively.

Expected behavior: Cobuild feature is enabled, cobuild related logs out in both terminals.

## Case 4: Cobuild enabled, run two cobuild commands in parallel, one of them failed

> Note: This test requires Visual Studio Code to be installed.

1. Making the cobuild command of project "A" fails

**sandbox/repo/projects/a/package.json**

```diff
"scripts": {
- "cobuild": "node ../build.js a",
+ "cobuild": "sleep 5 && exit 1",
"build": "node ../build.js a"
}
```

2. Clear redis server

```sh
(cd ../.. && docker compose down && docker compose up -d)
```

3. Clear build cache

```sh
rm -rf common/temp/build-cache
```

4. Open predefined `.vscode/redis-cobuild.code-workspace` in Visual Studio Code.

5. Open command palette (Ctrl+Shift+P or Command+Shift+P) and select `Tasks: Run Task` and select `cobuild`.

Expected behavior: Cobuild feature is enabled, cobuild related logs out in both terminals. These two cobuild commands fail because of the failing build of project "A". And, one of them restored the failing build cache created by the other one.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Defines configuration used by core Heft.
*/
{
"$schema": "https://developer.microsoft.com/json-schemas/heft/heft.schema.json",

"eventActions": [
{
/**
* The kind of built-in operation that should be performed.
* The "deleteGlobs" action deletes files or folders that match the
* specified glob patterns.
*/
"actionKind": "deleteGlobs",

/**
* The stage of the Heft run during which this action should occur. Note that actions specified in heft.json
* occur at the end of the stage of the Heft run.
*/
"heftEvent": "clean",

/**
* A user-defined tag whose purpose is to allow configs to replace/delete handlers that were added by other
* configs.
*/
"actionId": "defaultClean",

/**
* Glob patterns to be deleted. The paths are resolved relative to the project folder.
*/
"globsToDelete": ["dist", "lib", "temp"]
}
],

/**
* The list of Heft plugins to be loaded.
*/
"heftPlugins": [
// {
// /**
// * The path to the plugin package.
// */
// "plugin": "path/to/my-plugin",
//
// /**
// * An optional object that provides additional settings that may be defined by the plugin.
// */
// // "options": { }
// }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"operationSettings": [
{
"operationName": "build",
"outputFolderNames": ["lib", "dist"]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.7'

services:
redis:
image: redis:6.2.10-alpine
command: redis-server --save "" --loglevel warning --requirepass redis123
ports:
- '6379:6379'
volumes:
- ./redis-data:/data
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "rush-redis-cobuild-plugin-integration-test",
"version": "1.0.0",
"private": true,
"description": "Tests connecting to an redis server",
"license": "MIT",
"scripts": {
"_phase:build": "heft build --clean",
"build": "heft build --clean",
"test-lock-provider": "node ./lib/testLockProvider.js"
},
"devDependencies": {
"@microsoft/rush-lib": "workspace:*",
"@rushstack/eslint-config": "workspace:*",
"@rushstack/heft": "workspace:*",
"@rushstack/node-core-library": "workspace:*",
"@rushstack/rush-redis-cobuild-plugin": "workspace:*",
"@types/http-proxy": "~1.17.8",
"@types/node": "14.18.36",
"eslint": "~8.7.0",
"http-proxy": "~1.18.1",
"typescript": "~4.8.4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Rush temporary files
common/deploy/
common/temp/
common/autoinstallers/*/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"url": "redis://localhost:6379",
"password": "redis123"
}
Loading