Skip to content

Commit

Permalink
Merge branch 'hotfix/8.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Oct 13, 2024
2 parents 1688d82 + d3ef1b0 commit e782a00
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 34 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [vNext]

## [8.1.2] / 2024-10-13
- Fixed exclusion of skipped target from lookup for skippable dependencies
- Fixed resolution of empty environment variables to false
- Fixed parallel execution to prefer logger from settings

## [8.1.1] / 2024-10-05
- Fixed nested solution folders in `StronglyTypedSolutionGenerator`
- Fixed whitespace arguments in `ArgumentStringHandler`
Expand Down Expand Up @@ -1157,7 +1162,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added CLT tasks for Git
- Fixed background color in console output

[vNext]: https://github.com/nuke-build/nuke/compare/8.1.1...HEAD
[vNext]: https://github.com/nuke-build/nuke/compare/8.1.2...HEAD
[8.1.2]: https://github.com/nuke-build/nuke/compare/8.1.1...8.1.2
[8.1.1]: https://github.com/nuke-build/nuke/compare/8.1.0...8.1.1
[8.1.0]: https://github.com/nuke-build/nuke/compare/8.0.0...8.1.0
[8.0.0]: https://github.com/nuke-build/nuke/compare/7.0.6...8.0.0
Expand Down
16 changes: 8 additions & 8 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
<PackageVersion Include="Azure.Identity" Version="1.12.1" />
<PackageVersion Include="Azure.Security.KeyVault.Certificates" Version="4.6.0" />
<PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.6.0" />
<PackageVersion Include="Azure.Security.KeyVault.Secrets" Version="4.6.0" />
<PackageVersion Include="Basic.Reference.Assemblies.NetStandard20" Version="1.7.2" />
<PackageVersion Include="Glob" Version="1.1.9" />
<PackageVersion Include="HtmlAgilityPack" Version="1.11.61" />
<PackageVersion Include="HtmlAgilityPack" Version="1.11.67" />
<PackageVersion Include="Humanizer" Version="2.14.1" />
<PackageVersion Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageVersion Include="JetBrains.Annotations" Version="2024.2.0" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="8.0.2" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="NJsonSchema" Version="10.9.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="NuGet.Packaging" Version="6.10.1" />
<PackageVersion Include="NuGet.Packaging" Version="6.11.1" />
<PackageVersion Include="Octokit" Version="13.0.1" />
<PackageVersion Include="Serilog" Version="4.0.0" />
<PackageVersion Include="Serilog" Version="4.0.2" />
<PackageVersion Include="Serilog.Formatting.Compact" Version="3.0.0" />
<PackageVersion Include="Serilog.Formatting.Compact.Reader" Version="4.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
<PackageVersion Include="YamlDotNet" Version="15.3.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="YamlDotNet" Version="16.1.3" />
<PackageVersion Include="matkoch.spectre.console" Version="0.46.0" />
</ItemGroup>

Expand Down
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
7 changes: 7 additions & 0 deletions source/Nuke.Build.Tests/ParameterServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ public void TestNotSupplied(Type destinationType, object expectedValue)
[Theory]
[InlineData("arg1", typeof(string), "value1")]
[InlineData("arg2", typeof(string), "value3")]
[InlineData("arg3", typeof(string), "value4")]
[InlineData("switch1", typeof(bool), true)]
[InlineData("switch2", typeof(bool), true)]
[InlineData("switch3", typeof(bool), false)]
[InlineData("switch4", typeof(bool), false)]
[InlineData("switch5", typeof(bool), true)]
[InlineData("array1", typeof(string[]), new[] { "element1", "element2" })]
[InlineData("array2", typeof(string[]), new string[0])]
[InlineData("array3", typeof(string[]), null)]
Expand All @@ -60,8 +64,11 @@ public void TestEnvironmentVariables(string parameter, Type destinationType, obj
{
{ "arg1", "value2" },
{ "arg2", "value3" },
{ "nuke_arg_3", "value4" },
{ "switch2", "true" },
{ "switch3", "false" },
{ "switch4", "" },
{ "nuke_switch_5", "true" },
{ "array1", "element1+element2" },
{ "array2", "" },
});
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
2 changes: 1 addition & 1 deletion source/Nuke.Build/Execution/ParameterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static string GetTrimmedName(string name)

try
{
return Convert(value, destinationType, separator);
return Convert(value, destinationType, separator, booleanDefault: false);
}
catch (Exception ex)
{
Expand Down
26 changes: 14 additions & 12 deletions source/Nuke.Tooling/Configure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static T InvokeSafe<T>([CanBeNull] this Configure<T> configurator, T obj)
public static IReadOnlyCollection<(TSettings Settings, IReadOnlyCollection<Output> Output)> Invoke<TSettings>(
this CombinatorialConfigure<TSettings> configurator,
Func<TSettings, IReadOnlyCollection<Output>> executor,
Action<OutputType, string> logger,
Action<OutputType, string> defaultLogger,
int degreeOfParallelism,
bool completeOnFailure)
where TSettings : ToolSettings, new()
Expand All @@ -38,24 +38,24 @@ public static T InvokeSafe<T>([CanBeNull] this Configure<T> configurator, T obj)
configurator,
x => (Settings: x, Output: executor(x)),
x => x.Output,
logger,
defaultLogger,
degreeOfParallelism,
completeOnFailure);
}

