Skip to content

Commit

Permalink
Changed Configuration from class to a real enum (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
candoumbe committed Jan 20, 2023
1 parent 7091ac6 commit 1a1879e
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 61 deletions.
5 changes: 4 additions & 1 deletion .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
},
"Configuration": {
"type": "string",
"enum": []
"enum": [
"Debug",
"Release"
]
},
"Continue": {
"type": "boolean",
Expand Down
33 changes: 0 additions & 33 deletions build/Candoumbe.Pipelines.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,4 @@
<PackageReference Include="Candoumbe.Miscutilities" Version="0.10.0" />
<PackageDownload Include="GitVersion.Tool" Version="[5.10.3]" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\**" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2022-10-22_17-17-40.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2022-10-22_17-02-27.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2022-10-22_16-48-01.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2022-10-22_15-18-51.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2022-10-22_15-07-14.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2022-10-22_14-59-01.log" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion build/Pipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class Pipeline : NukeBuild,
IHaveSecret
{
///<inheritdoc/>
IEnumerable<AbsolutePath> IClean.DirectoriesToDelete => RootDirectory.GlobDirectories("**/bin", "**/obj");
IEnumerable<AbsolutePath> IClean.DirectoriesToDelete => this.Get<IHaveSourceDirectory>().SourceDirectory.GlobDirectories("**/bin", "**/obj");

///<inheritdoc/>
IEnumerable<AbsolutePath> IClean.DirectoriesToEnsureExistance => new[]
Expand Down
1 change: 0 additions & 1 deletion src/Candoumbe.Pipelines/Candoumbe.Pipelines.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.DependencyValidation.Analyzers" Version="0.11.0" />
<PackageReference Include="Nuke.Common" Version="6.3.0" />
</ItemGroup>
</Project>
25 changes: 7 additions & 18 deletions src/Candoumbe.Pipelines/Components/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
using JetBrains.Annotations;

using Nuke.Common.Tooling;

using System.ComponentModel;

namespace Candoumbe.Pipelines.Components
namespace Candoumbe.Pipelines.Components
{
/// <summary>
/// Configuration that can be used throughout CI/CD pipelines
/// Configuration that can be used to compile an application
/// </summary>
[PublicAPI]
[TypeConverter(typeof(TypeConverter<Configuration>))]
public class Configuration : Enumeration
public enum Configuration
{
/// <summary>
/// The "Debug" mode
/// Debug mode
/// </summary>
public static Configuration Debug => new() { Value = nameof(Debug) };
Debug,

/// <summary>
/// The "release" mode
/// Release mode
/// </summary>
public static Configuration Release => new() { Value = nameof(Release) };

///<inheritdoc/>
public static implicit operator string(Configuration configuration) => configuration.Value;
Release
}
}
4 changes: 2 additions & 2 deletions src/Candoumbe.Pipelines/Components/IBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface IBenchmark : ICompile, IHaveArtifacts
{
BenchmarkProjects.ForEach(csproj =>
{
DotNetRun(s => s.SetConfiguration(Configuration.Release)
DotNetRun(s => s.SetConfiguration(nameof(Configuration.Release))
.SetProjectFile(csproj)
.CombineWith(csproj.GetTargetFrameworks(),
(setting, framework) => setting.SetFramework(framework))
Expand All @@ -50,7 +50,7 @@ public interface IBenchmark : ICompile, IHaveArtifacts
/// Configures the way performance tests are run.
/// </summary>
public sealed Configure<DotNetRunSettings> BenchmarksSettingsBase => _ => _
.SetConfiguration(Configuration.Release)
.SetConfiguration(nameof(Configuration.Release))
.SetProcessArgumentConfigurator(args => args.Add("-- --filter {0}", "*", customValue: true)
.Add("--artifacts {0}", BenchmarkResultDirectory)
.Add("--join"));
Expand Down
2 changes: 1 addition & 1 deletion src/Candoumbe.Pipelines/Components/ICompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface ICompile : IRestore, IHaveConfiguration
public sealed Configure<DotNetBuildSettings> CompileSettingsBase => _ => _
.SetNoRestore(SucceededTargets.Contains(Restore) || SkippedTargets.Contains(Restore))
.SetProjectFile(Solution)
.SetConfiguration(Configuration)
.SetConfiguration(Configuration.ToString())
.SetContinuousIntegrationBuild(IsServerBuild)
.WhenNotNull(this as IHaveGitVersion,
(settings, gitVersion) => settings.SetAssemblyVersion(gitVersion.GitVersion.AssemblySemVer)
Expand Down
3 changes: 1 addition & 2 deletions src/Candoumbe.Pipelines/Components/IHaveConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ public interface IHaveConfiguration : INukeBuild
/// Configuration currently supported by the pipeline
/// </summary>
[Parameter]
public Configuration Configuration => TryGetValue(() => Configuration) ??
(IsLocalBuild ? Configuration.Debug : Configuration.Release);
public Configuration Configuration => IsLocalBuild ? Configuration.Debug : Configuration.Release;
}
2 changes: 1 addition & 1 deletion src/Candoumbe.Pipelines/Components/IPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public interface IPack : IHaveArtifacts, ICompile
.SetOutputDirectory(PackagesDirectory)
.SetNoBuild(SucceededTargets.Contains(Compile) || SkippedTargets.Contains(Compile))
.SetNoRestore(SucceededTargets.Contains(Restore) || SucceededTargets.Contains(Compile))
.SetConfiguration(Configuration)
.SetConfiguration(Configuration.ToString())
.SetSymbolPackageFormat(DotNetSymbolPackageFormat.snupkg)
.WhenNotNull(this as IHaveGitVersion,
(_, versioning) => _.SetAssemblyVersion(versioning.GitVersion.AssemblySemVer)
Expand Down
2 changes: 1 addition & 1 deletion src/Candoumbe.Pipelines/Components/IUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public interface IUnitTest : ICompile, IHaveTests, IHaveCoverage
});

internal sealed Configure<DotNetTestSettings> UnitTestSettingsBase => _ => _
.SetConfiguration(Configuration)
.SetConfiguration(Configuration.ToString())
.ResetVerbosity()
.EnableCollectCoverage()
.EnableUseSourceLink()
Expand Down

0 comments on commit 1a1879e

Please sign in to comment.