borchero / terraform-plan-comment

GitHub Action to post the output of "terraform plan" to a pull request comment.
MIT License
75 stars 12 forks source link

idea: support for condensed display of multiple plans? #12

Open simonblake-mp opened 5 months ago

simonblake-mp commented 5 months ago

This is total pie in the sky, I'm just spitballing.

I suspect many folks use a matrix to run multiple terraform plans concurrently (to different environments or cloud accounts or whatever) then feed each plan through a comment action to get a comment per matrix element in the PR. So if you've got, say, 8 environments, then you get 8 plan comments, which can add excessive scrolling to the PR.

What would be super sweet would be for a way to combine all those plans into a single uber-comment that showed a one line summary of all the changes across all the plans, making it easy for a reviewer to see if a single plan is out of whack versus all the rest, then allowing drill down to a specific plan.

Gitlab does something like this, although not in a comment (they have native TF support in a widget) - I'm struggling to find an actual picture of it in use (I no longer use gitlab), but their design ideas are visible here - https://gitlab.com/gitlab-org/gitlab/-/issues/222964

Obviously there are constraints, particularly around total comment size, and how to handle updating reruns and whatnot, so it wouldn't be trivial.

borchero commented 5 months ago

Interesting thought! I am not entirely sure how to implement the "drill-down" in a single plan since you need to persist the plan somewhere. One option would be to add a bunch of collapsed comments to the PR which contain the full plan and add a link to these collapsed comments (example). I'll have to think a bit more about other options :eyes:

borchero commented 5 months ago

Example

simonblake-mp commented 5 months ago

At the moment it's the calling action's responsibility to ensure the plan is available in the local filesystem before calling terraform-plan-comment? So I was naively assuming that would contInue - instead of this

token: ${{ github.token }}
planfile: planfile
working-directory: some_dir
id: some_id

then the caller would have to ensure all the plans were available in the local file system, then call uber-terraform-plan-comment with something like:

token: ${{ github.token }}
jobs:
   - id: job1_id
      planfile: job1_planfile
      working-directory: job1_dir
   - id: job2_id
      planfile: job2_planfile
      working-directory: job2_dir

then uber-terraform-plan-comment would have all the plan files available, and then could iterate over the jobs to make the uber comment?

rdhar commented 4 months ago

@simonblake-mp Looking at the GitLab issue linked, I really like their proposal diagram, particularly this one:

View GitLab's proposal diagram for Terraform report widget. ![image](https://github.com/borchero/terraform-plan-comment/assets/19497993/cd0882c3-6220-4a9a-9bac-179a951f0cf0)

Like yourself, I too run Terraform in matrix strategy for multiple different directories in various configurations, and I relate to noisy PRs with a whole bunch of comments. With that said, what do you think about this view?

image

The list in this screenshout is a product of TF-via-PR GitHub Action and integrated with GitHub's native status checks, enabling you to easily scan through multiple plan summaries in one place.

It also includes support for commenting TF plan in PR comments and job summaries, as shown here.

View TF-via-PR's output for plans with matrix strategy. ![image](https://github.com/borchero/terraform-plan-comment/assets/19497993/7252b51e-2743-4c32-ad79-f31c2c61fb2b)

You can probably tell I'm the Action's author, which is why I'm on the look-out for use-cases/feature-requests that users are seeking and connecting them to the relevant Action.

simonblake-mp commented 3 months ago

@RDhar sorry for the delay! That's super pretty - putting the plan/apply output directly into status check line - in a lot of circumstances that would remove the need to post plan comments to the PR at all.

rdhar commented 3 months ago

@simonblake-mp Agreed! So if the PR comment is disabled to reduce clutter in the conversation thread, a copy of the plan is attached to the workflow summary for ease of reference/audit (also accessible by clicking Details on the status check line).

borchero commented 2 months ago

putting the plan/apply output directly into status check line - in a lot of circumstances that would remove the need to post plan comments to the PR at all.

Up until few weeks ago, I didn't know how easy this would be :smile: so, definitely possible to write a condensed summary to the status check and put the details somewhere else. I'd be grateful for a PR (following some more concrete proposal) unless it is fine that this feature will still take some time :smile: