Skip to content

Commit

Permalink
Fix: no longer fails if it runs in GitHub Actions and does not use th…
Browse files Browse the repository at this point in the history
…e annotation reporter
  • Loading branch information
massongit committed Apr 8, 2024
1 parent d694c56 commit 6bd4da8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ...

### :bug: Fixes
- ...
- Fix: no longer fails if it runs in GitHub Actions and does not use the annotation reporter

### :rotating_light: Breaking changes
- ...
Expand Down
7 changes: 2 additions & 5 deletions cmd/reviewdog/doghouse.go
Expand Up @@ -226,14 +226,11 @@ github-pr-check reporter as a fallback.
continue
}
foundNumOverall++
// If it's not running in GitHub Actions, reviewdog should exit with 1
// If it's not running in GitHub Actions and not using the annotation reporter, reviewdog should exit with 1
// if there are at least one result in diff regardless of error level.
shouldFail = shouldFail || !cienv.IsInGitHubAction() ||
shouldFail = shouldFail || (!cienv.IsInGitHubAction() && !useAnnotationReporter) ||
!(results.Level == "warning" || results.Level == "info")

// If using the annotation reporter, the action should fail
shouldFail = shouldFail || !useAnnotationReporter

if foundNumOverall == githubutils.MaxLoggingAnnotationsPerStep {
githubutils.WarnTooManyAnnotationOnce()
shouldFail = true
Expand Down
7 changes: 6 additions & 1 deletion cmd/reviewdog/doghouse_test.go
Expand Up @@ -484,9 +484,14 @@ func TestReportResults_inGitHubAction(t *testing.T) {
ShouldReport: true,
},
},
Level: "info",
})
stdout := new(bytes.Buffer)
_ = reportResults(stdout, filteredResultSet, false)
foundResultShouldReport := reportResults(stdout, filteredResultSet, false)
if foundResultShouldReport {
t.Errorf("foundResultShouldReport = %v, want false", foundResultShouldReport)
}

want := `reviewdog: Reporting results for "name1"
`
if got := stdout.String(); got != want {
Expand Down

0 comments on commit 6bd4da8

Please sign in to comment.