Skip to content

Commit

Permalink
Merge branch 'main' into parallel_operation_config
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudomorph authored May 12, 2023
2 parents 9fa0d02 + 4e867fc commit 600735c
Show file tree
Hide file tree
Showing 22 changed files with 768 additions and 49 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/atlantis-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
env:
# Set docker repo to either the fork or the main repo where the branch exists
DOCKER_REPO: ghcr.io/${{ github.repository }}
# Push if not a pull request or this is a fork
PUSH: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
# Push if not a pull request and references the main branch
PUSH: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -75,9 +75,9 @@ jobs:
type=semver,pattern={{version}},prefix=v,enable=${{ matrix.image_type == 'alpine' }}
type=semver,pattern={{major}}.{{minor}},prefix=v,suffix=${{ env.SUFFIX }}
# dev
type=raw,value=dev,suffix=${{ env.SUFFIX }}-{{ sha }}
type=raw,event=push,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'main') && matrix.image_type == 'alpine' }},suffix=
type=raw,event=push,value=dev,enable={{is_default_branch}},suffix=${{ env.SUFFIX }}
type=raw,event=push,value=dev,enable={{is_default_branch}},suffix=${{ env.SUFFIX }}-{{ sha }}
type=raw,event=push,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'main') && matrix.image_type == 'alpine' }},suffix=
# prerelease
type=raw,event=tag,value=prerelease-latest,enable=${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, 'pre') && matrix.image_type == 'alpine' }},suffix=
type=raw,event=tag,value=prerelease-latest,enable=${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, 'pre') }},suffix=${{ env.SUFFIX }}
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# what distro is the image being built for
ARG ALPINE_TAG=3.17.3
ARG ALPINE_TAG=3.18.0
ARG DEBIAN_TAG=11.7-slim

# Stage 1: build artifact and download deps
Expand Down Expand Up @@ -178,8 +178,8 @@ RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/ma
curl~=8.0 \
unzip~=6.0 \
bash~=5.2 \
openssh~=9.1_p1 \
libcap~=2.66 \
openssh~=9.3_p1 \
libcap~=2.68 \
dumb-init~=1.2 \
gcompat~=1.1

