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

Configuration file verification #1163

Closed
2 tasks done
azazeal opened this issue Feb 13, 2025 · 0 comments · Fixed by #1167
Closed
2 tasks done

Configuration file verification #1163

azazeal opened this issue Feb 13, 2025 · 0 comments · Fixed by #1167
Labels
area: verify enhancement New feature or request

Comments

@azazeal
Copy link

azazeal commented Feb 13, 2025

Welcome

  • Yes, I understand that the GitHub action repository is not the repository of golangci-lint itself.
  • Yes, I've searched similar issues on GitHub and didn't find any.

Your feature request related to a problem? Please describe.

Configuration files for golangci-lint become invalid over time, as linters are added and removed and some even have their configuration schemas changed.

In cases like these, it'd be helpful, I think, to have the build break with an appropriate message if the caller opts for that.

For example, in one of the projects we use this action, when verifying the configuration file manually, we get the following:

$ golangci-lint config verify
jsonschema: "linters-settings.revive" does not validate with "/properties/linters-settings/properties/revive/additionalProperties": additionalProperties 'min-confidence' not allowed
jsonschema: "linters-settings.depguard" does not validate with "/properties/linters-settings/properties/depguard/additionalProperties": additionalProperties 'list-type', 'packages' not allowed
jsonschema: "linters-settings.errorlint" does not validate with "/properties/linters-settings/properties/errorlint/type": expected object, but got null
jsonschema: "linters-settings" does not validate with "/properties/linters-settings/additionalProperties": additionalProperties 'maligned', 'varcheck', 'gomnd' not allowed
Failed executing command with error: the configuration contains invalid elements

But, when the linter is executed, only a warning is outputted and the build ends up green.

$ golangci-lint run
WARN The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar.

In our case, we'd much rather have the build break when the configuration file isn't valid but there's no way to instruct the action to do so, currently.

Describe the solution you'd like.

The validity of the configuration file passed to golangci-lint can be determined via executing

golangci-lint config verify

A boolean option can be introduced to the action, namely verify-config, that, when set, would execute said command before golangci-lint run, to ensure that the linting process is in fact using a valid configuration file.

Describe alternatives you've considered.

We're bypassing the above issues by installing the binary ourselves and running the aforementioned check but we'd much rather have the action do it.

Additional context.

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: verify enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants