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

fix: Policy check summary not shown outside of "Show Output" details #2837

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

krrrr38
Copy link
Contributor

@krrrr38 krrrr38 commented Dec 20, 2022

what

  • Add {{.PolicyCheckSummary}} into tmpl
  • fix PolicyCheckSummary extract regex

why

  • original impl doesn't show output summary

references

@@ -415,7 +415,7 @@ type PolicyCheckSuccess struct {
func (p *PolicyCheckSuccess) Summary() string {
note := ""

r := regexp.MustCompile(`\d+ tests, \d+ passed, \d+ warnings, \d+ failures, \d+ exceptions`)
r := regexp.MustCompile(`\d+ tests?, \d+ passed, \d+ warnings?, \d+ failures?, \d+ exceptions?(, \d skipped)?`)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

output contains plurals. like followings

>  pwd
/Users/krrrr38/dev/src/github.com/open-policy-agent/conftest

> ag exception output | grep failure
output/github_test.go:26:				"0 tests, 0 passed, 0 warnings, 0 failures, 0 exceptions",
output/github_test.go:45:				"2 tests, 0 passed, 1 warning, 1 failure, 0 exceptions",
output/github_test.go:64:				"2 tests, 0 passed, 0 warnings, 1 failure, 0 exceptions",
output/github_test.go:81:				"1 test, 0 passed, 0 warnings, 1 failure, 0 exceptions",
output/standard_test.go:31:				"2 tests, 0 passed, 1 warning, 1 failure, 0 exceptions",
output/standard_test.go:49:				"2 tests, 0 passed, 1 warning, 1 failure, 0 exceptions",
output/standard_test.go:69:				"3 tests, 0 passed, 1 warning, 1 failure, 0 exceptions, 1 skipped",
output/standard_test.go:88:				"2 tests, 0 passed, 1 warning, 1 failure, 0 exceptions, 0 skipped",
output/standard.go:127:	outputText := fmt.Sprintf("%v test%s, %v passed, %v warning%s, %v failure%s, %v exception%s",
output/github.go:87:	outputText := fmt.Sprintf("%v test%s, %v passed, %v warning%s, %v failure%s, %v exception%s",

https://github.com/open-policy-agent/conftest/blob/03626f5bd32becd69b0cf4cd87d441883702a5d2/output/standard.go#L127

@@ -10,5 +10,6 @@
* :put_litter_in_its_place: To **delete** this plan click [here]({{.LockURL}})
* :repeat: To re-run policies **plan** this project again by commenting:
* `{{.RePlanCmd}}`
</details>{{ template "diverged" . }}
</details>
{{.PolicyCheckSummary}}{{ template "diverged" . }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renderer parameter contains PolicyCheckSummary by #2452. But template variable is not used, so not shown.

@krrrr38 krrrr38 marked this pull request as ready for review December 20, 2022 06:37
@krrrr38 krrrr38 requested a review from a team as a code owner December 20, 2022 06:37
@@ -282,6 +293,8 @@ $$$
* :put_litter_in_its_place: To **delete** this plan click [here](lock-url)
* :repeat: To re-run policies **plan** this project again by commenting:
* $atlantis plan -d path -w workspace$
</details>
2 tests, 1 passed, 0 warnings, 0 failure, 0 exceptions
Copy link
Contributor Author

Choose a reason for hiding this comment

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

got this

Copy link
Member

@nitrocode nitrocode left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you for your quick contribution!

@nitrocode nitrocode merged commit 2d29db6 into runatlantis:main Dec 20, 2022
@nitrocode nitrocode added this to the 0.22.0 milestone Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v0.21+: Policy check summary not shown outside of "Show Output" details
2 participants