Commit Graph

1012 Commits

Author SHA1 Message Date
MB
bcd917ffba fix(gitlab): Prevent considering non-head pipelines skipped by default (#3695)
By fixing nil pointer reference in 3428 we unveiled yet another bug now that the code is able to run further:

When an MR with no HeadPipeline exists its commits are set to skipped by default and thus create some mess when running "PullMergeable" (rendering the MR useless)

The bug was caught by the tests, however, in an attempt to make the build pass and unblock we create a patch to ignore that test.

In order to prevent further problems, this MR:

* Updates the test stack to run all plan/apply commands in the context
  of "HeadLess" Pipelines
* Fixes the default of skipped pipeline to false (as it is better to
  assume it is NOT skipped since that prevents the merge in most cases)
* Make all integratiion tests pass

References:

* Original MR: https://github.com/runatlantis/atlantis/pull/3428
* Tests Patch MR : https://github.com/runatlantis/atlantis/pull/3653
2023-08-23 17:07:38 -04:00
smstone
b8bb6df40a feat: Slack notifications matched on base branch name (#3644)
* Add ability to send slack notification matched on base branch name

* Update BranchRegex usage doc

* Add test with invalid branch and workspace regex
2023-08-22 15:13:00 +00:00
Finn Arne Gangstad
760190629e fix: complete the upgrade to github v54 to unbreak tests (#3691) 2023-08-21 11:38:17 -04:00
renovate[bot]
55e24fbbf5 fix(deps): update module github.com/google/go-github/v53 to v54 in go.mod (#3676)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-17 00:41:13 +00:00
Artur Rodrigues
049c146b2c fix(github): prevent null pointer dereferencing when using AllowMergeableBypassApply with no required checks on branch protection (#3672)
* Implement test for allow mergeable bypass apply with no branch protection checks

* Report true combined status if no branch protection required status checks

* Remove warning on feature flag utilization
2023-08-15 10:11:37 -07:00
Ghais Zaher
25c6b43a63 fix: gitlab client failing test (#3653)
* fix: gitlab client failing test

* change HeadCommit to `67cb91d3f6198189f433c045154a885784ba6977`

* remove test case for now
2023-08-09 13:31:36 -04:00
Simon Heather
ec77a951b0 chore: Fix Go Static Check Errors (#3637)
* Fix Go Static Checks

* Fix working dir tests
2023-08-05 16:41:54 -04:00
MB
89a028ffd2 fix(gitlab): Prevent nil pointer dereference when HeadPipeline is empty (#3428)
In this particular example `mr.HeadPipeline.SHA` panics on a nil pointer dereference because HeadPipeline is empty.

This seems to be caused by the lack of permission to update the commit status.

```go
runtime.gopanic
        runtime/panic.go:1038
runtime.panicmem
        runtime/panic.go:221
runtime.sigpanic
        runtime/signal_unix.go:735
github.com/runatlantis/atlantis/server/events/vcs.(*GitlabClient).PullIsMergeable
        github.com/runatlantis/atlantis/server/events/vcs/gitlab_client.go:208
github.com/runatlantis/atlantis/server/events/vcs.(*ClientProxy).PullIsMergeable
        github.com/runatlantis/atlantis/server/events/vcs/proxy.go:72
github.com/runatlantis/atlantis/server/events/vcs.(*pullReqStatusFetcher).FetchPullStatus
        github.com/runatlantis/atlantis/server/events/vcs/pull_status_fetcher.go:28
github.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run
        github.com/runatlantis/atlantis/server/events/apply_command_runner.go:105
github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand
        github.com/runatlantis/atlantis/server/events/command_runner.go:252
```

The least invasive solution is to simply use the commit-hash from pull and guess that the pipeline was "skipped" unless the HeadPipeline is there.

The outcome is:

When mr.HeadPipeline is present:
- use the commit hash and status from the HeadPipeline
When mr.HeadPipeline is NOT present:
- use the commit hash from pull request struct
- assume the pipeline was "skipped"

In cases where GitLab is configured to require a pipeline to pass, this results on a message saying the MR is not mergeable.

More info:
- https://github.com/runatlantis/atlantis/issues/1852
2023-08-04 13:00:47 -04:00
chroju
fbb12fe3b9 feat: set atlantis/apply check to successful if all plans are No Changes (#3378)
* 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>
2023-08-03 11:15:13 -04:00
Torben Tretau
62271955de fix(github): Mergeable requirement for fork PRs (#3620)
While using a PR from a fork and the "Github allow mergeable bypass apply" flag, the mergeable checks were run with the wrong owner in the request, leading to 404. By choosing the owner from the head repo data it should work both, for fork PRs and in-repo PRs.

Co-authored-by: Dylan Page <dylan.page@autodesk.com>
2023-08-01 02:25:31 +00:00
Simon Heather
b024cef470 chore: Update server/events/working_dir Logging Configuration (#3636)
* Update server/events/working_dir logging

* Add e2e FileWorkspace logger

* Fix github app working dir test logger

* Update working_dir_test

---------

Co-authored-by: Dylan Page <dylan.page@autodesk.com>
2023-07-31 22:10:03 -04:00
Shouichi Kamiya
2bd778b01e fix: auto plan when .terraform.lock.hcl changed (#3473)
Problem

When `projects` are specified and `when_modified` is not specified via
the config file, changing `.terraform.lock.hcl` file won't trigger auto
plan. This is because the default `raw.WhenModified` does not include
`.terraform.lock.hcl`.

Note that when projects are auto detected, changing
`.terraform.lock.hcl` triggers auto plan. This is because the
`cmd.DefaultAutoplanFileList` includes `.terraform.lock.hcl`.

Solution

Include `.terraform.lock.hcl` to the default `raw.WhenModified`.
2023-07-31 11:29:33 -04:00
Luke Massa
cbb86c248e feat: Allow for negations in repo allowlist (#3414)
* feat: Omit repos from allowlist

* Add quote in comment

* Better comment

* Remove test
2023-07-31 13:46:11 +00:00
William Richard
3ca5d82ebf fix: Include information about imports in PlanSuccessStats (#3621)
* Include information about imports in PlanSuccessStats

Terraform 1.5 introduced a feature to import existing resources into
state via code.

https://developer.hashicorp.com/terraform/language/import

When you run `terraform plan` with imports, the output includes information
about the imported resources, which breaks the current regex for parsing
plan changes.

This PR updates the regex to include the, optional, import information.

* Use the ?

Co-authored-by: Benjamin Ullian <5695343+bnu0@users.noreply.github.com>

---------

Co-authored-by: Will Richard <wrichard@seatgeek.com>
Co-authored-by: Benjamin Ullian <5695343+bnu0@users.noreply.github.com>
Co-authored-by: Dylan Page <dylan.page@autodesk.com>
2023-07-30 20:04:29 +00:00
Simon Heather
75b4b069e7 Fix Simple Logger Log Function (#3631) 2023-07-30 15:33:30 -04:00
Simon Heather
9aae60f1d3 Conftest Log Fix (#3632) 2023-07-28 19:49:38 +00:00
Tom Baker
a791fbfff6 feat: Add username to main lock screen (#3597)
* Add username to lock screen
2023-07-17 16:18:52 +00:00
Ross Strickland
1c232b5f90 fix: broken automerge logic (#3591)
* fix automerge logic.

* address failing autoplan test with automerge
2023-07-10 13:23:16 -04:00
Almenon
78632beb20 fix(bitbucket): avoid extra plans using a local LRU (#3402) 2023-07-07 18:35:22 -04:00
Simon Heather
b8994190be feat: Add Support for Customising the Shell for Pre and Post Workflow Hooks (#3451) 2023-07-07 18:34:01 -04:00
Ross Strickland
76c482b83a feat: global repo params (#3379) 2023-07-07 18:33:21 -04:00
Simon Heather
847cab74c4 feat: Add Command Name Environment Variable to Pre/Post Workflow Executions (#3571)
* Add Workflow Command Name env var

* Update tests

* Update command runner

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-07-07 16:21:32 -04:00
Simon Heather
91593b647b fix: Discarding a Plan Causes the Whole Working Directory to be Deleted (#3553) 2023-07-07 11:12:06 -04:00
Simon Heather
79a42ee90c Plan Discarded Fix (#3550) 2023-07-07 10:26:22 -04:00
Andre Ziviani
b6466bdfd2 fix: Tests broken by #3503 (#3583) 2023-07-06 22:22:47 +00:00
Andre Ziviani
974eed3803 feat: Disable policy check on some repositories (#3503)
* feat: Allow enabling policy check per repository

* chore: Tests

* chore: Docs

* chore: Improve tests

* chore: E2E tests
2023-07-06 16:39:36 -04:00
Simon Heather
fce28ebceb fix: Atlantis Triggers AutoPlans on Non-Code Change GitLab Merge Event Webhooks (#3567)
* Gitlab merge event fix

* Update events controller tests

* Update eventrsController formatting

* Update events controller test formatting

* Revert gitlab_request_parser_validator

* Update event_parser

* Update tests

* Add new testdata

* Add testdata EOF LF

* Update gitlab-merge-request-event-update-reviewer.json

* Update gitlab-merge-request-event-update-milestone.json
2023-07-06 12:57:32 -07:00
Simon Heather
8552607c2b Web Console Scrollbar Fix (#3574)
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-07-05 21:33:14 +00:00
Simon Heather
0d1f87810d fix: Gitlab Autoplan wont trigger when switching Draft to Ready (#3568)
* Fix: Gitlab Autoplan wont trigger when switching Draft to Ready

* Update gitlab-merge-request-event-mark-as-ready.json

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-07-05 12:56:21 -07:00
Yunchi Luo
a6161c9926 feat: Add an output option to filter output for custom run steps (#3518)
* feat: Add an `output` option to filter output for custom run steps
2023-06-30 10:00:31 -04:00
Simon Heather
c6801990db feat: update the lock detail web page to use a modern grid layout (#3552)
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-06-27 23:14:38 -04:00
Ken Kaizu
3954955e13 fix(deps): update module github.com/petergtz/pegomock/v3 to v4 (#3534)
* fix(deps): update module github.com/petergtz/pegomock/v3 to v4 in go.mod

* remove pegomock generate m option, which is not support after v4

* make regen-mocks

* replace pegomock v4 primitive eq/matchers

* convert pegomock v4 Eq/Any matchers

* remove custom models.Repo matcher

* pegomock v4 cannot use result method args

ref https://github.com/petergtz/pegomock/issues/123

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-20 15:05:23 -04:00
Ross Strickland
7545296741 fix: parse custom run step output in policy_check (#3502)
* parse custom run output in policy_check

* error if no conftest output

* e2e test

* Adding other policy template.

* update markdown renderer test
2023-06-20 14:55:37 -04:00
Simon Heather
556de93300 Gitlab Hide Previous Comments (#3476) 2023-06-13 21:03:36 -05:00
nitrocode
e505817a7d chore(deps): bump pegomock v3.0.1 (#3515) 2023-06-13 11:36:09 -07:00
Simon Heather
86607d8aeb feat: Add GitLab Reaction Emojis on MR Comments (#3456)
* Add GitLab Reaction Emoji

* Update docs

* update docs

* Update event_parser_test
2023-06-12 22:27:42 -05:00
Simon Heather
c5d03edd1a feat: Update Lock Index Page to Use a CSS Grid Layout (#3509)
* Update Lock Index Page to Use a CSS Grid Layout

* Update styles

* Modify css
2023-06-11 22:45:13 -05:00
Simon Heather
7fa9b9c925 fix: Remove the 'Plan Discarded' Message from the Enable/Disable Apply Commands (#3511)
* Remove `/?discard=true`

* Restore forward slash
2023-06-11 09:01:08 -05:00
Simon Heather
fa6a77a6ea Add xterm-addon-search-bar (#3507) 2023-06-11 01:22:09 -05:00
Simon Heather
504d1b7fe3 Replace bindata-assetfs with embed (#3504)
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2023-06-10 19:04:10 -05:00
Leandro López
c709fd0cff feat: Add Terraform command duration to log messages (#3484)
* Log duration of Terraform commands

Closes #3413.

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Make log message casing consistent

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Add tests for passing duration to Terraform comamnds logs

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Add logging mocks for testing Terraform client

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

---------

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
2023-06-09 21:03:36 -05:00
nitrocode
79500182db chore(deps): bump tally to v4 (#3498) 2023-06-08 21:57:46 -04:00
renovate[bot]
1d91dfb083 fix(deps): update module github.com/google/go-github/v52 to v53 in go.mod (#3495)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-07 03:41:38 +00:00
Finn Arne Gangstad
d1c6851899 fix: Check for upstream changes to merge only when planning (#3493)
* whitespace fixes

* Only re-clone on upstream updates just before planning

When using the merge checkout strategy, we would peviously
re-clone on upstream updates on any call to Clone(), for example
when running workflow hooks or runing import commands.

If we had already ran a plan, and master was updated, this
would delete the plan and apply would not have anything to
apply.

Modified to only re-clone on upstream updates in doPlan()

* Apply suggestions from code review

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2023-06-06 23:39:07 +00:00
Leandro López
339c0fe474 feat(stats): pass plan stats to markdown templates (#3478)
* Capture stats in plan changes regexp

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Add PlanSuccessStats model to hold plan stats

This will be useful to pass down to the templates to include
additional information when formatting the messages emitted by Atlantis.

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Return stats for a PlanSuccess

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Add plan success stats to template data

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Refactor plan success template data creation

DRY. Also highlights a bug where the stats should be a field in
planSuccessData in order to be accessible from the templates.

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Move plan stats to planSuccessData struct

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

---------

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2023-06-03 14:01:17 -05:00
Ross Strickland
ad75aace78 fix: Initialize VCSClient for commandrunner to remove recent server panics (#3461)
* Initialize VCSClient for commandrunner.

* Add test.
2023-05-30 14:32:37 -04:00
Simon Heather
50b1e48b4a fix(workflow-hook): multiline output formatting (#3425)
* Fix Workflow Hool Scripts Multiline Output

* Update unit tests

* revert bash cmd

* Fix tests
2023-05-30 09:21:56 -05:00
Simon Heather
998eb63821 fix(workflows): Workflow hook output id fix (#3454) 2023-05-26 08:50:52 -05:00
Alberto Rojas
4a7fc33857 fixbug: Update commandName in RunAndEmitStats (#3437) 2023-05-23 20:04:30 -05:00
Simon Heather
4915d8db5e fix(workflow-hook): log output with or without errors (#3422)
* fix: Errors in Pre or Post Workflow Hook Scripts do not Produce any Output

* Fix post workflow

* Update unit tests
2023-05-23 17:12:28 -05:00