Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto-plan projects when modules change #2507

Merged
merged 6 commits into from
Nov 28, 2022

Conversation

iamnoah
Copy link
Contributor

@iamnoah iamnoah commented Sep 8, 2022

Fixes #920

See testdata for an example repo structure. Any project that uses modules in the same repo should be able to take advantage.

Only files that are not considered part of a project will be considered. With the current auto-plan heuristic, only changed files in /modules/ without a main.tf would trigger a check of the modules dependencies.

Adds --autoplan-modules and --autoplan-modules-from-projects

@iamnoah iamnoah requested a review from a team as a code owner September 8, 2022 19:52
@jamengual jamengual added bug Something isn't working waiting-on-review Waiting for a review from a maintainer labels Sep 8, 2022
@jamengual
Copy link
Contributor

What are the repo structure and the module instantiation used?

a more detailed example could help to understand the feature

@iamnoah
Copy link
Contributor Author

iamnoah commented Sep 8, 2022

@jamengual updated the description to point to the test data. It's layout agnostic as it parses the module dependencies out of the projects.

@jamengual
Copy link
Contributor

jamengual commented Sep 8, 2022

so this only works when the source = is relative to the checked out repo not when the source = cloudposse/vpc/aws which is the terraform registry ?

@iamnoah
Copy link
Contributor Author

iamnoah commented Sep 8, 2022

@jamengual correct, it's only detecting changes to local modules.

@iamnoah iamnoah force-pushed the autoplan-modules branch 4 times, most recently from 326ffd4 to e093b18 Compare September 12, 2022 20:54
@iamnoah
Copy link
Contributor Author

iamnoah commented Sep 12, 2022

Sorry for the churn, in testing this out, I've squashed some bugs and cleaned things up.

I think the docs now lay out the use case. Since it's a departure from current behavior, it requires a flag to activate, but I think --autoplan-modules does what one would intuitively expect. If the module indexing does something undesired, e.g., take a long time or fail on unusual projects, it can be disabled selectively by changing its pattern.

@iamnoah
Copy link
Contributor Author

iamnoah commented Sep 19, 2022

Anything else I need to do to have this considered? A week of using it in our pipelines hasn't revealed any new issues.

@pauloconnor
Copy link
Contributor

This sounds similar to something I have in my atlantis.yaml generation script. I'm curious to know if you can disable autoplanning for individual child modules. For example, I have a child module that is called hundreds of times that I don't want to autoplan for obvious reasons, so I include a header in my main.tf file so my script knows to ignore it.

@iamnoah
Copy link
Contributor Author

iamnoah commented Sep 20, 2022

@pauloconnor yup! --autoplan-file-list=**/*.tf...,!modules/really-common-child-module/* would keep changes to that module from being planned.

@pauloconnor
Copy link
Contributor

@iamnoah Damn, that's fantastic! Hopefully this'll get merged in soon.

@iamnoah
Copy link
Contributor Author

iamnoah commented Oct 25, 2022

@jamengual rebased and tried to fix linter issues. LMK what can help move this forward.

server/events/modules.go Outdated Show resolved Hide resolved
@nitrocode nitrocode requested a review from jamengual October 25, 2022 17:53
@iamnoah iamnoah requested review from nitrocode and removed request for jamengual October 28, 2022 19:00
@nitrocode
Copy link
Member

@iamnoah please merge from the default branch to fix the branch test failure

@jamengual
Copy link
Contributor

@iamnoah can you fix the conflicts?

@nitrocode
Copy link
Member

@iamnoah please fix conflicts

@nitrocode
Copy link
Member

@iamnoah please fix linting error in failed branch pr check

@nitrocode
Copy link
Member

@iamnoah apologies but looks like this PR has some conflicts, could you resolve them?

@nitrocode nitrocode added waiting-on-response Waiting for a response from the user and removed waiting-on-review Waiting for a review from a maintainer labels Nov 19, 2022
# Conflicts:
#	go.mod
#	go.sum
#	server/events/project_finder.go
@iamnoah iamnoah requested a review from nitrocode November 21, 2022 14:54
@nitrocode nitrocode added waiting-on-review Waiting for a review from a maintainer and removed waiting-on-response Waiting for a response from the user labels Nov 21, 2022
@jamengual
Copy link
Contributor

@iamnoah Thanks for the contribution

@jamengual jamengual merged commit 61bcfba into runatlantis:main Nov 28, 2022
@lattwood
Copy link

lattwood commented Dec 1, 2022

@jamengual what are the chances of getting a release cut with this in it? Looks like the merge happened less than two hours after the release was tagged.

@jamengual
Copy link
Contributor

we do pre-release for new features before they go to the stable branch.

We will do a prerelease soon.

krrrr38 pushed a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
* feat: auto-plan projects when modules change

Fixes runatlantis#920

* rename Downstream->Dependent; docs cleanup

* chore: gofmt -s
@nitrocode nitrocode added this to the 0.22.0 milestone Dec 23, 2022
@iamnoah iamnoah deleted the autoplan-modules branch April 18, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting-on-review Waiting for a review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autoplanning - auto-detect modules dependencies
5 participants