From 6bd4da80765f81c649548e802d3007a99dd49dde Mon Sep 17 00:00:00 2001 From: Masaya Suzuki Date: Tue, 9 Apr 2024 08:30:54 +0900 Subject: [PATCH] Fix: no longer fails if it runs in GitHub Actions and does not use the annotation reporter --- CHANGELOG.md | 2 +- cmd/reviewdog/doghouse.go | 7 ++----- cmd/reviewdog/doghouse_test.go | 7 ++++++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8642cd639..0adc0a1758 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - ... diff --git a/cmd/reviewdog/doghouse.go b/cmd/reviewdog/doghouse.go index 3cf7560452..13e1e83760 100644 --- a/cmd/reviewdog/doghouse.go +++ b/cmd/reviewdog/doghouse.go @@ -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 diff --git a/cmd/reviewdog/doghouse_test.go b/cmd/reviewdog/doghouse_test.go index 49c2dc1859..e7ee60af7f 100644 --- a/cmd/reviewdog/doghouse_test.go +++ b/cmd/reviewdog/doghouse_test.go @@ -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 {