diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index 3f28e64470..fc7c9b6f16 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -482,8 +482,8 @@ func (p *DefaultProjectCommandBuilder) buildProjectCommandCtx(ctx *CommandContex repoDir, automerge, projCfg.DeleteSourceBranchOnMerge, - parallelPlan, parallelApply, + parallelPlan, verbose, )...) } @@ -498,8 +498,8 @@ func (p *DefaultProjectCommandBuilder) buildProjectCommandCtx(ctx *CommandContex repoDir, automerge, projCfg.DeleteSourceBranchOnMerge, - parallelPlan, parallelApply, + parallelPlan, verbose, )...) } diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go index 87907eb8fb..f39d52dd49 100644 --- a/server/events/project_command_builder_test.go +++ b/server/events/project_command_builder_test.go @@ -170,15 +170,17 @@ projects: // Test building a plan and apply command for one project. func TestDefaultProjectCommandBuilder_BuildSinglePlanApplyCommand(t *testing.T) { cases := []struct { - Description string - AtlantisYAML string - Cmd events.CommentCommand - ExpCommentArgs []string - ExpWorkspace string - ExpDir string - ExpProjectName string - ExpErr string - ExpApplyReqs []string + Description string + AtlantisYAML string + Cmd events.CommentCommand + ExpCommentArgs []string + ExpWorkspace string + ExpDir string + ExpProjectName string + ExpErr string + ExpApplyReqs []string + ExpParallelApply bool + ExpParallelPlan bool }{ { Description: "no atlantis.yaml", @@ -342,6 +344,29 @@ projects: `, ExpErr: "no project with name \"notconfigured\" is defined in atlantis.yaml", }, + { + Description: "atlantis.yaml with ParallelPlan Set to true", + Cmd: events.CommentCommand{ + Name: models.PlanCommand, + RepoRelDir: ".", + Workspace: "default", + ProjectName: "myproject", + }, + AtlantisYAML: ` +version: 3 +parallel_plan: true +projects: +- name: myproject + dir: . + workspace: myworkspace +`, + ExpParallelPlan: true, + ExpParallelApply: false, + ExpDir: ".", + ExpWorkspace: "myworkspace", + ExpProjectName: "myproject", + ExpApplyReqs: []string{}, + }, } logger := logging.NewNoopLogger(t) @@ -403,6 +428,8 @@ projects: Equals(t, c.ExpCommentArgs, actCtx.EscapedCommentArgs) Equals(t, c.ExpProjectName, actCtx.ProjectName) Equals(t, c.ExpApplyReqs, actCtx.ApplyRequirements) + Equals(t, c.ExpParallelApply, actCtx.ParallelApplyEnabled) + Equals(t, c.ExpParallelPlan, actCtx.ParallelPlanEnabled) }) } } diff --git a/server/events/project_command_context_builder.go b/server/events/project_command_context_builder.go index f681ec4df7..f269a68258 100644 --- a/server/events/project_command_context_builder.go +++ b/server/events/project_command_context_builder.go @@ -33,7 +33,7 @@ type ProjectCommandContextBuilder interface { prjCfg valid.MergedProjectCfg, commentFlags []string, repoDir string, - automerge, deleteSourceBranchOnMerge, parallelPlan, parallelApply, verbose bool, + automerge, deleteSourceBranchOnMerge, parallelApply, parallelPlan, verbose bool, ) []models.ProjectCommandContext } diff --git a/server/events/project_command_context_builder_test.go b/server/events/project_command_context_builder_test.go index d0a3de9bdd..ee85eabb74 100644 --- a/server/events/project_command_context_builder_test.go +++ b/server/events/project_command_context_builder_test.go @@ -81,4 +81,25 @@ func TestProjectCommandContextBuilder_PullStatus(t *testing.T) { assert.Equal(t, models.ErroredPolicyCheckStatus, result[0].ProjectPlanStatus) }) + + t.Run("when ParallelApply is set to true", func(t *testing.T) { + projCfg.Name = "Apply Comment" + When(mockCommentBuilder.BuildPlanComment(projRepoRelDir, projWorkspace, "", []string{})).ThenReturn(expectedPlanCmt) + When(mockCommentBuilder.BuildApplyComment(projRepoRelDir, projWorkspace, "")).ThenReturn(expectedApplyCmt) + pullStatus.Projects = []models.ProjectStatus{ + { + Status: models.ErroredPlanStatus, + RepoRelDir: "dir2", + }, + { + Status: models.ErroredPolicyCheckStatus, + RepoRelDir: "dir1", + }, + } + + result := subject.BuildProjectContext(commandCtx, models.PlanCommand, projCfg, []string{}, "some/dir", false, false, true, false, false) + + assert.True(t, result[0].ParallelApplyEnabled) + assert.False(t, result[0].ParallelPlanEnabled) + }) }