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: Add pre and post workflow hook status #2441

Merged
merged 21 commits into from
Dec 19, 2022

Conversation

Fabianoshz
Copy link
Contributor

@Fabianoshz Fabianoshz commented Aug 12, 2022

Currently when a pre or post workflow hook is running there's no indication to the user. When running a lengthy task like using terragrunt-atlantis-config on a big repository a PR may stay a long time without any return.

This tries to help users (especially those with low experience) to identity the current status of the operation.

@Fabianoshz
Copy link
Contributor Author

Still need to work on tests for this 😅

@jamengual jamengual added waiting-on-review Waiting for a review from a maintainer work-in-progress labels Aug 18, 2022
@nitrocode nitrocode added the needs tests Change requires tests label Nov 24, 2022
@nitrocode
Copy link
Member

Nice job @Fabianoshz ! I'd love tests and I'd love to see the stdout output via the details link like we can for the terraform plan/applies.

@Fabianoshz
Copy link
Contributor Author

Hi @nitrocode, I'll start writing tests for this, about the stdout output maybe on a separated PR? I'm still familiarizing myself with Atlantis code base.

@nitrocode
Copy link
Member

nitrocode commented Dec 2, 2022

A separate pr would be okay i suppose but in the mean time it would break consistency with what we currently have for the atlantis plan and apply workflows which do expose a details link. If you go the separate pr route, please do not forget to add and test that functionality or we may have to revert the pr.

Thoughts? @runatlantis/maintainers

@jamengual
Copy link
Contributor

maybe keep it in the same PR since they will be related?

@nitrocode
Copy link
Member

It would be nice too if the status of the pre and post workflows is modifiable like @albertorm95 is attempting in pr #2699. that pr will parae the output because the output is standard but in the case of pre and post workflows, there can be any script run, so it would be nice if we could set it to be a custom regex in the yaml to parse the output to bubble it up as the status. But of course this is just a bonus.

@Fabianoshz
Copy link
Contributor Author

Fabianoshz commented Dec 12, 2022

I'll look how to add stdout to the status link in this PR, I've messed around with the code base enough to fell confident about trying this. @nitrocode I will try to add a way of setting the status too, I'm unsure about the regex though, what do you think about passing an environment variable to the command, expecting the user to push the output it wants to the variable and then we expose it later? Regex might break in ways user might not expect, also it would be harder for them to test things.

@Fabianoshz
Copy link
Contributor Author

@nitrocode Didn't managed to use a environment variable, instead I've passed an env with a filepath to the command so it can send the status to it. I just need to check the string size limit for this before sending it to the VCS client.

@Fabianoshz
Copy link
Contributor Author

Ok, managed to make the output work, it will add the link to the check:
image

And will output the stdout to the UI:
image

Had to change a lot of things to make this work, and I have heavily coupled the hooks code to the functions that the jobs use to show the output too, I believe more changes will be required to make this more readable in the future, I think I'm gonna need more time to finish this.

Also the tests are broken (had to fix a bazillion times because I've kept changing things).

@Fabianoshz
Copy link
Contributor Author

Custom descriptions seems to work fine too:
image

go.mod Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR, just some nitpicks.

server/core/runtime/pre_workflow_hook_runner.go Outdated Show resolved Hide resolved
Copy link
Contributor

@krrrr38 krrrr38 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work.

runatlantis.io/docs/post-workflow-hooks.md Outdated Show resolved Hide resolved
Copy link
Contributor

@jamengual jamengual left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fabianoshz when you have some time, resolve the discussions/feedback
otherwise it looks good to me

@nitrocode nitrocode added waiting-on-response Waiting for a response from the user and removed needs tests Change requires tests waiting-on-review Waiting for a review from a maintainer labels Dec 17, 2022
@nitrocode
Copy link
Member

@runatlantis/maintainers ready for a second review 🙏

@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 work-in-progress labels Dec 19, 2022
@nitrocode nitrocode changed the title Add pre and post workflow hook status feat: Add pre and post workflow hook status Dec 19, 2022
Copy link
Contributor

@krrrr38 krrrr38 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nitrocode nitrocode merged commit cb485f1 into runatlantis:main Dec 19, 2022
@nitrocode
Copy link
Member

@Fabianoshz nice job! This will be very helpful in the next release.

Thanks for the additional set of eyes @krrrr38 and @GenPage !

@ribejara-te
Copy link
Contributor

Hey, this is a great feature. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-review Waiting for a review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants