It seems that GitHub has changed its Markdown renderer such that an
emoji followed by a string of plain text (with no other formatting)
followed by a colon at the end of the line renders as plain text instead
of as the emoji. Compare the following two lines:
* 🚮 To delete all plans and locks for the PR, comment:
* 🚮 To **delete** all plans and locks for the PR, comment:
While this seems like it is probably a GitHub bug, we can work around it
by adding some formatting between the emoji and the end of the line,
which matches the bullet point above it anyway.
* Enforce policy checks for overriden apply reqs
* Another take on the fix
This new version only includes the 'policies_passed' req back if
policy checks are enabled for the project.
* Fix test
* Fix comment
* Fix spelling
---------
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
* feat: better logging for UpdateStatus
* feat: jobs now shown in a table in the main page
---------
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
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.
* add flag to allow the user disable the autodiscover
* add global config and doc
* feat: Implement autodiscover.mode
* fix: Minor doc fixes
* fix: Small fixes to docs/indent/tests
* fix: Line length, quoting, function comments
* fix: Add a few more tests and remove newlines
* fix: Always camel case never snake
---------
Co-authored-by: Marcelo Medeiros <m.medeiros@carepay.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
We should use `(*regexp.Regexp).MatchString` instead of
`(*regexp.Regexp).Match([]byte(...))` when matching string to avoid
unnecessary `[]byte` conversions and reduce allocations.
Example benchmark:
func BenchmarkMatch(b *testing.B) {
for i := 0; i < b.N; i++ {
if match := branchRegex.Match([]byte("main")); !match {
b.Fail()
}
}
}
func BenchmarkMatchString(b *testing.B) {
for i := 0; i < b.N; i++ {
if match := branchRegex.MatchString("main"); !match {
b.Fail()
}
}
}
goos: linux
goarch: amd64
pkg: github.com/runatlantis/atlantis/server/core/config
cpu: AMD Ryzen 7 PRO 4750U with Radeon Graphics
BenchmarkMatch-16 8269699 141.4 ns/op 4 B/op 1 allocs/op
BenchmarkMatchString-16 14298446 95.81 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/runatlantis/atlantis/server/core/config 2.784s
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
* add misspell check
* lint: fix misspell issues
```
server/events/vcs/instrumented_client.go:46:26: `soley` is a misspelling of `solely` (misspell)
// methods and implement soley any github specific interfaces.
^
server/events/project_command_context_builder.go:49:5: `Conciously` is a misspelling of `Consciously` (misspell)
// Conciously making this global since it gets flushed periodically anyways
^
server/controllers/events/gitlab_request_parser_validator.go:87:32: `noteable` is a misspelling of `notable` (misspell)
NoteableType string `json:"noteable_type"`
^
server/controllers/events/gitlab_request_parser_validator_test.go:351:6: `noteable` is a misspelling of `notable` (misspell)
"noteable_type": "MergeRequest",
^
server/controllers/events/gitlab_request_parser_validator_test.go:359:6: `noteable` is a misspelling of `notable` (misspell)
"noteable_id": 7,
^
server/controllers/events/gitlab_request_parser_validator_test.go:467:6: `noteable` is a misspelling of `notable` (misspell)
"noteable_type": "Commit",
^
server/controllers/events/gitlab_request_parser_validator_test.go:475:6: `noteable` is a misspelling of `notable` (misspell)
"noteable_id": null,
^
server/events/event_parser_test.go:1012:23: `seperate` is a misspelling of `separate` (misspell)
// If sha changes in seperate PR,
^
```
Signed-off-by: Rui Chen <rui@chenrui.dev>
* add locale setting
Signed-off-by: Rui Chen <rui@chenrui.dev>
* Revert "lint: fix misspell issues"
This reverts commit 7cc56afa8e.
* lint: fix some misspell issues
Signed-off-by: Rui Chen <rui@chenrui.dev>
---------
Signed-off-by: Rui Chen <rui@chenrui.dev>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
When the underlying GitHub Client returns an error it gets swallowed
in this wrapper method. Not only that but also the emitted metrics are
wrong, as it counts one error AND success at the same time.
We've found this @grafana when using Atlantis in a massive repository
with many changes per minute, and sometimes Atlantis leave a comment
saying it's automatically merging but then nothing happens. But
checking the logs, we've found the following error message:
Unable to merge pull, error: merging pull request: PUT
https://api.github.com/repos/grafana/redacted/pulls/666/merge: 405
Base branch was modified. Review and try the merge again. []
And because the error is swallowed and `InstrumentedClient.MergePull`
returns `nil`, then `Automerger` fails to leave a comment saying
merging failed.
* Make code more Go-idiomatic
While at it makes it more readable.
Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
* Add internal function to parse multienv step input
This new function properly deals with quotes and commas in values.
Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
* Add regression test for multienv output with comma in values
See #2765 for an issue report.
Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
* Use parseMultienvLine for parsing multienv steps output
Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
* Add internal function to parse multienv step input
This new function properly deals with quotes and commas in values.
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>
* Rename arguments in mocked functions from result to res
The code generated by pegomock is broken if any of the arguments to the
mocked function are named "result", so they must be named something else.
* Regenerate all mocks with make go-generate
The mocks now work without further modification after running go-generate.
* Adding new flag everywhere relevant, implementing policy result workaround
* Fixing unit test str matching, adding custom policy conditional to step_runner
* Adding documentation steps for custom policy tools
* Refactoring ConftestOutput attribute to PolicyOutput
* Safer handling of merging with an updated upstream.
We used to call forceClone() to update with upstream, but this deletes the
checked out directory. This is inefficient, can delete existing plan files,
and is very surprising if you are working manually in the working directory.
We now fetch an updated upstream, and re-do the merge operation. This
leaves any working files intact.
* Rename SafeToReClone -> CheckForUpstreamChanges
It's never safe to clone again. But sometimes we need to check
for upstream changes to avoid reverting changes.
The flag is now used to know when we need to merge
again non-destructively with new changes.
* Update fixtures.go
* Add test to make sure plans are not wiped out
As long as the branch itself has not been updated, plans
should be kept. Even if upstream has changed.
* renamed HasDiverged to MergedAgain in PlanResult and from Clone()
This flag was only set to true in case a call to Clone()
ended up merging with an updated upstream, so the
new name better represents what it means.
* Test that Clone on branch update wipes old plans
This complements the test that Clone with unmodified
branch but modified upstream does _not_ wipe plans.
* runGit now runs git instead of returning a function that runs git
* Updated template to merged again instead of diverged
This is no longer a warning, but expected behavior in merge chekout mode
* Rename git wrapper to wrappedGit, add a type for static config
Every call to wrappedGit for the same PR uses identical setup
for directory, head repo and PR, so passing the
---------
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
* 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>
* feat: Add use plugin cache bool flag
* feat: Added use-plugin-cache doc
* feat: refactor to reflect terrafrom in plugin cache flag
Co-authored-by: Simon Heather <32168619+X-Guardian@users.noreply.github.com>
* fix: missing closing in bash block documentation
* fix: typo in flag example
* feat: improve docs
* feat: performance implications documented
* feat: increase terraform minor version to 1.3.10
---------
Co-authored-by: Simon Heather <32168619+X-Guardian@users.noreply.github.com>
* Running 'atlantis unlock' on a PR Causes The Whole Working Directory to be Deleted
* Update events controller tests
* Fix events controller tests
---------
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
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