Commit Graph

29 Commits

Author SHA1 Message Date
Andrew Carter
dcae47bddb fix: parallel plan and apply also in a single workspace (rebased) (#5264)
Signed-off-by: Andrew Carter <andrew@emailcarter.com>
Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com>
Co-authored-by: Finn Arne Gangstad <finnag@gmail.com>
Co-authored-by: Rui Chen <rui@chenrui.dev>
Co-authored-by: PePe Amengual <2208324+jamengual@users.noreply.github.com>
Co-authored-by: Luke Massa <lukefrederickmassa@gmail.com>
2025-04-22 13:57:17 -04:00
Simon Heather
4bea4e934a chore: Add Struct required tags and Server Struct Validator (#5371)
Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
2025-03-09 11:34:48 +00:00
Simon Heather
be06063668 fix: Pre Workflow Hook VCS Combined Status Check Set to Pending Twice (#5242)
Signed-off-by: X-Guardian <32168619+X-Guardian@users.noreply.github.com>
2025-02-01 19:12:54 +00:00
Simon Heather
e468a23e0b feat: Refine the Atlantis Info Message Logging (#5034)
Signed-off-by: Simon Heather <32168619+X-Guardian@users.noreply.github.com>
2024-11-19 12:54:55 -05:00
Xing Yahao
267b2f133b feat: make api plan apply support workflow hooks (#4482)
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2024-05-01 09:06:35 -07:00
Simon Heather
b221fdc0af feat: Refine the logging in the Working Dir Package (#4294)
Co-authored-by: Dylan Page <dylan.page@autodesk.com>
2024-03-27 16:20:45 +00:00
Simon Heather
67b5740053 feat: Refine The Atlantis VCS Logging Configuration (#4285)
* Refine VCS Logging

* Remove github/gitlab client logger

* Remove fmtLogSrc from instrumented_client and format

* Add staticcheck lint exception for NewGitHubClient

* Fix tests
2024-02-26 13:07:41 -05:00
Thomas Lorreyte
9fa4cd3c34 fix: unnamed jobs in ui (#4137) 2024-02-02 05:21:17 -08:00
Simon Heather
1b45fb1ae1 fix: When GitHub/GitLab Auto-Merge Is Used with Atlantis Pre Workflow Hooks, the PR will be Merged Prematurely (#3880)
* Fix Premature Auto-Merge

* Add CommitStatusUpdater to commandRunner
2023-11-03 22:41:16 -04:00
Simon Heather
64f7d2e1a1 feat: Add Targeted Execution to the Pre/Post Workflow Hooks (#3708)
* Add Workflow hook target filter

* Fix post workflow hook example

* Update WokrflowHook in global_cfg

* Fix linting

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-10-06 09:37:07 -04: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
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
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
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
Simon Heather
998eb63821 fix(workflows): Workflow hook output id fix (#3454) 2023-05-26 08:50:52 -05:00
Ken Kaizu
27b9897517 chore(build): rm pegomock experimental feature for smooth mock generation (#2886)
* disable pegomock --use-experimental-model-gen, cause random fail by segv

* make regen-mocks

* fix mock code which uses non experimental pegomock codes
2022-12-27 19:58:15 -06:00
Fabiano Soares Honorato
cb485f11ee feat: Add pre and post workflow hook status (#2441)
* Add pre and post workflow hook status

* fix missing mocks

* fix pre/post workflow hooks tests

* add cmd output to file

* fix typo

* add cmd output to file on pre workflow hooks

* Add hooks output to web UI

* Remove unnecessary dependencies

* Clean the code and make tests work again

* Make lint happy

* Small fixes, create dedicated UUID generator and docs

* Add missing commentary

* Use matchers instead of mocking for tests and fix e2e tests

* Change 'OUTPUT_FILE' to 'OUTPUT_STATUS_FILE'

* Reduce SendWorkflowHook calls on hooks

* Apply suggestions from code review

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-12-19 14:20:34 -06:00
Adam Verigin
c3462f9073 Add COMMENT_ARGS to pre/post-workflow hook execution environment (#2621) 2022-11-07 14:50:49 -06:00
PePe Amengual
485c4b508f Revert "fix: add path to WorkingDir methods (#2180)" (#2253)
This reverts commit 1a8344489f.
2022-05-13 10:19:29 -07:00
KevinSnyderCodes
1a8344489f fix: add path to WorkingDir methods (#2180)
* 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>
2022-04-08 11:55:35 -07:00
KevinSnyderCodes
5288389897 fix: allow projects in separate directories to run in parallel (#2131)
* 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>
2022-03-21 16:08:52 -07:00
Sarvar Muminov
90e92e3a13 chore: move CommandContext and CommandResult to models (#193) (#2093)
* 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
2022-03-21 10:36:13 -07: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
Tim McFadden
b859f72561 feat: post workflow hooks (#1990)
* Add post-workflow hooks

* docs: Add cost estimation as post workflow use case

Co-authored-by: Gerald Barker <geraldbarker@gmail.com>
2022-01-12 19:57:45 -05:00
Masayuki Morita
2600708fba Validate base branches in DefaultCommandRunner (#1768)
Fixes #1539

The branch matcher feature has been introduced in #1383, but the current
implementation was broken and doesn't work at all (#1539).

If my understanding is correct, there are two problems:

(1) The `GlobalCfg` has a default `Repo` instance which always matches
any repositries and branches. Therefore the branch matcher never be
functional.
(2) Validating base branches in
`DefaultPreWorkflowHooksCommandRunner.RunPreHooks()` implicitly assumed
that users customize `pre_workflow_hooks`, but the assumption isn't
always true because it defaults to empty.

For (1), I added a new method `MatchingRepo()` to `GlobalCfg` to check
`BranchMatches()` for a single `Repo` instance.

For (2), I moved validating branch to
`DefaultCommandRunner.validateCtxAndComment()`. Since the method has
already validated meta data of pull request, I think it's suitable place
to check base branches, but please let me know if there is anywhere more
suitable.
2021-08-30 15:13:59 -07:00
Nish Krishnan
d914eafd2a Move core workflow packages under core. (#1684)
* Move core workflow packages under core.

* lint.
2021-07-01 12:54:44 -07:00
Dalton Hubble
00a5bc0fc0 Add a branch regex matcher to the server side repo config (#1383)
* Add a branch regex to the repo.yaml config to allow Atlantis to
accept only pull requests with a given base branch (the branch
a PR would merge _into_).
* `branch` is optional. By default its unset and Atlantis will match
webhooks for pull requests for any branch (no change)

Match any PR,

```
repos:
  - id: /.*/
    branch: /.*/
```

Match only PRs with master or main base branch.

```
repos:
  - id: /.*/
    branch: /(main|master)/
```

Some repos have special pull request branching practices. For example,
plan/apply from feature branches merging into master, but separate flows
for merging master into a release branch (where Atlantis isn't used).
Adding a regex allows for flexible workflow options. For example, you
could have Atlantis ignore "release" branches.
2021-02-24 12:52:30 -08:00
Nish Krishnan
8598c37671 Support pre-workflow hooks on all comment/auto triggered commands. (#43) (#1418)
Fixes pre-workflow-hooks not logging errors #1371
Prevents pre-workflow-hook from locking and cloning the dir if there are no hooks registered. #1342
2021-02-22 08:34:26 -08:00
Sarvar Muminov
3456dc934b Add pre workflow custom hooks to run scripts before workflow execution(plan, apply, etc) (#1255)
* Updated runatlantis.io/docs to have `pre-workflow-hooks` use cases and examples
2020-12-14 15:19:52 -05:00