* Start threading job output to RunStepRunner
* Strip ANSI
* Fix lint
* Use waitgroup to avoid test flakiness
* Move waitgroup higher
* Add ANSI test and use strings.Builder
* Fix lint
* Use errors.Wrap per style guide
* Create ShellCommandRunner to encapsulate streaming
* WIP: shell command runner
* Update signatures to propagate error finding version
* Fix log output
* Fix error checking
* Fix accidental whitespace stripping
* Remove unused struct field
* Fix error checking in terraform client
* Add unit tests to verify command output handler was called
* Remove err from async interface
* Remove duplicative log now that shell command runner does it
* Hide output in stream for env/multienv
* Add comment explaining goroutines
* Use printf for better macOS compatibility
error message:
```
- Finding hashicorp/null versions matching "3.0.0"...
╷
│ Error: Incompatible provider version
│
│ Provider registry.terraform.io/hashicorp/null v3.0.0 does not have a package
│ available for your current platform, darwin_arm64.
│
│ Provider releases are separate from Terraform CLI releases, so not all providers
│ are available for all platforms. Other versions of this provider may have
│ different platforms supported.
```
Signed-off-by: Rui Chen <rui@chenrui.dev>
* Delete previous plans on autoplan or atlantis plan
When using non-default workspaces, plans are stored
in pr-and-workspace-specific directories.
If a PR is subsequently updated it might happen that
some of the plans are no longer relevant with regards
to the latest changes.
This change ensures that plans are always deleted
when a generic plan is triggered either by autoplan
or by a "atlantis plan" command.
NB Plans are not cleaned up when specific projects are
planned explicitly with "atlantis plan -p/-d/-w".
* Use DeleteLockCommand to delete locks and workdirs
containing previous plans
Co-authored-by: giuli007 <giuglioz@gmail.com>
Currently the link goes to "" on my install, which browsers interpret as
the current page. Looking at the other templates in this file, it was
missing a trailing `/`.
This fixes the tests to not rely in the implicit value of the
"defaultBranch" git configuration value, since they later assume that
it's "master".
For example, if you run:
```sh
git config --global init.defaultBranch main
```
And then run these tests, you get:
```sh
--- FAIL: TestClone_CheckoutMergeNoneExisting (0.68s)
working_dir_test.go:71: err running "git checkout master": error:
pathspec 'master' did not match any file(s) known to git
--- FAIL: TestClone_CheckoutMergeNoReclone (0.68s)
working_dir_test.go:127: err running "git checkout master":
error: pathspec 'master' did not match any file(s) known to git
--- FAIL: TestClone_CheckoutMergeNoRecloneFastForward (0.68s)
logger.go:130: 2022-05-17T10:05:33.665-0700 INFO creating
dir "/tmp/3762936464/repos/0/default"
working_dir_test.go:198: unexpected error: running git
clone --branch master --single-branch
file:///tmp/3657236513 /tmp/3762936464/repos/0/default:
Cloning into '/tmp/3762936464/repos/0/default'...
warning: Could not find remote branch master to
clone.
fatal: Remote branch master not found in
upstream origin
: exit status 128
--- FAIL:
TestClone_CheckoutMergeConflict
(0.68s)
working_dir_test.go:232: err running "git checkout master": error:
pathspec 'master' did not match any file(s) known to git
--- FAIL: TestClone_MasterHasDiverged (0.68s)
working_dir_test.go:344: err running "git clone --branch
master --single-branch /tmp/1931262087 .": Cloning into '.'...
warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in
upstream origin
--- FAIL: TestHasDiverged_MasterHasDiverged
(0.68s)
working_dir_test.go:415: err running "git clone --branch master
--single-branch /tmp/2356723317 .": Cloning into '.'...
warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in upstream
origin
FAIL
FAIL
github.com/runatlantis/atlantis/server/events
7.269s
FAIL
```
Currently this is failing on PRs
```
server/events/vcs/gitlab_client_test.go:301:14: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte(response))
```
* fix: update commit status check logic to match the commit status name
* Update server/events/vcs/gitlab_client.go
chore: simplify ignored statuses logic
Co-authored-by: Emil 'Skeen' Madsen <sovende@gmail.com>
* feat(gitlab_client_test): add PullIsMergeable test case
Co-authored-by: Emil 'Skeen' Madsen <sovende@gmail.com>
* fix: add path to WorkingDir methods
`WorkingDirLocker` and `WorkingDir` are closely related -- the former acquires a lock, which ensures that the latter can safely operate on a given file path.
In #2131 we added `path` to the `WorkingDirLocker` lock key, but neglected to add the same to `WorkingDir`.
This commit adds `path` as an argument to certain `WorkingDir` methods, and includes `path` in the directory that we use to clone the repository for a given project.
Since `path` can include certain special characters such as `/`, we encode `path` as base32 when using it as part of a file path. This should ensure no special characters are used in the filesystem, and that the value can be decoded if desired (unlike hashes such as md5).
Additional changes:
- All calls to changed methods have been updated, including unit tests
- Mocks have been regenerated for `WorkingDir` and `WorkingDirLocker`
- `working_dir_test.go`
- Commands that operate on filesystem paths have been updated to include the base32 encoded `path` value
- When running `git init`, we include `-b master` as additional arguments, to ensure that `master` is our default branch (expected by the unit tests)
* Try fixing E2E tests
* Fix DefaultPendingPlanFinder
In addition to iterating over `workspaceDirs`, also iterate over `pathDirs`, and use both `workspace` and `path` to build `repoDir`.
* Fix DefaultPendingPlanFinder unit tests
* Fix DefaultProjectCommandBuilder unit tests
Co-authored-by: Kevin Snyder <kevinsnyder@KevinSnydersMBP.lan>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-192-168-1-188.ec2.internal>
* fix: add path to DefaultWorkingDirLocker.TryLock()
In the release notes for v0.13.0: https://github.com/runatlantis/atlantis/blob/master/CHANGELOG.md#features-4
> Running in parallel is only supported if you're using workspaces to separate your projects. Projects in separate directories can not be run in parallel currently.
This commit adds `path` as an argument to `DefaultWorkingDirLocker.TryLock()` and includes `path` in the `workspaceKey` used to check if a project is locked. This should allow projects in separate directories to run in parallel.
To my knowledge, there is no functional reason that projects in separate directories cannot run in parallel.
All calls to `DefaultWorkingDirLocker.TryLock()` have been updated. A new unit test `TestTryLockWithDifferentPaths` has been added to test the behavior of locking two separate directories with the same workspace name.
* Add documntation for parallel_plan and parallel_apply options
* Fix working_dir_locker_test.go
- Fix expected error message for `TestTryLock()`
- Use `.` as default path for calls to `DefaultWorkingDirLocker.TryLock()`
Co-authored-by: Kevin Snyder <kevinsnyder@ip-192-168-4-61.ec2.internal>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-10-60-10-94.ec2.internal>
Co-authored-by: Kevin Snyder <kevinsnyder@Kevin-Snyders-MacBook-Pro.local>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-10-60-10-189.ec2.internal>
Co-authored-by: Rui Chen <rui@chenrui.dev>
* fix: add path to DefaultWorkingDirLocker.TryLock()
In the release notes for v0.13.0: https://github.com/runatlantis/atlantis/blob/master/CHANGELOG.md#features-4
> Running in parallel is only supported if you're using workspaces to separate your projects. Projects in separate directories can not be run in parallel currently.
This commit adds `path` as an argument to `DefaultWorkingDirLocker.TryLock()` and includes `path` in the `workspaceKey` used to check if a project is locked. This should allow projects in separate directories to run in parallel.
To my knowledge, there is no functional reason that projects in separate directories cannot run in parallel.
All calls to `DefaultWorkingDirLocker.TryLock()` have been updated. A new unit test `TestTryLockWithDifferentPaths` has been added to test the behavior of locking two separate directories with the same workspace name.
* Add documntation for parallel_plan and parallel_apply options
Co-authored-by: Kevin Snyder <kevinsnyder@ip-192-168-4-61.ec2.internal>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-10-60-10-94.ec2.internal>
* Moved CommandContext and CommandResult to models (#193)
* Moved CommandContext and CommandResult to models
* move from models to command
rename CommandContext -> Context
rename CommandResult -> Result
* moved command related helpers into command package
* move ProjectCommandContext and ProjectResult to command/project package
* move project command context and project result
* revert unrelated code
* move tests
* fix left over
* fix linting
* fix tests
* remove unused import
* fix project context dependencies
* fix depenedecies
* fix typo
* 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
* fix(web-templates): use CleanedBasePath for static content
When setting '--atlantis-url' this static content 404s.
For example, we can see this when comparig:
- /lock --> works seamless with a custom `--atlantis-url`
- /jobs --> doesn't work when using a custom `--atlantis-url`
* fix(web-templates): regenerate bindata_assetfs
* Add UUID for Log Streaming Job ID (#167)
* Update log handler to close buffered channels when an operation is complete (#170)
* Add preliminary check before registering new receivers in the log handler (#173)
* Using projectOutputBuffers to check for jobID instead of receiverBuffers (#181)
* Refactor log handler (#175)
* Reverting go.mod and go.sum
* Fix lint errors
* Fix linting
* Replacing . with _ when generating project identifier if project name is not set
* Adding test for GenerateProjectJobURL when working dir set to .
* Replacing . with _ when generating project identifier if project name is not set
* Fixing merge conflicts
* Add benchmark for /healthz endpoint
This benchmark will measure not only speed but also how much memory
each request to /healthz allocate. I'm adding the benchmark to have a
baseline to compare.
Signed-off-by: Leandro López (inkel) <inkel.ar@gmail.com>
* Hardcode /healthz body into a variable
We know it will always be this value, there's no need to import and
call json.MarshalIndent.
Signed-off-by: Leandro López (inkel) <inkel.ar@gmail.com>
* Initialize /healthz body only once
Signed-off-by: Leandro López (inkel) <inkel.ar@gmail.com>