Skip to content

Commit

Permalink
Merge branch 'main' into add-env-to-post-hook
Browse files Browse the repository at this point in the history
  • Loading branch information
a1k0u authored Feb 10, 2025
2 parents e9665f6 + 452040f commit d513b21
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/atlantis-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ jobs:
go-version-file: "go.mod"

- name: Set up QEMU
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3
uses: docker/setup-qemu-action@4574d27a4764455b42196d70a065bc6853246a25 # v3
with:
image: tonistiigi/binfmt:latest
platforms: arm64,arm

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3
# https://github.com/docker/build-push-action/issues/761#issuecomment-1575006515
with:
driver-opts: |
Expand Down Expand Up @@ -216,7 +216,7 @@ jobs:

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3
# https://github.com/docker/build-push-action/issues/761#issuecomment-1575006515
with:
driver-opts: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/testing-env-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Set up QEMU
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3
uses: docker/setup-qemu-action@4574d27a4764455b42196d70a065bc6853246a25 # v3
with:
image: tonistiigi/binfmt:latest
platforms: arm64,arm

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3

- name: Login to Packages Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
Expand Down
3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ builds:
archives:
- id: zip
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
format: zip
formats:
- zip
files:
- none*

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/moby/patternmatcher v0.6.0
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/opentofu/tofudl v0.0.0-20240923062014-8c1e00f33ce6
github.com/opentofu/tofudl v0.0.0-20250129123822-d4254f2a6147
github.com/petergtz/pegomock/v4 v4.1.0
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU=
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
github.com/opentofu/tofudl v0.0.0-20240923062014-8c1e00f33ce6 h1:+1yJm0gEoDaxYmMhmmU3gRAOMx3A43z84bokm1dQroU=
github.com/opentofu/tofudl v0.0.0-20240923062014-8c1e00f33ce6/go.mod h1:CD1BhvxxNPp4ZBwNBjWycf5isG9UaPrzfE7J/E/s6RY=
github.com/opentofu/tofudl v0.0.0-20250129123822-d4254f2a6147 h1:FRrWXOEB5P/rmDbXNON3erWlAxe8NtxEeAfYqMk0oRY=
github.com/opentofu/tofudl v0.0.0-20250129123822-d4254f2a6147/go.mod h1:HeIabsnOzo0WMnIRqI13Ho6hEi6tu2nrQpzSddWL/9w=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/petergtz/pegomock/v4 v4.1.0 h1:Reoy2rlwshuxNaD2ZWp5TrSCrmoFH5SSLHb5U1z2pog=
Expand Down
6 changes: 3 additions & 3 deletions server/events/vcs/azuredevops_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (g *AzureDevopsClient) UpdateStatus(logger logging.SimpleLogging, repo mode
return errors.Wrap(err, "getting pull request")
}
if resp.StatusCode != http.StatusOK {
return errors.Wrapf(err, "http response code %d getting pull request", resp.StatusCode)
return errors.Errorf("http response code %d getting pull request", resp.StatusCode)
}
if source.GetSupportsIterations() {
opts := azuredevops.PullRequestIterationsListOptions{}
Expand All @@ -276,7 +276,7 @@ func (g *AzureDevopsClient) UpdateStatus(logger logging.SimpleLogging, repo mode
return errors.Wrap(err, "listing pull request iterations")
}
if resp.StatusCode != http.StatusOK {
return errors.Wrapf(err, "http response code %d listing pull request iterations", resp.StatusCode)
return errors.Errorf("http response code %d listing pull request iterations", resp.StatusCode)
}
for _, iteration := range iterations {
if sourceRef := iteration.GetSourceRefCommit(); sourceRef != nil {
Expand All @@ -297,7 +297,7 @@ func (g *AzureDevopsClient) UpdateStatus(logger logging.SimpleLogging, repo mode
return errors.Wrap(err, "creating pull request status")
}
if resp.StatusCode != http.StatusOK {
return errors.Wrapf(err, "http response code %d creating pull request status", resp.StatusCode)
return errors.Errorf("http response code %d creating pull request status", resp.StatusCode)
}
return err
}
Expand Down
36 changes: 18 additions & 18 deletions server/events/vcs/gitlab_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,27 @@ func (g *GitlabClient) UpdateStatus(logger logging.SimpleLogging, repo models.Re
}
)

for i := 0; i < maxAttempts; i++ {
for {
attempt := int(retryer.Attempt()) + 1
logger := logger.With(
"attempt", i+1,
"attempt", attempt,
"max_attempts", maxAttempts,
"repo", repo.FullName,
"commit", commit.ShortID,
"state", state.String(),
)

_, resp, err = g.Client.Commits.SetCommitStatus(repo.FullName, pull.HeadCommit, setCommitStatusOptions)
_, resp, err := g.Client.Commits.SetCommitStatus(repo.FullName, pull.HeadCommit, setCommitStatusOptions)
if err == nil {
if retryer.Attempt() > 0 {
logger.Info("GitLab returned HTTP [200 OK] after updating commit status")
}

return nil
}
if attempt == maxAttempts {
return errors.Wrap(err, fmt.Sprintf("failed to update commit status for '%s' @ '%s' to '%s' after %d attempts", repo.FullName, pull.HeadCommit, src, attempt))
}

if resp != nil {
logger.Debug("POST /projects/%s/statuses/%s returned: %d", repo.FullName, pull.HeadCommit, resp.StatusCode)
Expand All @@ -481,26 +492,15 @@ func (g *GitlabClient) UpdateStatus(logger logging.SimpleLogging, repo models.Re
// GitLab does not allow merge requests to be merged when the pipeline status is "running."

if resp.StatusCode == http.StatusConflict {
sleep := retryer.ForAttempt(float64(i))

logger.With("retry_in", sleep).Warn("GitLab returned HTTP [409 Conflict] when updating commit status")
time.Sleep(sleep)

continue
logger.Warn("GitLab returned HTTP [409 Conflict] when updating commit status")
}
}

// Log we got a 200 OK response from GitLab after at least one retry to help with debugging/understanding delays/errors.
if err == nil && i > 0 {
logger.Info("GitLab returned HTTP [200 OK] after updating commit status")
}
sleep := retryer.Duration()

// Return the err, which might be nil if everything worked out
return err
logger.With("retry_in", sleep).Warn("GitLab errored when updating commit status: %w", err)
time.Sleep(sleep)
}

// If we got here, we've exhausted all attempts to update the commit status and still failed, so return the error upstream
return errors.Wrap(err, fmt.Sprintf("failed to update commit status for '%s' @ '%s' to '%s' after %d attempts", repo.FullName, pull.HeadCommit, src, maxAttempts))
}

func (g *GitlabClient) GetMergeRequest(logger logging.SimpleLogging, repoFullName string, pullNum int) (*gitlab.MergeRequest, error) {
Expand Down

0 comments on commit d513b21

Please sign in to comment.