Expand Down
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (

require (
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/cloudflare/circl v1.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion e2e/go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/cloudflare/circl v1.1.0 h1:bZgT/A+cikZnKIwn7xL2OBj012Bmvho/o6RpRvv3GKY=
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/circl v1.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/color v1.13.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.1.0 h1:bZgT/A+cikZnKIwn7xL2OBj012Bmvho/o6RpRvv3GKY=
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
Expand Down
8 changes: 7 additions & 1 deletion runatlantis.io/docs/repo-level-atlantis-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ automerge: true
delete_source_branch_on_merge: true
parallel_plan: true
parallel_apply: true
abort_on_execution_order_fail: true
projects:
- name: my-project-name
branch: /main/
Expand All @@ -64,6 +65,7 @@ projects:
plan_requirements: [mergeable, approved, undiverged]
apply_requirements: [mergeable, approved, undiverged]
import_requirements: [mergeable, approved, undiverged]
execution_order_group: 1
workflow: myworkflow
workflows:
myworkflow:
Expand Down Expand Up @@ -262,6 +264,7 @@ to be allowed to set this key. See [Server-Side Repo Config Use Cases](server-si
### Order of planning/applying
```yaml
version: 3
abort_on_execution_order_fail: true
projects:
- dir: project1
execution_order_group: 2
Expand All @@ -271,7 +274,10 @@ projects:
With this config above, Atlantis runs planning/applying for project2 first, then for project1.
Several projects can have same `execution_order_group`. Any order in one group isn't guaranteed.
`parallel_plan` and `parallel_apply` respect these order groups, so parallel planning/applying works
in each group one by one.
in each group one by one.

If any plan/apply fails and `abort_on_execution_order_fail` is set to true on a repo level, all the
following groups will be aborted. For this example, if project2 fails then project1 will not run.

### Custom Backend Config
See [Custom Workflow Use Cases: Custom Backend Config](custom-workflows.html#custom-backend-config)
Expand Down
10 changes: 10 additions & 0 deletions server/core/config/raw/repo_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const DefaultDeleteSourceBranchOnMerge = false
// DefaultEmojiReaction is the default emoji reaction for repos
const DefaultEmojiReaction = ""

// DefaultAbortOnExcecutionOrderFail being false is the default setting for abort on execution group failiures
const DefaultAbortOnExcecutionOrderFail = false

// RepoCfg is the raw schema for repo-level atlantis.yaml config.
type RepoCfg struct {
Version *int `yaml:"version,omitempty"`
Expand All @@ -37,6 +40,7 @@ type RepoCfg struct {
DeleteSourceBranchOnMerge *bool `yaml:"delete_source_branch_on_merge,omitempty"`
EmojiReaction *string `yaml:"emoji_reaction,omitempty"`
AllowedRegexpPrefixes []string `yaml:"allowed_regexp_prefixes,omitempty"`
AbortOnExcecutionOrderFail *bool `yaml:"abort_on_execution_order_fail,omitempty"`
}

func (r RepoCfg) Validate() error {
Expand Down Expand Up @@ -88,6 +92,11 @@ func (r RepoCfg) ToValid() valid.RepoCfg {
emojiReaction = *r.EmojiReaction
}

abortOnExcecutionOrderFail := DefaultAbortOnExcecutionOrderFail
if r.AbortOnExcecutionOrderFail != nil {
abortOnExcecutionOrderFail = *r.AbortOnExcecutionOrderFail
}

return valid.RepoCfg{
Version: *r.Version,
Projects: validProjects,
Expand All @@ -99,5 +108,6 @@ func (r RepoCfg) ToValid() valid.RepoCfg {
DeleteSourceBranchOnMerge: r.DeleteSourceBranchOnMerge,
AllowedRegexpPrefixes: r.AllowedRegexpPrefixes,
EmojiReaction: emojiReaction,
AbortOnExcecutionOrderFail: abortOnExcecutionOrderFail,
}
}
47 changes: 26 additions & 21 deletions server/core/config/raw/repo_cfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,43 +259,48 @@ func TestConfig_ToValid(t *testing.T) {
},
},
{
description: "automerge and parallel_apply omitted",
description: "automerge, parallel_apply and abort_on_execution_order_fail omitted",
input: raw.RepoCfg{
Version: Int(2),
},
exp: valid.RepoCfg{
Version: 2,
Automerge: false,
ParallelApply: false,
Workflows: map[string]valid.Workflow{},
Version: 2,
Automerge: false,
ParallelApply: false,
AbortOnExcecutionOrderFail: false,
Workflows: map[string]valid.Workflow{},
},
},
{
description: "automerge and parallel_apply true",
description: "automerge, parallel_apply and abort_on_execution_order_fail true",
input: raw.RepoCfg{
Version: Int(2),
Automerge: Bool(true),
ParallelApply: Bool(true),
Version: Int(2),
Automerge: Bool(true),
ParallelApply: Bool(true),
AbortOnExcecutionOrderFail: Bool(true),
},
exp: valid.RepoCfg{
Version: 2,
Automerge: true,
ParallelApply: true,
Workflows: map[string]valid.Workflow{},
Version: 2,
Automerge: true,
ParallelApply: true,
AbortOnExcecutionOrderFail: true,
Workflows: map[string]valid.Workflow{},
},
},
{
description: "automerge and parallel_apply false",
description: "automerge, parallel_apply and abort_on_execution_order_fail false",
input: raw.RepoCfg{
Version: Int(2),
Automerge: Bool(false),
ParallelApply: Bool(false),
Version: Int(2),
Automerge: Bool(false),
ParallelApply: Bool(false),
AbortOnExcecutionOrderFail: Bool(false),
},
exp: valid.RepoCfg{
Version: 2,
Automerge: false,
ParallelApply: false,
Workflows: map[string]valid.Workflow{},
Version: 2,
Automerge: false,
ParallelApply: false,
AbortOnExcecutionOrderFail: false,
Workflows: map[string]valid.Workflow{},
},
},
{
Expand Down
1 change: 1 addition & 0 deletions server/core/config/valid/repo_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type RepoCfg struct {
RepoLocking *bool
EmojiReaction string
AllowedRegexpPrefixes []string
AbortOnExcecutionOrderFail bool
}

func (r RepoCfg) FindProjectsByDirWorkspace(repoRelDir string, workspace string) []Project {
Expand Down
2 changes: 1 addition & 1 deletion server/events/apply_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (a *ApplyCommandRunner) Run(ctx *command.Context, cmd *CommentCommand) {
var result command.Result
if a.isParallelEnabled(projectCmds) {
ctx.Log.Info("Running applies in parallel")
result = runProjectCmdsParallelGroups(projectCmds, a.prjCmdRunner.Apply, a.parallelPoolSize)
result = runProjectCmdsParallelGroups(ctx, projectCmds, a.prjCmdRunner.Apply, a.parallelPoolSize)
} else {
result = runProjectCmds(projectCmds, a.prjCmdRunner.Apply)
}
Expand Down
Loading

0 comments on commit 600735c

Please sign in to comment.