Skip to content
Draft
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
11 changes: 7 additions & 4 deletions src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public DistributedApplicationPipeline()
_steps.Add(new PipelineStep
{
Name = WellKnownPipelineSteps.Deploy,
Action = _ => Task.CompletedTask,
Action = _ => Task.CompletedTask
});

_steps.Add(new PipelineStep
Expand Down Expand Up @@ -116,20 +116,23 @@ public DistributedApplicationPipeline()

resource.Annotations.Add(new DeploymentImageTagCallbackAnnotation(_ => uniqueDeployTag));
}
}
},
Tags = [WellKnownPipelineTags.ProvisionInfrastructure]
});

// Add a default "build" step
_steps.Add(new PipelineStep
{
Name = WellKnownPipelineSteps.Build,
Action = _ => Task.CompletedTask,
Tags = [WellKnownPipelineTags.BuildCompute]
});

_steps.Add(new PipelineStep
{
Name = WellKnownPipelineSteps.BuildPrereq,
Action = context => Task.CompletedTask
Action = context => Task.CompletedTask,
Tags = [WellKnownPipelineTags.BuildCompute]
});

// Add a default "Publish" meta-step that all publish steps should be required by
Expand All @@ -142,7 +145,7 @@ public DistributedApplicationPipeline()
_steps.Add(new PipelineStep
{
Name = WellKnownPipelineSteps.PublishPrereq,
Action = _ => Task.CompletedTask,
Action = _ => Task.CompletedTask
});

// Add diagnostic step for dependency graph analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public required IReadOnlyList<PipelineStep> Steps
/// </summary>
/// <param name="tag">The tag to search for.</param>
/// <returns>A collection of steps that have the specified tag.</returns>
public IEnumerable<PipelineStep> GetSteps(string tag)
public IEnumerable<PipelineStep> GetStepsByTag(string tag)
{
ArgumentNullException.ThrowIfNull(tag);
return Steps.Where(s => s.Tags.Contains(tag));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ public async Task PipelineConfigurationContext_GetStepsByTag_ReturnsCorrectSteps

pipeline.AddPipelineConfiguration((configContext) =>
{
foundSteps.AddRange(configContext.GetSteps("test-tag"));
foundSteps.AddRange(configContext.GetStepsByTag("test-tag"));
return Task.CompletedTask;
});

Expand Down Expand Up @@ -1768,6 +1768,47 @@ public void WellKnownPipelineTags_ConstantsAccessible()
Assert.Equal("deploy-compute", WellKnownPipelineTags.DeployCompute);
}

[Fact]
public async Task DefaultPipelineSteps_HaveCorrectTags()
{
// Arrange
using var builder = TestDistributedApplicationBuilder.Create(DistributedApplicationOperation.Publish, step: null);
var pipeline = new DistributedApplicationPipeline();

var capturedSteps = new List<PipelineStep>();

pipeline.AddPipelineConfiguration((configContext) =>
{
capturedSteps.AddRange(configContext.Steps);
return Task.CompletedTask;
});

var context = CreateDeployingContext(builder.Build());
await pipeline.ExecuteAsync(context);

// Act & Assert - Verify each default step has the correct tag
var deployStep = capturedSteps.Single(s => s.Name == WellKnownPipelineSteps.Deploy);
Assert.Empty(deployStep.Tags);

var deployPrereqStep = capturedSteps.Single(s => s.Name == WellKnownPipelineSteps.DeployPrereq);
Assert.Contains(WellKnownPipelineTags.ProvisionInfrastructure, deployPrereqStep.Tags);

var buildStep = capturedSteps.Single(s => s.Name == WellKnownPipelineSteps.Build);
Assert.Contains(WellKnownPipelineTags.BuildCompute, buildStep.Tags);

var buildPrereqStep = capturedSteps.Single(s => s.Name == WellKnownPipelineSteps.BuildPrereq);
Assert.Contains(WellKnownPipelineTags.BuildCompute, buildPrereqStep.Tags);

var publishStep = capturedSteps.Single(s => s.Name == WellKnownPipelineSteps.Publish);
Assert.Empty(publishStep.Tags);

var publishPrereqStep = capturedSteps.Single(s => s.Name == WellKnownPipelineSteps.PublishPrereq);
Assert.Empty(publishPrereqStep.Tags);

var diagnosticsStep = capturedSteps.Single(s => s.Name == WellKnownPipelineSteps.Diagnostics);
Assert.Empty(diagnosticsStep.Tags);
}

[Fact]
public async Task ConfigurationCallback_CanCreateComplexDependencyRelationships()
{
Expand Down Expand Up @@ -1822,9 +1863,9 @@ public async Task ConfigurationCallback_CanCreateComplexDependencyRelationships(

pipeline.AddPipelineConfiguration((configContext) =>
{
var provisionSteps = configContext.GetSteps(WellKnownPipelineTags.ProvisionInfrastructure).ToList();
var buildSteps = configContext.GetSteps(WellKnownPipelineTags.BuildCompute).ToList();
var deploySteps = configContext.GetSteps(WellKnownPipelineTags.DeployCompute).ToList();
var provisionSteps = configContext.GetStepsByTag(WellKnownPipelineTags.ProvisionInfrastructure).ToList();
var buildSteps = configContext.GetStepsByTag(WellKnownPipelineTags.BuildCompute).ToList();
var deploySteps = configContext.GetStepsByTag(WellKnownPipelineTags.DeployCompute).ToList();

foreach (var buildStep in buildSteps)
{
Expand Down
Loading