From 76e8a6d35297c525169d3c8627c0feea0a8c5c84 Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Thu, 12 Sep 2024 17:37:35 -0400 Subject: [PATCH] fix(affected): include dependents in affected filter (#9137) ### Description This PR changes `--affected` so packages that depend on affected packages also get added. ### Testing Instructions Added integration test to makes sure dependents of changed packages get ran for `--affected`. --- crates/turborepo-lib/src/run/scope/filter.rs | 1 + .../integration/tests/affected-rdeps.t | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 turborepo-tests/integration/tests/affected-rdeps.t diff --git a/crates/turborepo-lib/src/run/scope/filter.rs b/crates/turborepo-lib/src/run/scope/filter.rs index 7bb31423f9382..b16924d430ab1 100644 --- a/crates/turborepo-lib/src/run/scope/filter.rs +++ b/crates/turborepo-lib/src/run/scope/filter.rs @@ -201,6 +201,7 @@ impl<'a, T: GitChangeDetector> FilterResolver<'a, T> { include_uncommitted: true, allow_unknown_objects: true, }), + include_dependents: true, ..Default::default() }); } diff --git a/turborepo-tests/integration/tests/affected-rdeps.t b/turborepo-tests/integration/tests/affected-rdeps.t new file mode 100644 index 0000000000000..44b8e8762761f --- /dev/null +++ b/turborepo-tests/integration/tests/affected-rdeps.t @@ -0,0 +1,19 @@ +Setup + $ . ${TESTDIR}/../../helpers/setup_integration_test.sh + +Create a new branch + $ git checkout -b my-branch + Switched to a new branch 'my-branch' + +Edit a file that affects `util` package + $ echo "foo" >> packages/util/index.js +Commit the change + $ git add . + $ git commit -m "add foo" --quiet + +Validate that we run `util#build` and all rdeps + $ ${TURBO} run build --affected --dry=json | jq '.tasks | map(select(.command != "")) | map(.taskId)| sort' + [ + "my-app#build", + "util#build" + ]