Skip to content

Commit

Permalink
chore: remove globalDotEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-olszewski committed May 20, 2024
1 parent b668d5a commit c65090c
Show file tree
Hide file tree
Showing 16 changed files with 7 additions and 103 deletions.
3 changes: 0 additions & 3 deletions crates/turborepo-lib/src/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ pub struct GlobalHashable<'a> {
pub pass_through_env: &'a [String],
pub env_mode: EnvMode,
pub framework_inference: bool,
pub dot_env: &'a [turbopath::RelativeUnixPathBuf],
}

pub struct LockFilePackages(pub Vec<turborepo_lockfiles::Package>);
Expand Down Expand Up @@ -411,8 +410,6 @@ mod test {
pass_through_env: &["pass_through_env".to_string()],
env_mode: EnvMode::Infer,
framework_inference: true,

dot_env: &[turbopath::RelativeUnixPathBuf::new("dotenv".to_string()).unwrap()],
};

assert_eq!(global_hash.hash(), "2144612ff08bddb9");
Expand Down
1 change: 0 additions & 1 deletion crates/turborepo-lib/src/run/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ impl RunBuilder {
&root_package_json,
is_single_package,
)?;
root_turbo_json.track_usage(&run_telemetry);

pkg_dep_graph.validate()?;

Expand Down
19 changes: 1 addition & 18 deletions crates/turborepo-lib/src/run/global_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub struct GlobalHashableInputs<'a> {
pub pass_through_env: Option<&'a [String]>,
pub env_mode: EnvMode,
pub framework_inference: bool,
pub dot_env: Option<&'a [RelativeUnixPathBuf]>,
pub env_at_execution_start: &'a EnvironmentVariableMap,
}

Expand All @@ -63,7 +62,6 @@ pub fn get_global_hash_inputs<'a, L: ?Sized + Lockfile>(
global_pass_through_env: Option<&'a [String]>,
env_mode: EnvMode,
framework_inference: bool,
dot_env: Option<&'a [RelativeUnixPathBuf]>,
hasher: &SCM,
) -> Result<GlobalHashableInputs<'a>, Error> {
let global_hashable_env_vars =
Expand All @@ -90,19 +88,7 @@ pub fn get_global_hash_inputs<'a, L: ?Sized + Lockfile>(
.map(|p| root_path.anchor(p).expect("path should be from root"))
.collect::<Vec<_>>();

let mut global_file_hash_map =
hasher.get_hashes_for_files(root_path, &global_deps_paths, false)?;

if !dot_env.unwrap_or_default().is_empty() {
let system_dot_env = dot_env
.into_iter()
.flatten()
.map(|p| p.to_anchored_system_path_buf());

let dot_env_object = hasher.hash_existing_of(root_path, system_dot_env)?;

global_file_hash_map.extend(dot_env_object);
}
let global_file_hash_map = hasher.get_hashes_for_files(root_path, &global_deps_paths, false)?;

debug!(
"external deps hash: {}",
Expand All @@ -118,7 +104,6 @@ pub fn get_global_hash_inputs<'a, L: ?Sized + Lockfile>(
pass_through_env: global_pass_through_env,
env_mode,
framework_inference,
dot_env,
env_at_execution_start,
})
}
Expand Down Expand Up @@ -190,7 +175,6 @@ impl<'a> GlobalHashableInputs<'a> {
pass_through_env: self.pass_through_env.unwrap_or_default(),
env_mode: self.env_mode,
framework_inference: self.framework_inference,
dot_env: self.dot_env.unwrap_or_default(),
};

global_hashable.hash()
Expand Down Expand Up @@ -240,7 +224,6 @@ mod tests {
None,
EnvMode::Infer,
false,
None,
&SCM::new(&root),
);
assert!(result.is_ok());
Expand Down
1 change: 0 additions & 1 deletion crates/turborepo-lib/src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ impl Run {
pass_through_env,
env_mode,
self.opts.run_opts.framework_inference,
self.root_turbo_json.global_dot_env.as_deref(),
&self.scm,
)?
};
Expand Down
4 changes: 0 additions & 4 deletions crates/turborepo-lib/src/run/summary/global_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub struct GlobalHashSummary<'a> {
pub root_key: &'static str,
pub files: BTreeMap<RelativeUnixPathBuf, String>,
pub hash_of_external_dependencies: &'a str,
pub global_dot_env: Option<&'a [RelativeUnixPathBuf]>,
pub environment_variables: GlobalEnvVarSummary<'a>,
}

