From 7b93978442e3130df8c6cc40a2184f030f45a837 Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Tue, 22 Nov 2022 22:21:45 +0300 Subject: [PATCH] Print coverage statistics Signed-off-by: Alper Rifat Ulucinar --- .github/workflows/ci.yml | 3 +++ cmd/generator/main.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 445a7be0e1..5906bd38a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,6 +131,9 @@ jobs: if: failure() && steps.check-diff.outcome == 'failure' run: git diff + - name: Report Statistics + run: head -1 _output/skipped_resources.csv + - name: Publish skipped resources CSV to Github uses: actions/upload-artifact@v3 with: diff --git a/cmd/generator/main.go b/cmd/generator/main.go index 147681739c..a1dcd365d9 100644 --- a/cmd/generator/main.go +++ b/cmd/generator/main.go @@ -41,7 +41,10 @@ func main() { p := config.GetProvider() pipeline.Run(p, absRootDir) if len(*skippedResourcesCSV) != 0 { - if err := os.WriteFile(*skippedResourcesCSV, []byte(strings.Join(p.GetSkippedResourceNames(), "\n")), 0o600); err != nil { + skippedCount := len(p.GetSkippedResourceNames()) + totalCount := skippedCount + len(p.Resources) + summaryLine := fmt.Sprintf("Skipped, total, coverage: %d, %d, %.1f%%", skippedCount, totalCount, (1.0-float64(skippedCount)/float64(totalCount))*100) + if err := os.WriteFile(*skippedResourcesCSV, []byte(strings.Join(append([]string{summaryLine}, p.GetSkippedResourceNames()...), "\n")), 0o600); err != nil { panic(fmt.Sprintf("cannot write skipped resources CSV to file %s: %s", *skippedResourcesCSV, err.Error())) } }