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 negative globs in globalDeps #8190

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions crates/turborepo-lib/src/run/global_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
str::FromStr,
};

use either::Either;
use globwalk::{ValidatedGlob, WalkType};
use itertools::Itertools;
use thiserror::Error;
use tracing::debug;
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf, RelativeUnixPathBuf};
Expand Down Expand Up @@ -116,7 +118,7 @@
if global_file_dependencies.is_empty() {
return Ok(HashSet::new());
}
let raw_exclusions = match package_manager.get_workspace_globs(root_path) {
let workspace_exclusions = match package_manager.get_workspace_globs(root_path) {
Ok(globs) => globs.raw_exclusions,
// If we hit a missing workspaces error, we could be in single package mode
// so we should just use the default globs
Expand All @@ -128,13 +130,21 @@
return Err(err.into());
}
};
let exclusions = raw_exclusions
let (raw_inclusions, raw_exclusions): (Vec<_>, Vec<_>) = global_file_dependencies

Check warning on line 133 in crates/turborepo-lib/src/run/global_hash.rs

View workflow job for this annotation

GitHub Actions / Build Turborepo (windows, windows-latest)

unused variable: `raw_inclusions`

Check warning on line 133 in crates/turborepo-lib/src/run/global_hash.rs

View workflow job for this annotation

GitHub Actions / Turborepo Rust testing on windows

unused variable: `raw_inclusions`

Check warning on line 133 in crates/turborepo-lib/src/run/global_hash.rs

View workflow job for this annotation

GitHub Actions / Turborepo Integration (windows-latest)

unused variable: `raw_inclusions`
.iter()
.map(|e| ValidatedGlob::from_str(e))
.partition_map(|glob| match glob.strip_prefix('!') {
None => Either::Left(glob.as_str()),
Some(exclusion) => Either::Right(exclusion),
});
let exclusions = workspace_exclusions
.iter()
.map(|s| s.as_str())
.chain(raw_exclusions.iter().copied())
.map(ValidatedGlob::from_str)
.collect::<Result<Vec<_>, _>>()?;

#[cfg(not(windows))]
let inclusions = global_file_dependencies
let inclusions = raw_inclusions
.iter()
.map(|i| ValidatedGlob::from_str(i))
.collect::<Result<Vec<_>, _>>()?;
Expand Down
3 changes: 3 additions & 0 deletions turborepo-tests/integration/fixtures/global_deps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# My Monorepo

Hello!
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": ["global_deps/**"],
"globalDependencies": ["global_deps/**", "!global_deps/**/*.md"],
"globalEnv": ["SOME_ENV_VAR"],
"tasks": {
"build": {
Expand Down
11 changes: 11 additions & 0 deletions turborepo-tests/integration/tests/global-deps.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ Run a build
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

$ echo "Submit a PR!" >> global_deps/CONTRIBUTING.md
$ ${TURBO} build -F my-app --output-logs=hash-only
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:build: cache hit, suppressing logs ded57f1945fa82be

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

Loading