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 Summaries to Plan And Apply PR Comments #3889

Merged
merged 12 commits into from
Jan 2, 2024

Conversation

X-Guardian
Copy link
Contributor

@X-Guardian X-Guardian commented Oct 22, 2023

what

  • Calculate additional data for the markdown renderer plan and apply results.
    • Plan:
      • Number of plans with changes
        Number of plans with no changes
        Number of plans with failures
    • Apply:
      • Number of apply successes
        Number of apply failures
        Number of apply errors
  • Add a summary line to the multi plan and apply templates displaying this data.
  • The plan and apply template footers were moved to separate files for easier readability.
  • The templates were standardised to only use the right delimiter trim following white space, rather than a mix of left and right delimiter trim. This allowed the tests to be more standardised.
  • Updated the markdown render tests as follows:
    • Added carriage return trimming so that the tests work on Windows with native line endings.
    • Standardised the test data string endings to always have a line feed.
    • Moved the TrimSpace and backtick processing into a normalise function along with the carriage return trimming.

Other changes

  • The multi policy markdown was using the multi plan template, so this was copied into a new multi 'policy` template so these changes didn't affect it.

why

tests

Tested locally

Plan Example

Ran Plan for 6 projects:

  1. dir: live/aws/123456789012/develop/eu-west-2/stack1 workspace: default
  2. dir: live/aws/123456789012/develop/eu-west-2/stack2 workspace: default
  3. dir: live/aws/123456789012/develop/eu-west-2/stack3 workspace: default
  4. dir: live/aws/123456789012/develop/eu-west-2/stack4 workspace: default
  5. dir: live/aws/123456789012/develop/eu-west-2/stack5 workspace: default
  6. dir: live/aws/123456789012/develop/eu-west-2/stack6 workspace: default

1. dir: live/aws/123456789012/develop/eu-west-2/stack1 workspace: default

Plan Failed: This project is currently locked by an unapplied plan from pull !15. To continue, delete the lock from !15 or apply that plan and merge the pull request.

Once the lock is released, comment atlantis plan here to re-plan.


2. dir: live/aws/123456789012/develop/eu-west-2/stack2 workspace: default

Show Output
local_file.foo: Refreshing state... [id=109f4b3c50d7b0df729d299bc6f8e9ef9066971f]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:

  # local_file.foo will be created
