Skip to content
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</PackageVersion>
<PackageVersion Include="StreamJsonRpc" Version="2.22.11" />
<PackageVersion Include="System.Collections.Immutable" Version="9.0.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta5.25306.1" />
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
<PackageVersion Include="Testcontainers.Kafka" Version="4.6.0" />
Expand Down
64 changes: 32 additions & 32 deletions TUnit.Pipeline/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,46 @@
using ModularPipelines.Options;
using TUnit.Pipeline;

var fileOption = new Option<string[]>(
name: "--categories",
description: "The categories to run.",
getDefaultValue: () => [])
var categoryOption = new Option<string[]>(
name: "--categories")
{
Arity = ArgumentArity.ZeroOrMore,
AllowMultipleArgumentsPerToken = true,
Description = "The categories to run.",
DefaultValueFactory = _ => []
};

var rootCommand = new RootCommand("The pipeline for building, testing and packaging TUnit");
rootCommand.AddOption(fileOption);

rootCommand.SetHandler((categories) =>
{
var pipelineHostBuilder = PipelineHostBuilder.Create()
.ConfigureAppConfiguration((_, builder) =>
{
builder.AddEnvironmentVariables();
})
.ConfigureServices((context, collection) =>
{
collection.Configure<NuGetOptions>(context.Configuration.GetSection("NuGet"));
collection.AddModulesFromAssembly(typeof(Program).Assembly);
})
.ConfigurePipelineOptions((_, options) => options.ExecutionMode = ExecutionMode.WaitForAllModules);
rootCommand.Add(categoryOption);
rootCommand.SetAction(parseResult =>
{
var categories = parseResult.GetValue(categoryOption)!;

if (categories.Length > 0)
var pipelineHostBuilder = PipelineHostBuilder.Create()
.ConfigureAppConfiguration((_, builder) =>
{
pipelineHostBuilder.RunCategories(categories);
}
else
builder.AddEnvironmentVariables();
})
.ConfigureServices((context, collection) =>
{
pipelineHostBuilder.IgnoreCategories("ReadMe");
}
collection.Configure<NuGetOptions>(context.Configuration.GetSection("NuGet"));
collection.AddModulesFromAssembly(typeof(Program).Assembly);
})
.ConfigurePipelineOptions((_, options) => options.ExecutionMode = ExecutionMode.WaitForAllModules);

if (categories.Length > 0)
{
pipelineHostBuilder.RunCategories(categories);
}
else
{
pipelineHostBuilder.IgnoreCategories("ReadMe");
}

pipelineHostBuilder
.ExecutePipelineAsync()
.GetAwaiter()
.GetResult();
},
fileOption);
pipelineHostBuilder
.ExecutePipelineAsync()
.GetAwaiter()
.GetResult();
});

return await rootCommand.InvokeAsync(args);
return await rootCommand.Parse(args).InvokeAsync();
Loading