Expand All @@ -46,7 +45,6 @@ impl<'a> TryFrom<GlobalHashableInputs<'a>> for GlobalHashSummary<'a> {
env,
resolved_env_vars,
pass_through_env,
dot_env,
env_at_execution_start,
..
} = global_hashable_inputs;
Expand Down Expand Up @@ -80,8 +78,6 @@ impl<'a> TryFrom<GlobalHashableInputs<'a>> for GlobalHashSummary<'a> {
.map(|vars| vars.by_source.matching.to_secret_hashable()),
pass_through,
},

global_dot_env: dot_env,
})
}
}
10 changes: 0 additions & 10 deletions crates/turborepo-lib/src/run/summary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,16 +499,6 @@ impl<'a> RunSummary<'a> {
" Global Cache Key\t=\t{}",
self.global_hash_summary.root_key
)?;
cwriteln!(
tab_writer,
ui,
GREY,
" Global .env Files Considered\t=\t{}",
self.global_hash_summary
.global_dot_env
.unwrap_or_default()
.len()
)?;
cwriteln!(
tab_writer,
ui,
Expand Down
31 changes: 1 addition & 30 deletions crates/turborepo-lib/src/turbo_json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ use miette::{NamedSource, SourceSpan};
use serde::{Deserialize, Serialize};
use struct_iterable::Iterable;
use tracing::debug;
use turbopath::{AbsoluteSystemPath, AnchoredSystemPath, RelativeUnixPathBuf};
use turbopath::{AbsoluteSystemPath, AnchoredSystemPath};
use turborepo_errors::Spanned;
use turborepo_repository::{package_graph::ROOT_PKG_NAME, package_json::PackageJson};
use turborepo_telemetry::events::generic::GenericEventBuilder;

use crate::{
cli::OutputLogsMode,
Expand Down Expand Up @@ -50,7 +49,6 @@ pub struct TurboJson {
path: Option<Arc<str>>,
pub(crate) extends: Spanned<Vec<String>>,
pub(crate) global_deps: Vec<String>,
pub(crate) global_dot_env: Option<Vec<RelativeUnixPathBuf>>,
pub(crate) global_env: Vec<String>,
pub(crate) global_pass_through_env: Option<Vec<String>>,
pub(crate) pipeline: Pipeline,
Expand Down Expand Up @@ -115,9 +113,6 @@ pub struct RawTurboJson {
global_env: Option<Vec<Spanned<UnescapedString>>>,
#[serde(skip_serializing_if = "Option::is_none")]
global_pass_through_env: Option<Vec<Spanned<UnescapedString>>>,
// .env files to consider, in order.
#[serde(skip_serializing_if = "Option::is_none")]
global_dot_env: Option<Vec<UnescapedString>>,
// Pipeline is a map of Turbo pipeline entries which define the task graph
// and cache behavior on a per task or per package-task basis.
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -489,19 +484,6 @@ impl TryFrom<RawTurboJson> for TurboJson {

global_deps
},
global_dot_env: raw_turbo
.global_dot_env
.map(|env| -> Result<Vec<RelativeUnixPathBuf>, Error> {
let mut global_dot_env = Vec::new();
for dot_env_path in env {
let type_checked_path = RelativeUnixPathBuf::new(dot_env_path)?;
// These are _explicitly_ not sorted.
global_dot_env.push(type_checked_path);
}

Ok(global_dot_env)
})
.transpose()?,
pipeline: raw_turbo.pipeline.unwrap_or_default(),
// copy these over, we don't need any changes here.
extends: raw_turbo
Expand Down Expand Up @@ -631,11 +613,6 @@ impl TurboJson {
.collect()
}

pub fn track_usage(&self, telemetry: &GenericEventBuilder) {
let global_dot_env = self.global_dot_env.as_deref();
telemetry.track_global_dot_env(global_dot_env);
}

pub fn has_root_tasks(&self) -> bool {
self.pipeline
.iter()
Expand Down Expand Up @@ -752,12 +729,6 @@ mod tests {
..TurboJson::default()
}
; "global dependencies (sorted)")]
#[test_case(r#"{ "globalDotEnv": [".env.local", ".env"] }"#,
TurboJson {
global_dot_env: Some(vec![RelativeUnixPathBuf::new(".env.local").unwrap(), RelativeUnixPathBuf::new(".env").unwrap()]),
..TurboJson::default()
}
; "global dot env (unsorted)")]
#[test_case(r#"{ "globalPassThroughEnv": ["GITHUB_TOKEN", "AWS_SECRET_KEY"] }"#,
TurboJson {
global_pass_through_env: Some(vec!["AWS_SECRET_KEY".to_string(), "GITHUB_TOKEN".to_string()]),
Expand Down
23 changes: 0 additions & 23 deletions crates/turborepo-telemetry/src/events/generic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fmt::Display;

use serde::{Deserialize, Serialize};
use turbopath::RelativeUnixPathBuf;
use turborepo_vercel_api::telemetry::{TelemetryEvent, TelemetryGenericEvent};
use uuid::Uuid;

Expand Down Expand Up @@ -213,28 +212,6 @@ impl GenericEventBuilder {
self
}

pub fn track_global_dot_env(&self, global_dot_env: Option<&[RelativeUnixPathBuf]>) -> &Self {
if let Some(global_dot_env) = global_dot_env {
self.track(Event {
key: "global_dot_env".into(),
value: global_dot_env.len().to_string(),
is_sensitive: EventType::NonSensitive,
});
}
self
}

pub fn track_dot_env(&self, dot_env: Option<&[RelativeUnixPathBuf]>) -> &Self {
if let Some(dot_env) = dot_env {
self.track(Event {
key: "dot_env".into(),
value: dot_env.len().to_string(),
is_sensitive: EventType::NonSensitive,
});
}
self
}

// errors
pub fn track_error(&self, error: TrackedErrors) -> &Self {
self.track(Event {
Expand Down
1 change: 0 additions & 1 deletion turborepo-tests/integration/tests/dry-json/monorepo.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Setup
"foo.txt": "eebae5f3ca7b5831e429e947b7d61edd0de69236"
},
"hashOfExternalDependencies": "459c029558afe716",
"globalDotEnv": null,
"environmentVariables": {
"specified": {
"env": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Setup
"package.json": "8606ff4b95a5330740d8d9d0948faeada64f1f32"
},
"hashOfExternalDependencies": "",
"globalDotEnv": null,
"environmentVariables": {
"specified": {
"env": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Setup
"somefile.txt": "45b983be36b73c0788dc9cbcb76cbb80fc7bb057"
},
"hashOfExternalDependencies": "",
"globalDotEnv": null,
"environmentVariables": {
"specified": {
"env": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Setup
"somefile.txt": "45b983be36b73c0788dc9cbcb76cbb80fc7bb057"
},
"hashOfExternalDependencies": "",
"globalDotEnv": null,
"environmentVariables": {
"specified": {
"env": [],
Expand Down
1 change: 0 additions & 1 deletion turborepo-tests/integration/tests/dry-run.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Setup
Global Files = 1
External Dependencies Hash = 459c029558afe716
Global Cache Key = HEY STELLLLLLLAAAAAAAAAAAAA
Global .env Files Considered = 0
Global Env Vars = SOME_ENV_VAR
Global Env Vars Values =
Inferred Global Env Vars Values =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Check
Global Files = 3
External Dependencies Hash =
Global Cache Key = HEY STELLLLLLLAAAAAAAAAAAAA
Global .env Files Considered = 0
Global Env Vars =
Global Env Vars Values =
Inferred Global Env Vars Values =
Expand Down
11 changes: 5 additions & 6 deletions turborepo-tests/integration/tests/run/single-package/no-config.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ Check
Global Files = 2\s* (re)
External Dependencies Hash =\s* (re)
Global Cache Key = HEY STELLLLLLLAAAAAAAAAAAAA\s* (re)
Global .env Files Considered = 0\s* (re)
Global Env Vars =\s* (re)
Global Env Vars Values =\s* (re)
Inferred Global Env Vars Values =\s* (re)
Global Passed Through Env Vars =\s* (re)
Global Passed Through Env Vars Values =\s* (re)
Global Env Vars =
Global Env Vars Values =
Inferred Global Env Vars Values =
Global Passed Through Env Vars =
Global Passed Through Env Vars Values =

Tasks to Run
build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Check
Global Files = 3
External Dependencies Hash =
Global Cache Key = HEY STELLLLLLLAAAAAAAAAAAAA
Global .env Files Considered = 0
Global Env Vars =
Global Env Vars Values =
Inferred Global Env Vars Values =
Expand Down

0 comments on commit c65090c

Please sign in to comment.