Autoplan would set the "policy_check" status to successful if
there were no modified projects in a PR, but "atlantis plan"
would not. Changed "atlantis plan" to behave like autoplan
in this regard.
* Do not unnecessarily create apply pipeline if it doesn't exist yet
* Updates
* Fix remaining
* Fix test logic
* Cleanup more tests
* Fix test
---------
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
* mod: rename updateCommitStatus func
* feat: add PlannedNoChangesPlanStatus
* Add skipApplyNoChanges option to PlanCommandRunner
* Add skipApplyNoChanges option to ApplyCommandRunner
* Add --skip-apply-no-changes flag
* Fix typo
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
* Rename --skip-apply-no-changes flag
* Refactor updateCommitStatus functions
* chore(docs): add detailed use case for the flag
* test: add plan_command_runner set apply status
* feat: set apply status to successful by default when result is 'No Changes'
---------
Co-authored-by: chroju <chroju@users.noreply.github.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
* feat: when using order group, abort plan/apply if any fail
* feat: add 'abort_on_execution_order_fail' flag on repo level
* feat: use runProjectCmdsParallelGroups in version_command_runner
* chore: add plan tests
---------
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
* fix(discardApprovalOnPlan): add missing conditional and tests
* tests(discardApprovalOnPlan): match for any Pull request or repo for turned off discarding
* Apply suggestions from code review
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
* Update server/events/plan_command_runner.go
* Update server/events/plan_command_runner.go
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
* Delete previous plans on autoplan or atlantis plan
When using non-default workspaces, plans are stored
in pr-and-workspace-specific directories.
If a PR is subsequently updated it might happen that
some of the plans are no longer relevant with regards
to the latest changes.
This change ensures that plans are always deleted
when a generic plan is triggered either by autoplan
or by a "atlantis plan" command.
NB Plans are not cleaned up when specific projects are
planned explicitly with "atlantis plan -p/-d/-w".
* Also delete locks along with plans when running
autoplan or generic plan command
* Fix Plan deletion tests after 0.19.8 rebase
* Fix Plan deletion tests after v0.19.9-pre.20220912 rebase
* Rename struct field to follow camelCase naming convention
Co-authored-by: giuli007 <giuglioz@gmail.com>
* Delete previous plans on autoplan or atlantis plan
When using non-default workspaces, plans are stored
in pr-and-workspace-specific directories.
If a PR is subsequently updated it might happen that
some of the plans are no longer relevant with regards
to the latest changes.
This change ensures that plans are always deleted
when a generic plan is triggered either by autoplan
or by a "atlantis plan" command.
NB Plans are not cleaned up when specific projects are
planned explicitly with "atlantis plan -p/-d/-w".
* Use DeleteLockCommand to delete locks and workdirs
containing previous plans
Co-authored-by: giuli007 <giuglioz@gmail.com>
* Moved CommandContext and CommandResult to models (#193)
* Moved CommandContext and CommandResult to models
* move from models to command
rename CommandContext -> Context
rename CommandResult -> Result
* moved command related helpers into command package
* move ProjectCommandContext and ProjectResult to command/project package
* move project command context and project result
* revert unrelated code
* move tests
* fix left over
* fix linting
* fix tests
* remove unused import
* fix project context dependencies
* fix depenedecies
* fix typo
* add a pending status for apply when running plan command
* fix status updater logic, we should only update the status after we check if the PR is mergeable like the doc next to it says
* do not dismiss the PR if the only our "atlantis/apply" status is pending/failing
* fix logic and tests
* linting
* Adding policy_check support into yaml config
* Added policy check model and runtime structs
* Adding BuildPolicyCheckCommand to ProjectCommandBuilder
* Return incorrectly deleted code
* Remove BuildAutoPolicyPlanCommand from ProjectCommandBuilder
* Split runAutoCommand into two functions
runAutoPlanCommand - does what originally RunAutoplancommand was doing
except now it returns CommandResult and []models.ProjectCommandContext
runAutoPolicyCheckCommand - accepts CommandContext, CommandResult, and
[]models.ProjectCommandContext as arguments and runs PolicyCheckStep runner
* Refactor RunCommentCommand
* Remove BuildPolicyCheckCommand and rename StepCmdExec back to TerraformExec
* Add policy step runner logic and conftest interfaces.
* Add show step runner to policy check stage.
* Adding models.PolicyCheckCommand to buildCtx
This also means buildPlanAllCommands call buildCtx twice once with
models.PlanCommand and once with models.PolicyCheckCommand
* Adding new project_command_builder that supports policy_check
* Refactoring PolicyCheck specific logic into a PolicyCheckProjectCommandBuilder
* Moving events.CommandContext to models.CommandContext this will allow me
to remove buildCtx method and move ProjectCommandContext creation into
models package
* Policy Owners might be different types, for that reason we are
refactoring Owners into its own struct with specific keys defining
different owner types
Co-authored-by: Nish Krishnan <nishk@lyft.com>
Co-authored-by: Nish Krishnan <nishkrishnan@users.noreply.github.com>