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

feat: allow for specifying path of root turbo.json #9087

Conversation

chris-olszewski
Copy link
Member

@chris-olszewski chris-olszewski commented Aug 30, 2024

Description

Allow for setting the root turbo.json path via --root-turbo-json=path/to/my.json or TURBO_ROOT_TURBO_JSON=path/to/my.json. This option is not compatible with watch mode.

Reviewing this PR should be done commit-wise, there's a lot of prefactoring before the final commit that implements the actual feature.

Major changes as part of prefactor:

  • We parse turbo.json based on absolute paths instead of repo root relative ones. This allows us to read a turbo.json from wherever a user wants
  • Moved the reading of a trace generated turbo.json outside of the primary turbo.json reading logic and into TaskAccess
  • Changed ordering of how config layering happens instead of ordering them from least to most significant and always choosing a present value, we now go from most to least significant and only choose a value if we do not already have a value for it. This is necessary as we now have a config option (TURBO_ROOT_TURBO_JSON) that alters a less significant config source (turbo.json).
  • Move config sources out of config.rs
  • We are now lazy with evaluating our config sources. This allows us to change the path of the turbo.json we read after partial evaluation of config sources

Testing Instructions

Existing unit tests for the refactors.
Manual testing of the traced config logic.
Integration test for new feature.

Copy link

linear bot commented Aug 30, 2024

Copy link

vercel bot commented Aug 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 6:28pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 6:28pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 6:28pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 6:28pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 6:28pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 6:28pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 6:28pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 6:28pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Sep 3, 2024 6:28pm

let config = sources.into_iter().try_fold(
ConfigurationOptions::default(),
|mut acc, current_source| {
let mut current_source_config = current_source.get_configuration_options(&acc)?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an existing bug where we would ignore any errors that came from resolving config options from a source. In reality since these were (mostly) eagerly calculated it only affected and validation errors from extracting config options from a turbo.json.

We now bubble up any errors generated by resolving config options.

Copy link
Contributor

@NicholasLYang NicholasLYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nicely done! Love the PR organization. Just a couple nits and one question about task access config

crates/turborepo-lib/src/turbo_json/mod.rs Outdated Show resolved Hide resolved
turborepo-tests/integration/tests/run/no-root-turbo.t Outdated Show resolved Hide resolved
if !self.enabled {
return None;
}
let trace_json_path = self.repo_root.join_components(&TASK_ACCESS_CONFIG_PATH);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original code, we first resolve the dir arg then join to TASK_ACCESS_CONFIG_PATH. Do we no longer need the dir part?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to as traced turbo.json is only supported for single package repositories so it would only be successful for dir == "" where it ends up being at $REPO_ROOT/.turbo/traced-config.json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required in this PR we can fix this when we need it but this should be aware of the cache dir as well beacuse the intention is that the config gets cached as an artifact.

@chris-olszewski chris-olszewski merged commit ac57dc7 into main Sep 3, 2024
40 checks passed
@chris-olszewski chris-olszewski deleted the chrisolszewski/turbo-4008-investigate-viability-of-a-config-path-or-similar-flag branch September 3, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants