Skip to content

Commit

Permalink
chore(turborepo): Improve pipeline error message (#8231)
Browse files Browse the repository at this point in the history
### Description

Made a nicer error message for having a `pipeline` key instead of
`tasks`.

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->

---------

Co-authored-by: Anthony Shew <[email protected]>
  • Loading branch information
NicholasLYang and anthonyshew authored May 28, 2024
1 parent cc1057b commit ac50e35
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions crates/turborepo-lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ pub enum Error {
#[source_code]
text: NamedSource,
},
#[error("found `pipeline` field instead of `tasks`")]
#[diagnostic(help("Deprecated in 2.0: `pipeline` has been renamed to `tasks`"))]
PipelineField {
#[label("rename `pipeline` field to `tasks`")]
span: Option<SourceSpan>,
#[source_code]
text: NamedSource,
},
#[error("Failed to create APIClient: {0}")]
ApiClient(#[source] turborepo_api_client::Error),
#[error("{0} is not UTF8.")]
Expand Down
7 changes: 7 additions & 0 deletions crates/turborepo-lib/src/turbo_json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ pub struct RawTurboJson {
// and cache behavior on a per task or per package-task basis.
#[serde(skip_serializing_if = "Option::is_none")]
pub tasks: Option<Pipeline>,

#[serde(skip_serializing)]
pub pipeline: Option<Spanned<Pipeline>>,
// Configuration options when interfacing with the remote cache
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) remote_cache: Option<RawRemoteCacheOptions>,
Expand Down Expand Up @@ -432,6 +435,10 @@ impl TryFrom<RawTurboJson> for TurboJson {
type Error = Error;

fn try_from(raw_turbo: RawTurboJson) -> Result<Self, Error> {
if let Some(pipeline) = raw_turbo.pipeline {
let (span, text) = pipeline.span_and_text("turbo.json");
return Err(Error::PipelineField { span, text });
}
let mut global_env = HashSet::new();
let mut global_file_dependencies = HashSet::new();

Expand Down
6 changes: 4 additions & 2 deletions crates/turborepo-lib/src/turbo_json/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ impl WithMetadata for RawTurboJson {
self.global_dependencies.add_text(text.clone());
self.global_env.add_text(text.clone());
self.global_pass_through_env.add_text(text.clone());
self.tasks.add_text(text);
self.tasks.add_text(text.clone());
self.pipeline.add_text(text);
}

fn add_path(&mut self, path: Arc<str>) {
Expand All @@ -156,7 +157,8 @@ impl WithMetadata for RawTurboJson {
self.global_dependencies.add_path(path.clone());
self.global_env.add_path(path.clone());
self.global_pass_through_env.add_path(path.clone());
self.tasks.add_path(path);
self.tasks.add_path(path.clone());
self.pipeline.add_path(path);
}
}

Expand Down

0 comments on commit ac50e35

Please sign in to comment.