+ resource "local_file" "foo" {
      + content              = "test2"
      + content_base64sha256 = (known after apply)
      + content_base64sha512 = (known after apply)
      + content_md5          = (known after apply)
      + content_sha1         = (known after apply)
      + content_sha256       = (known after apply)
      + content_sha512       = (known after apply)
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "stack3.txt"
      + id                   = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
  • ▶️ To apply this plan, comment:
    • atlantis apply -d live/aws/123456789012/develop/eu-west-2/stack2
  • 🚮 To delete this plan click here
  • 🔁 To plan this project again, comment:
    • atlantis plan -d live/aws/123456789012/develop/eu-west-2/stack2
Plan: 1 to add, 0 to change, 0 to destroy.

3. dir: live/aws/123456789012/develop/eu-west-2/stack3 workspace: default

Show Output
local_file.foo: Refreshing state... [id=3ebfa301dc59196f18593c45e519287a23297589]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:

  # local_file.foo will be created
+ resource "local_file" "foo" {
      + content              = "test3"
      + content_base64sha256 = (known after apply)
      + content_base64sha512 = (known after apply)
      + content_md5          = (known after apply)
      + content_sha1         = (known after apply)
      + content_sha256       = (known after apply)
      + content_sha512       = (known after apply)
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "stack2.txt"
      + id                   = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
  • ▶️ To apply this plan, comment:
    • atlantis apply -d live/aws/123456789012/develop/eu-west-2/stack3
  • 🚮 To delete this plan click here
  • 🔁 To plan this project again, comment:
    • atlantis plan -d live/aws/123456789012/develop/eu-west-2/stack3
Plan: 1 to add, 0 to change, 0 to destroy.

4. dir: live/aws/123456789012/develop/eu-west-2/stack4 workspace: default

Show Output
local_file.foo: Refreshing state... [id=1ff2b3704aede04eecb51e50ca698efd50a1379b]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:

  # local_file.foo will be created
+ resource "local_file" "foo" {
      + content              = "test4"
      + content_base64sha256 = (known after apply)
      + content_base64sha512 = (known after apply)
      + content_md5          = (known after apply)
      + content_sha1         = (known after apply)
      + content_sha256       = (known after apply)
      + content_sha512       = (known after apply)
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "stack4.txt"
      + id                   = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
  • ▶️ To apply this plan, comment:
    • atlantis apply -d live/aws/123456789012/develop/eu-west-2/stack4
  • 🚮 To delete this plan click here
  • 🔁 To plan this project again, comment:
    • atlantis plan -d live/aws/123456789012/develop/eu-west-2/stack4
Plan: 1 to add, 0 to change, 0 to destroy.

Plan Summary

6 projects, 3 with changes, 2 with no changes, 1 failed

  • ⏩ To apply all unapplied plans from this pull request, comment:
    • atlantis apply
  • 🚮 To delete all plans and locks for the PR, comment:
    • atlantis unlock
Apply Example Ran Apply for 5 projects:
  1. dir: live/aws/123456789012/develop/eu-west-2/stack2 workspace: default
  2. dir: live/aws/123456789012/develop/eu-west-2/stack3 workspace: default
  3. dir: live/aws/123456789012/develop/eu-west-2/stack4 workspace: default
  4. dir: live/aws/123456789012/develop/eu-west-2/stack5 workspace: default
  5. dir: live/aws/123456789012/develop/eu-west-2/stack6 workspace: default

1. dir: live/aws/123456789012/develop/eu-west-2/stack2 workspace: default

local_file.foo: Creating...
local_file.foo: Creation complete after 0s [id=109f4b3c50d7b0df729d299bc6f8e9ef9066971f]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

2. dir: live/aws/123456789012/develop/eu-west-2/stack3 workspace: default

local_file.foo: Creating...
local_file.foo: Creation complete after 0s [id=3ebfa301dc59196f18593c45e519287a23297589]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

3. dir: live/aws/123456789012/develop/eu-west-2/stack4 workspace: default

local_file.foo: Creating...
local_file.foo: Creation complete after 0s [id=1ff2b3704aede04eecb51e50ca698efd50a1379b]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

4. dir: live/aws/123456789012/develop/eu-west-2/stack5 workspace: default

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

5. dir: live/aws/123456789012/develop/eu-west-2/stack6 workspace: default

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Apply Summary

5 projects, 5 successful, 0 failed, 0 errored

@X-Guardian X-Guardian requested a review from a team as a code owner October 22, 2023 15:27
@github-actions github-actions bot added the go Pull requests that update Go code label Oct 22, 2023
@jamengual jamengual added waiting-on-review Waiting for a review from a maintainer feature New functionality/enhancement labels Oct 24, 2023
@GenPage GenPage enabled auto-merge (squash) December 12, 2023 01:20
GenPage
GenPage previously approved these changes Dec 12, 2023
@GenPage GenPage added quick-win Is obviously something Atlantis should do and will take <4 hrs work and removed waiting-on-review Waiting for a review from a maintainer labels Dec 12, 2023
@GenPage GenPage modified the milestones: v0.27.0, v0.28.0 Dec 12, 2023
@GenPage
Copy link
Member

GenPage commented Dec 12, 2023

@X-Guardian Not sure why the tests are failing after rebasing/merging main.

auto-merge was automatically disabled December 12, 2023 12:49

Head branch was pushed to by a user without write access

@X-Guardian
Copy link
Contributor Author

@GenPage, I have fixed the failing tests. They were broken by conflicts with some of the changes in #3690. I'm surprised GitHub managed to auto-merge these changes. It should have flagged a conflict.

@X-Guardian
Copy link
Contributor Author

@GenPage, this PR is ready for re-review.

@X-Guardian X-Guardian requested a review from a team as a code owner December 30, 2023 11:44
@X-Guardian X-Guardian requested review from lukemassa and nitrocode and removed request for a team December 30, 2023 11:44
@X-Guardian X-Guardian merged commit 310fc8a into runatlantis:main Jan 2, 2024
25 checks passed
@X-Guardian X-Guardian deleted the plan-apply-summaries branch January 2, 2024 09:07
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement go Pull requests that update Go code quick-win Is obviously something Atlantis should do and will take <4 hrs work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Summaries to Plan And Apply PR Comments
4 participants