Skip to content

Commit

Permalink
fix(execution): exclude skipped target from lookup for skippable depe…
Browse files Browse the repository at this point in the history
…ndencies
  • Loading branch information
matkoch committed Oct 12, 2024
1 parent 1688d82 commit 0464568
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions source/Nuke.Build.Tests/BuildExecutorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ public void TestStaticCondition_DependencyBehavior_Skip()
B.OnlyWhen.Should().Be("false");
}

[Fact]
public void TestStaticCondition_DependencyBehavior_Skip_Invoked()
{
C.Invoked = true;
C.StaticConditions.Add(("() => false", () => false));
B.DependencyBehavior = DependencyBehavior.Skip;
ExecuteBuild();
AssertSkipped(A, B, C);
A.Skipped.Should().Be("because of B");
B.Skipped.Should().Be("because of C");
C.OnlyWhen.Should().Be("false");
}

[Fact]
public void TestStaticCondition_Multiple()
{
Expand Down
6 changes: 3 additions & 3 deletions source/Nuke.Build/Execution/BuildExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ private static void MarkTargetSkipped(INukeBuild build, ExecutableTarget target,

bool HasOtherDependencies(ExecutableTarget dependentTarget)
=> build.ExecutionPlan
.Where(x => x.Status == ExecutionStatus.Scheduled)
.Where(x => x != target && x.Status == ExecutionStatus.Scheduled)
.Any(x => x.ExecutionDependencies.Contains(dependentTarget) || x.Triggers.Contains(dependentTarget));

var skippableTargets = target.ExecutionDependencies.Concat(target.Triggers)
var skippableDependencies = target.ExecutionDependencies.Concat(target.Triggers)
.Where(x => !HasOtherDependencies(x)).ToList();
skippableTargets.ForEach(x => MarkTargetSkipped(build, x, $"because of {target.Name}"));
skippableDependencies.ForEach(x => MarkTargetSkipped(build, x, $"because of {target.Name}"));
}

private static void AppendToBuildAttemptFile(string value)
Expand Down

0 comments on commit 0464568

Please sign in to comment.