public static IReadOnlyCollection<(TSettings Settings, TResult Result, IReadOnlyCollection<Output> Output)> Invoke<TSettings, TResult>(
this CombinatorialConfigure<TSettings> configurator,
Func<TSettings, (TResult Result, IReadOnlyCollection<Output> Output)> executor,
Action<OutputType, string> logger,
Action<OutputType, string> defaultLogger,
int degreeOfParallelism,
bool completeOnFailure)
where TSettings : ToolSettings, new()
{
return Invoke(
configurator,
x => (Settings: x, ReturnValue: executor(x)),
x => x.ReturnValue.Output,
logger,
executor: x => (Settings: x, ReturnValue: executor(x)),
outputSelector: x => x.ReturnValue.Output,
defaultLogger,
degreeOfParallelism,
completeOnFailure)
.Select(x => (x.Settings, x.ReturnValue.Result, x.ReturnValue.Output)).ToList();
Expand All @@ -65,12 +65,12 @@ private static IReadOnlyCollection<TResult> Invoke<TSettings, TResult>(
CombinatorialConfigure<TSettings> configurator,
Func<TSettings, TResult> executor,
Func<TResult, IReadOnlyCollection<Output>> outputSelector,
Action<OutputType, string> logger,
Action<OutputType, string> defaultLogger,
int degreeOfParallelism,
bool completeOnFailure)
where TSettings : ToolSettings, new()
{
var invocations = new ConcurrentBag<(TSettings Settings, TResult Result, Exception Exception)>();
var invocations = new ConcurrentBag<(TSettings Settings, Action<OutputType, string> logger, TResult Result, Exception Exception)>();

try
{
Expand All @@ -79,13 +79,15 @@ private static IReadOnlyCollection<TResult> Invoke<TSettings, TResult>(
.WithDegreeOfParallelism(degreeOfParallelism)
.ForAll(x =>
{
var logger = x.ProcessLogger ?? defaultLogger;
try
{
invocations.Add((x, executor(x.DisableProcessLogOutput()), default));
var result = executor(x.DisableProcessLogOutput());
invocations.Add((x, logger, result, default));
}
catch (Exception exception)
{
invocations.Add((x, default, exception));
invocations.Add((x, logger, default, exception));

if (!completeOnFailure)
throw;
Expand All @@ -103,14 +105,14 @@ private static IReadOnlyCollection<TResult> Invoke<TSettings, TResult>(
.Where(x => x.Settings.ProcessLogOutput ?? ProcessTasks.DefaultLogOutput)
.SelectMany(x =>
{
var (settings, result, exception) = x;
var (_, logger, result, exception) = x;
var output = exception switch
{
ProcessException processException => processException.Process.Output,
_ => outputSelector(result),
};

return output.Select(x => (Logger: logger ?? settings.ProcessLogger, Line: x));
return output.Select(x => (Logger: logger, Line: x));
})
.ForEach(x => x.Logger(x.Line.Type, x.Line.Text));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ public void TestConversionCollections()
.Should().BeOfType<string[]>().Which
.Should().BeEmpty();

ReflectionUtility.Convert(string.Empty, typeof(string[]), separator: '+')
ReflectionUtility.Convert(string.Empty, typeof(string[]), separator: '+', booleanDefault: true)
.Should().BeOfType<string[]>().Which
.Should().BeEmpty();

ReflectionUtility.Convert("A+B+C", typeof(string[]), separator: '+')
ReflectionUtility.Convert("A+B+C", typeof(string[]), separator: '+', booleanDefault: true)
.Should().BeOfType<string[]>().Which
.Should().Equal("A", "B", "C");

ReflectionUtility.Convert("1 2 3", typeof(int[]), separator: ' ')
ReflectionUtility.Convert("1 2 3", typeof(int[]), separator: ' ', booleanDefault: true)
.Should().BeOfType<int[]>().Which
.Should().Equal(1, 2, 3);
}
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Utilities/ArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private object ConvertValues(string argumentName, IReadOnlyCollection<string> va
{
try
{
return ReflectionUtility.Convert(values, destinationType);
return ReflectionUtility.Convert(values, destinationType, booleanDefault: true);
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Utilities/EnvironmentInfo.Variables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static T GetVariable<T>(string name, char? separator = null)
if (value == null)
return default;

return (T)ReflectionUtility.Convert(value, typeof(T), separator);
return (T)ReflectionUtility.Convert(value, typeof(T), separator, booleanDefault: false);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ public static object Convert(object value, Type destinationType)

// TODO: rename overloads?
[CanBeNull]
public static object Convert(string value, Type destinationType, char? separator)
public static object Convert(string value, Type destinationType, char? separator, bool booleanDefault)
{
var values = (separator.HasValue ? value.Split(separator.Value) : new[] { value })
.Where(x => !x.IsNullOrWhiteSpace()).ToArray();
return Convert(values, destinationType);
return Convert(values, destinationType, booleanDefault);
}

[CanBeNull]
public static object Convert(IReadOnlyCollection<string> values, Type destinationType)
public static object Convert(IReadOnlyCollection<string> values, Type destinationType, bool booleanDefault)
{
Assert.True(!destinationType.IsArray || destinationType.GetArrayRank() == 1, "Arrays must have a rank of 1");
var elementType = (destinationType.IsArray ? destinationType.GetElementType() : destinationType).NotNull();
Expand All @@ -62,7 +62,7 @@ public static object Convert(IReadOnlyCollection<string> values, Type destinatio
return Array.CreateInstance(elementType, length: 0);

if (destinationType == typeof(bool) || destinationType == typeof(bool?))
return true;
return booleanDefault;

return null;
}
Expand Down

0 comments on commit e782a00

Please sign in to comment.