Skip to content

Commit

Permalink
Fixing tests and PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaslyang authored and nicholaslyang committed Oct 3, 2023
1 parent a19add8 commit becdae5
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 48 deletions.
25 changes: 23 additions & 2 deletions crates/turborepo-lib/src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,27 @@ impl<'a> Run<'a> {

let scm = SCM::new(&self.base.repo_root);

let filtered_pkgs =
scope::resolve_packages(&opts.scope_opts, &self.base.repo_root, &pkg_dep_graph, &scm)?;
let filtered_pkgs = {
let mut filtered_pkgs = scope::resolve_packages(
&opts.scope_opts,
&self.base.repo_root,
&pkg_dep_graph,
&scm,
)?;

if filtered_pkgs.len() != pkg_dep_graph.len() {
for target in self.targets() {
let task_name = TaskName::from(target.as_str()).into_root_task();

if root_turbo_json.pipeline.contains_key(&task_name) {
filtered_pkgs.insert(WorkspaceName::Root);
break;
}
}
}

filtered_pkgs
};

let global_hash = global_hash_inputs.calculate_global_hash_from_inputs();

Expand Down Expand Up @@ -466,6 +485,8 @@ impl<'a> Run<'a> {
global_env_mode,
self.base.ui,
true,
self.processes.clone(),
&self.base.repo_root,
);

visitor.visit(engine.clone()).await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/run/task_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub const ROOT_PKG_NAME: &str = "//";

/// A task identifier as it will appear in the task graph
#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize)]
#[serde(from = "String")]
#[serde(from = "String", into = "String")]
pub struct TaskId<'a> {
package: Cow<'a, str>,
task: Cow<'a, str>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ Setup

$ cd $TARGET_DIR/outer-no-turbo/apps && ${TURBO} run build --filter=nothing -vv
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: [\-\w\/\.]+ (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: [\-\w\/\.]+ (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: [\-\w\/\.]+ (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: [\-\w\/\.]+ (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" (re)
Error: Could not find turbo.json. Follow directions at https://turbo.build/repo/docs to create one
Expand Down
17 changes: 14 additions & 3 deletions turborepo-tests/integration/tests/inference/no_workspaces.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ Setup
[-0-9:.TWZ+]+ \[DEBUG] turbo: build tag: rust (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=\[] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=b3dc914d74316433 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=dc8feb7ec0a6cc34 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash matches between Rust and Go (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Running build (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
[-0-9:.TWZ+]+ \[DEBUG] turbo: task hashes match (re)

No tasks were executed as part of this run.

Expand All @@ -34,14 +36,19 @@ Setup
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .* (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] turborepo_lib::run::global_hash: global hash env vars \[] (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::run::global_hash: external deps hash: no hash \(single package\) (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::run::scope::filter: Using as a basis for selecting packages (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: build tag: (go|rust) (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=\[] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=b76f12ffa66eaf29 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=999206ff8ba1bf87 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash matches between Rust and Go (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Running build (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
[-0-9:.TWZ+]+ \[DEBUG] turbo: task hashes match (re)

No tasks were executed as part of this run.

Expand All @@ -56,11 +63,15 @@ Setup
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .* (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] turborepo_lib::run::global_hash: global hash env vars \[] (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::run::global_hash: external deps hash: no hash \(single package\) (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::run::scope::filter: Using as a basis for selecting packages (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: build tag: (go|rust) (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=\[] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=cdaabfe0ec87db4e (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=ec249bff3bde08fe (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash matches between Rust and Go (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Running build (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion turborepo-tests/integration/tests/ordered/github.t
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ because otherwise prysk interprets them as multiline commands
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
::group::util:build
util:build: cache bypass, force executing 90d7154e362e3386
util:build: cache bypass, force executing 329a30aa0bee6760
util:build:
util:build: > build
util:build: > sleep 0.5 && echo 'building' && sleep 1 && echo 'completed'
Expand Down
18 changes: 9 additions & 9 deletions turborepo-tests/integration/tests/package_manager.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Setup
$ . ${TESTDIR}/_helpers/setup_monorepo.sh $(pwd) basic_monorepo "[email protected]"

Run test run
$ ${TURBO} run build --__test-run | jq .package_manager
$ TURBO_LOG_VERBOSITY=off ${TURBO} run build --__test-run | jq .package_manager
"npm"

Set package manager to yarn in package.json
$ jq '.packageManager = "[email protected]"' package.json > package.json.tmp && mv package.json.tmp package.json

Run test run
$ ${TURBO} run build --__test-run | jq .package_manager
$ TURBO_LOG_VERBOSITY=off ${TURBO} run build --__test-run | jq .package_manager
"yarn"

Set up .yarnrc.yml
Expand All @@ -20,7 +20,7 @@ Set package manager to berry in package.json
$ jq '.packageManager = "[email protected]"' package.json > package.json.tmp && mv package.json.tmp package.json

Run test run
$ ${TURBO} run build --__test-run | jq .package_manager
$ TURBO_LOG_VERBOSITY=off ${TURBO} run build --__test-run | jq .package_manager
"berry"

Set package manager to pnpm6 in package.json
Expand All @@ -31,14 +31,14 @@ Set up pnpm-workspace.yaml
$ echo " - apps/*" >> pnpm-workspace.yaml

Run test run
$ ${TURBO} run build --__test-run | jq .package_manager
$ TURBO_LOG_VERBOSITY=off ${TURBO} run build --__test-run | jq .package_manager
"pnpm6"

Set package manager to pnpm in package.json
$ jq '.packageManager = "[email protected]"' package.json > package.json.tmp && mv package.json.tmp package.json

Run test run
$ ${TURBO} run build --__test-run | jq .package_manager
$ TURBO_LOG_VERBOSITY=off ${TURBO} run build --__test-run | jq .package_manager
"pnpm"

Clear package manager field in package.json
Expand All @@ -55,15 +55,15 @@ Create yarn.lock
$ touch yarn.lock

Run test run
$ ${TURBO} run build --__test-run | jq .package_manager
$ TURBO_LOG_VERBOSITY=off ${TURBO} run build --__test-run | jq .package_manager
"yarn"

Use yarn 3.5.1
$ corepack prepare yarn@3.5.1 --activate
Preparing yarn@3.5.1 for immediate activation...

Run test run
$ ${TURBO} run build --__test-run | jq .package_manager
$ TURBO_LOG_VERBOSITY=off ${TURBO} run build --__test-run | jq .package_manager
"berry"

Delete yarn.lock
Expand All @@ -73,7 +73,7 @@ Create pnpm-lock.yaml
$ touch pnpm-lock.yaml

Run test run
$ ${TURBO} run build --__test-run | jq .package_manager
$ TURBO_LOG_VERBOSITY=off ${TURBO} run build --__test-run | jq .package_manager
"pnpm"

Delete pnpm-lock.yaml
Expand All @@ -83,5 +83,5 @@ Create package-lock.json
$ touch package-lock.json

Run test run
$ ${TURBO} run build --__test-run | jq .package_manager
$ TURBO_LOG_VERBOSITY=off ${TURBO} run build --__test-run | jq .package_manager
"npm"
8 changes: 8 additions & 0 deletions turborepo-tests/integration/tests/run-logging/verbosity.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Setup

Verbosity level 1
$ ${TURBO} build -v --filter=util --force
waiting for task
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
\xe2\x80\xa2 Packages in scope: util (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -20,6 +21,7 @@ Verbosity level 1
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --verbosity=1 --filter=util --force
waiting for task
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
\xe2\x80\xa2 Packages in scope: util (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand Down Expand Up @@ -50,6 +52,9 @@ Verbosity level 2
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::task_hash: task hash env vars for util:build (re)
vars: \[] (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::task_graph::visitor: task util#build hash is 12af4a2f5c5af4e1 (re)
waiting for task
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::process::child: child process exited normally (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::process::child: child process stopped (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/\.]+" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: build tag: rust (re)
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
Expand Down Expand Up @@ -90,6 +95,9 @@ Verbosity level 2
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::task_hash: task hash env vars for util:build (re)
vars: []
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::task_graph::visitor: task util#build hash is 12af4a2f5c5af4e1 (re)
waiting for task
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::process::child: child process exited normally (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::process::child: child process stopped (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/\.]+" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: build tag: rust (re)
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
Expand Down

0 comments on commit becdae5

Please sign in to comment.