Skip to content

Commit

Permalink
Root inference: skip turbo.json (#3946)
Browse files Browse the repository at this point in the history
Integration tests for inferring the root. This demonstrates that detection based upon `turbo.json` (and the change made in #3938) is not (particularly) relevant to root identification.

How to review:
- Each commit is pretty self-contained. You can see me adding a debug line to assert against in the first commit.
- The third commit is both a revert of #3938 and a full deletion of the `turbo.json`-included detection logic.

<details>
<summary>OUTDATED</summary>
There is _one_ behavior change. If you previously:
1. Had nested workspaces (which is not supported by us or any package manager).
2. Had a `turbo.json` at the "outer" one.
3. Did _not_ have a `turbo.json` at the "inner" one

Then we would have selected the outer one. We now select the inner one, and throw an error because the inner one does not have a `turbo.json`. I believe this to be an _improvement_.
</details>

***

#3938 treats any `turbo.json` that has comments in it as nonexistent since `serde_json` doesn't support JSONC. That everything still worked with parsing that is throwing an error made it clear that the `turbo.json` check was not being used except for the described edge case.
  • Loading branch information
nathanhammond committed Feb 27, 2023
1 parent c9c9e2f commit b75b04d
Show file tree
Hide file tree
Showing 58 changed files with 676 additions and 56 deletions.
2 changes: 2 additions & 0 deletions cli/integration_tests/basic_monorepo/verbosity.t
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Verbosity level 2
$ ${TURBO} build -vv --filter=util --force
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/verbosity\.t (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Running command as global turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
Expand Down Expand Up @@ -69,6 +70,7 @@ Verbosity level 2
$ ${TURBO} build --verbosity=2 --filter=util --force
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/verbosity\.t (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Running command as global turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
Expand Down
113 changes: 113 additions & 0 deletions cli/integration_tests/inference/has-workspaces.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
Setup
$ . ${TESTDIR}/../setup.sh
$ . ${TESTDIR}/setup.sh $(pwd) "has-workspaces"

$ cd $TARGET_DIR && ${TURBO} run build --filter=nothing -vv
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/has-workspaces\.t (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Running command as global turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=c1fb8f74a026cdb8 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Packages in scope: (esc)
\xe2\x80\xa2 Running build in 0 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

No tasks were executed as part of this run.

Tasks: 0 successful, 0 total
Cached: 0 cached, 0 total
Time:\s*[\.0-9]+m?s (re)

$ cd $TARGET_DIR/apps/web && ${TURBO} run build --filter=nothing -vv
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/has-workspaces\.t (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Running command as global turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "apps/web" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Using apps/web as a basis for selecting packages (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=c1fb8f74a026cdb8 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Packages in scope: (esc)
\xe2\x80\xa2 Running build in 0 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

No tasks were executed as part of this run.

Tasks: 0 successful, 0 total
Cached: 0 cached, 0 total
Time:\s*[\.0-9]+m?s (re)

$ cd $TARGET_DIR/crates && ${TURBO} run build --filter=nothing -vv
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/has-workspaces\.t (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Running command as global turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "crates" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Using crates as a basis for selecting packages (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=c1fb8f74a026cdb8 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Packages in scope: (esc)
\xe2\x80\xa2 Running build in 0 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

No tasks were executed as part of this run.

Tasks: 0 successful, 0 total
Cached: 0 cached, 0 total
Time:\s*[\.0-9]+m?s (re)

$ cd $TARGET_DIR/crates/super-crate/tests/test-package && ${TURBO} run build --filter=nothing -vv
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/has-workspaces\.t (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Running command as global turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "crates/super-crate/tests/test-package" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Using crates/super-crate/tests/test-package as a basis for selecting packages (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=c1fb8f74a026cdb8 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Packages in scope: (esc)
\xe2\x80\xa2 Running build in 0 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

No tasks were executed as part of this run.

Tasks: 0 successful, 0 total
Cached: 0 cached, 0 total
Time:\s*[\.0-9]+m?s (re)

$ cd $TARGET_DIR/packages/ui-library/src && ${TURBO} run build --filter=nothing -vv
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/has-workspaces\.t (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Running command as global turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "packages/ui-library/src" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Using packages/ui-library/src as a basis for selecting packages (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=c1fb8f74a026cdb8 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Packages in scope: (esc)
\xe2\x80\xa2 Running build in 0 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

No tasks were executed as part of this run.

Tasks: 0 successful, 0 total
Cached: 0 cached, 0 total
Time:\s*[\.0-9]+m?s (re)

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "docs"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "web"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "test-package"
}
9 changes: 9 additions & 0 deletions cli/integration_tests/inference/has-workspaces/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "inference",
"workspaces": [
"apps/*",
"packages/*",
"crates/super-crate/tests/test-package"
],
"packageManager": "npm@8.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "eslint-config-custom"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "ui-library"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"pipeline": {}
}
7 changes: 7 additions & 0 deletions cli/integration_tests/inference/has-workspaces/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Has a comment!
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {}
}
}
Loading

0 comments on commit b75b04d

Please sign in to comment.