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

Support reviewdog command line argument changes (--fail-level) #72

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nayuta
Copy link
Contributor

@nayuta nayuta commented Dec 22, 2024

Support reviewdog command line argument changes.

New: support fail-level
Deprecated: fail-on-error

See: #70
See also: https://github.com/reviewdog/reviewdog/blob/master/CHANGELOG.md#rotating_light-deprecation-warnings

@nayuta nayuta self-assigned this Dec 22, 2024
@nayuta nayuta marked this pull request as draft December 22, 2024 06:15
@nayuta nayuta changed the title Support reviewdog command line argument changes Support reviewdog command line argument changes (fail-level) Dec 22, 2024
@nayuta nayuta changed the title Support reviewdog command line argument changes (fail-level) Support reviewdog command line argument changes (--fail-level) Dec 22, 2024
@nayuta nayuta force-pushed the support_reviewdog_parameter_changes branch from a324957 to 091455a Compare December 22, 2024 06:34
@nayuta nayuta marked this pull request as ready for review December 22, 2024 06:35
@nayuta nayuta requested review from haya14busa and shmokmt December 22, 2024 06:36
action.yml Outdated Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
nayuta and others added 2 commits December 25, 2024 15:06
Co-authored-by: Shoma Okamoto <[email protected]>
Co-authored-by: Shoma Okamoto <[email protected]>
@nayuta nayuta requested a review from shmokmt December 25, 2024 07:03
Comment on lines +93 to +95
Optional. The level of failures that will cause the action to fail [any,info,warning,error].

The default is `error`.
Copy link
Member

@shmokmt shmokmt Dec 25, 2024

Choose a reason for hiding this comment

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

Description hasn't been fixed yet. Please fix 🙏
It might be better to use the same sentence as in action-rubocop.

Suggested change
Optional. The level of failures that will cause the action to fail [any,info,warning,error].
The default is `error`.
Optional. If set to none, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. Possible values: [none, any, info, warning, error] Default is none.
The default is `none`.

ref. https://github.com/reviewdog/action-rubocop?tab=readme-ov-file#inputs

Comment on lines +102 to +110
if [[ -n "${INPUT_FAIL_LEVEL}" ]]; then
fail_level="--fail-level=${INPUT_FAIL_LEVEL}"
elif [[ "${INPUT_FAIL_ON_ERROR}" = "true" ]]; then
# For backward compatibility, default to any if fail-on-error is true
# Deprecated
fail_level="--fail-level=any"
else
fail_level=""
fi
Copy link
Member

@shmokmt shmokmt Dec 25, 2024

Choose a reason for hiding this comment

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

I don’t think it makes sense for reviewdog users to include conditional branching based on options.
The reviewdog code seems to include code to take care when fail-on-error is true. You can just pass the two options as is and there will be no problem.

func failLevel(opt *option) reviewdog.FailLevel {
	if opt.failOnError {
		slog.Warn("reviewdog: -fail-on-error is deprecated. Use -fail-level=any, or -fail-level=error for github-[pr-]check reporter instead. See also https://github.com/reviewdog/reviewdog/blob/master/CHANGELOG.md")
		if opt.failLevel == reviewdog.FailLevelDefault {
			switch opt.reporter {
			default:
				return reviewdog.FailLevelAny
			case "github-check", "github-pr-check":
				return reviewdog.FailLevelError
			}
		}
	}
	return opt.failLevel
}

reviewdog/reviewdog#1854
https://github.com/reviewdog/action-rubocop/blob/master/script.sh#L135-L136

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.

2 participants