Skip to content

Commit

Permalink
Add warning and exit with 1 for too many annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Jan 5, 2020
1 parent 4110505 commit 65bbb79
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cmd/reviewdog/doghouse.go
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"sort"
"strings"
"sync"

"golang.org/x/oauth2"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -175,6 +176,7 @@ func reportResults(w io.Writer, filteredResultSet *reviewdog.FilteredResultMap)
sort.Strings(names)

shouldFail := false
foundNumOverall := 0
for _, name := range names {
results, err := filteredResultSet.Load(name)
if err != nil {
Expand All @@ -190,10 +192,17 @@ func reportResults(w io.Writer, filteredResultSet *reviewdog.FilteredResultMap)
filteredNum++
continue
}
foundNumOverall++
// If it's not running in GitHub Actions, reviewdog should exit with 1
// if there are at least one result in diff regardless of error level.
shouldFail = shouldFail || !cienv.IsInGitHubAction() ||
!(results.Level == "warning" || results.Level == "info")

if foundNumOverall > 9 {
warnTooManyAnnotationOnce.Do(warnTooManyAnnotation)
shouldFail = true
}

foundResultPerName = true
if cienv.IsInGitHubAction() {
reportResultsInGitHubActions(name, results.Level, result)
Expand Down Expand Up @@ -232,3 +241,17 @@ func reportResultsInGitHubActions(toolName, level string, result *reviewdog.Filt
core.Error(mes, opt)
}
}

var warnTooManyAnnotationOnce sync.Once

func warnTooManyAnnotation() {
core.Error(`reviewdog: Too many results (annotations) in diff.
You may miss some annotations due to GitHub limitation for annotation created by logging command.
Limitation:
- 10 warning annotations and 10 error annotations per step
- 50 annotations per job (sum of annotations from all the steps)
- 50 annotations per run (separate from the job annotations, these annotations aren't created by users)
Source: https://github.community/t5/GitHub-Actions/Maximum-number-of-annotations-that-can-be-created-using-GitHub/m-p/39085`, nil)
}

0 comments on commit 65bbb79

Please sign in to comment.