Commit Graph

58 Commits

Author SHA1 Message Date
Raymond Chen
4e4568501d fix: fix unmarshall error in graphql call (#2128)
* Fix unmarshall error in GraphQL call #2090

* Add unit tests for GetTeamNamesForUser

* Fix lint error
2022-03-09 14:37:58 -08:00
Andre Ziviani
1a7cc360a9 feat: add a pending status for apply when running plan command (#2053)
* 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
2022-03-04 14:49:54 -05:00
Raymond Chen
136b23ac11 fix: get user teams with GitHub GraphQL API (#2045) 2022-02-04 19:47:30 -05:00
Sarvar Muminov
7a927c050b Moving config files to core/config (#2036)
* Moving config files to core/config

* fix package names

* fix package dependencies

* linting fixes

* more linting fixes

* ran golangci-lint run --fix
2022-02-03 11:06:04 -08:00
Iain Lane
e3f0dd5553 Retry /files/ requests to github (#2002)
Similar to #1131, we see this for /files/ too, resulting in a plan
error.

Closes #1905
2022-01-25 09:49:11 -05:00
Nish Krishnan
64612019f4 Revert "feat: filter out atlantis/apply from mergeability clause (#18… (#1968)
* Revert "feat: filter out atlantis/apply from mergeability clause (#1856)"

This reverts commit d01796b9d9.

* Add missing import.
2022-01-01 15:11:39 -05:00
Paul Erickson
bc368465a0 feat: add GitHub team allowlist configuration option (#1694)
* Add GitHub team allowlist configuration option

Co-authored-by: PePe (Jose) Amengual <jamengual@sonatype.com>
Co-authored-by: Troy Neeriemer <tneeriemer@sonatype.com>
Co-authored-by: Ted Roby <troby+github@sonatype.com>
Co-authored-by: Paul Erickson <perickson@sonatype.com>

* Check team allowlist in command runner, rather than event controller

* Remove unneeded trimming

* Test wildcard groups and commands

* Improve error logging

Co-authored-by: PePe (Jose) Amengual <jamengual@sonatype.com>
Co-authored-by: Troy Neeriemer <tneeriemer@sonatype.com>
Co-authored-by: Ted Roby <troby+github@sonatype.com>
2021-12-21 16:08:43 -08:00
Nish Krishnan
d01796b9d9 feat: filter out atlantis/apply from mergeability clause (#1856)
Filter out atlantis apply status during mergeability check.
2021-10-19 13:51:22 -07:00
Nicholas (Nick) Meyer
875e2adc40 Improve github pull request call retries (#1810)
* Improve github pull request call retries

Retry with fixed 1 second backoff up to 3 retries was added by #1131 to
address #1019, but the issue continued to show up (#1453).

Increase max attempts to 5 and use exponential backoff for a maximum
total retry time of (2^n - n - 1) seconds, which is roughly 30 seconds
for current max attempts n = 5.

Also move the sleep to the top of the loop so that we never sleep
without sending the request again on the last iteration.

* Fix style with gofmt -s
2021-10-04 09:59:53 -07:00
Aayush Gupta
bb2c239dd9 Updating client interface and adding ApprovalStatus model (#1827) 2021-09-22 12:41:05 -07:00
Gábor Lipták
a4f0e3a467 Bump golangci to 1.39.0 (#1541)
Signed-off-by: Gábor Lipták <gliptak@gmail.com>
2021-05-26 21:00:20 -04:00
Nish Krishnan
79309ed39c [ORCA-559] Fix hide previous command logic (#37) (#1549) 2021-05-03 12:47:23 -07:00
Istvan Tapaszto
632460b20b Delete source branch on merge (#1357)
Co-authored-by: Tapaszto, Istvan <istvan.tapaszto@msciintegration.onmicrosoft.com>
2021-04-22 09:54:18 -07:00
Nish Krishnan
7ac8106f8a Add structured logger (#54) (#1467)
This is two changes:

Replacing all usages of SimpleLogger with it's interface SimpleLogging which makes it easier to swap out loggers going forward
Nukes SimpleLogger in favor of StructuredLogger which allows us to better analyze logs in our log management system we choose.
2021-04-06 12:02:25 -07:00
Gábor Lipták
832afeaec1 Correct typo (#1424) 2021-02-23 17:04:35 -05:00
Nish Krishnan
1513ee6421 Add support for fetching gh app user. (#30) (#1334)
* Add support for fetching gh app user. (#30)

* Upgrade pegomock.

* go mod vendor.
2021-01-05 15:21:31 -08:00
Luke Kysow
cbe0b18c0e Refactor --skip-clone-no-changes work. 2020-08-18 15:48:33 -07:00
Quan Hoang
54e3dc2ef0 Skip cloning PR repository in case of no projects configured in repo config file were changed 2020-08-18 15:48:05 -07:00
Luke Kysow
67b2217245 Retry get pull request calls to github
These calls have been 404'ing lately, likely due to eventual consistency
issues on GitHub's side where they send the PR created webhook but it's
not yet available on their API.

To work around this, we will retry up to 3 times with a 1s delay.
2020-07-25 23:46:41 -07:00
Chris Alexander
4568213356 Reversed if statement for comment splitting 2020-07-10 18:13:05 -05:00
Mark Keisler
caf3319b7d Bring back the change from
2f074727e2 (diff-e348084f0b7562996b0bd5d429158e53)
that was clobbered.
2020-07-09 11:21:00 -05:00
Chris Alexander
aa1bfc0a27 Add "plan" to continued statement 2020-07-01 10:11:33 -05:00
Luke Kysow
875abf1362 Refactoring to github app code
- rename gh-app-key to gh-app-key-file for clarity
- change git credentials writer to append a line if there is an existing
.git-credentials file and in the case of the github app to replace the
old github app line
- removed automatically setting --write-git-creds to true when using a
github app and instead requiring this is set specifically
2020-06-19 11:41:44 -07:00
rob
011d3f8229 Test against a live repo, fix accordingly
more docs, add installation step
2020-06-03 20:25:11 -04:00
rob
227ce9cbf4 Upgrade to github/v31 for CompleteAppManifest
split fixtures out elsewhere, add working dir test
2020-06-03 20:18:13 -04:00
Roberto Hidalgo
199cdfe192 Play around with github app credentials 2020-06-03 20:16:24 -04:00
Sam Park
2f074727e2 Fix GraphQL URL for Github Enterprise
Partially addresses #1009, but doesn't fix it entirely. The 406 response
is still a puzzler.
2020-06-03 11:34:44 -07:00
Christopher Ketchum
88e397ed6d vcs/github_client: add logging around github API calls (#1042) 2020-06-01 16:42:03 -07:00
Luke Kysow
3eaa67e1ef Update go-github, empty automerge commit
Using an empty auto-merge commit will cause GitHub to autogenerate its
own commit message like would happen when using the UI.
2020-05-25 12:07:52 -07:00
David McPike
bc069d4b0c Add MarkdownPullLink function to VCS clients 2020-04-21 09:19:55 -05:00
Luke Kysow
6e8b4eed16 Small refactor 2020-04-15 21:44:34 -07:00
Sam Park
dcd43bead1 Add pagination 2020-01-24 21:51:01 -08:00
Sam Park
fd93af8a55 Fix body string check 2020-01-24 21:51:01 -08:00
Sam Park
610c9b2c37 Add hide old comments VCS interface function
And implement the Github version.

The Golang Github client recommends using shurcooL/githubv4.
2020-01-24 21:51:01 -08:00
Luke Kysow
4e8d19be0a Convert AZDO paths to relative
Previously the AZDO paths returned by GetModifiedFiles were absolute.
Now they're relative to the repo root to match the rest of the VCS's.
2020-01-02 09:45:38 -06:00
Dave D'Amico
b025a9037a Fix for Issue 727 (#762)
* initial commit for testing

* testing update

* go fmt
2019-09-03 13:00:17 -04:00
Luke Kysow
b81fe9a5e5 Switch to gomod 2019-08-26 18:38:22 +02:00
Luke Kysow
db1203bf0f Add better support for remote plan/apply.
Features:
- remote plans and applies will set a commit status with a link to the
Terraform Enterpise UI where the streaming output can be viewed.
- because remote plans don't support the -out flag, we diff the plan
output between plan and apply phases to ensure users are applying the
plan they expected

How:
We add a new capability to execute a terraform command while
concurrently reading its real-time output and performing actions
accordingly.
2019-02-27 17:26:00 -05:00
Luke Kysow
b749a32c5f Allow setting 'source' for commit statuses
This is needed so we can set different commit statuses for plan and
apply phases.

Also, append os env variables to git commands during cloning. This fixed
a bug when running tests where I got an error because git couldn't expand
'~' from its git config to my home directory because the HOME env var
wasn't set.
2019-02-25 17:10:20 -05:00
Luke Kysow
def41f6cef Add tests for GH merge-type detection. 2019-02-11 11:12:15 -06:00
Brenden Matthews
862b5228d0 [automerge] Use available merge methods.
For repos with certain merge methods disabled (such as 'merge'), simply
hitting the GitHub `/merge` endpoint is not sufficient. Instead, we need
to check which methods are actually available, then use the appropriate
method.

With this change it will:

 1. Default to 'merge' if enabled
 2. Use 'rebase' if 'merge' is disabled and rebase is enabled
 3. Use 'squash' if 'merge' is disabled
2019-02-07 16:18:28 -05:00
Luke Kysow
74e9bbb82b Add automerge feature.
Automerging merges pull requests automatically if all plans have been
successfully applied.

* Save status of PR's to BoltDB so after each apply, we can check if
there are pending plans.
* Add new feature where we delete successful plans *unless* all plans
have succeeded *if* automerge is enabled. This was requested by users
because when automerge is enabled, they want to enforce that a pull
request's changes have been fully applied. They asked that plans not be
allowed to be applied "piecemeal" and instead, all plans must be
generated successfully prior to allowing any plans to be applied.
2019-02-06 16:27:43 -06:00
Luke Kysow
3d8138d3fa Include moved files in GetModifiedFiles
Implement the change from the previous commit for GitLab and Bitbucket
Server/Cloud. Test the change for GitHub.

If a file is moved, we want to run plan in the directory it is moved to
*and* the directory it was moved from.
2019-01-07 16:36:09 -05:00
Luke Kysow
e93384fdb0 Use mergeable_state to determine if mergeable
- Need to use the mergeable_state field in GitHub to know if a pull
request is mergeable.
- Add tests.
- Since we updated our vendored go-github library, fix how we were
creating webhooks in testdrive.
2018-12-12 11:17:09 -06:00
Brenden Matthews
e001353ae9 Add mergeable requirement.
Introduce new `mergeable` requirement, in similar vein to the `approved`
requirement. Ran `make go-generate` to update mocks accordingly.

This addresses issue #43.
2018-12-11 16:00:04 -05:00
Luke Kysow
bf19968cec Split Bitbucket Server comments if over max length
- Refactor the comment split method into a common package
2018-12-04 09:58:37 -06:00
Luke Kysow
63557b4cb5 Change exact open/closing of split messages. Test. 2018-11-22 18:41:18 -06:00
Tobias Bielohlawek
e32a57b6f3 Fix broken format for continued comments on GitHub
Adds close and (re)open <details> tag in between the split portions to 
ensure the markup is correct across multiple comments. This isn't the prettiest, but a close result, under the assumption continued-comments are in 99% within a terraform output anyway...
2018-11-22 15:07:56 -06:00
Luke Kysow
e9b7001266 Add godocs. Refactor ProjectResult. Golint errors. 2018-08-30 16:47:17 -06:00
Luke Kysow
bd8335f82f Rename CommitStatus enums 2018-07-20 12:43:48 +02:00