node-maintenance-operator icon indicating copy to clipboard operation
node-maintenance-operator copied to clipboard

[WIP] Add Super Linter target and CI

Open razo7 opened this issue 3 years ago • 8 comments

What has changed?

  • Add and run multiple linters, using one big linter (Super Linter). Linting will test our code base locally and will be run for each PR using Pre Submit job.
  • Use super-linter slim - https://github.com/super-linter/super-linter#slim-image
  • Use test target for unit-test and lint target for the rest
  • Fetch and verify Golang version prior to make lint by go.mod and go.sum files

What and why to lint the code?

Linting is the automated checking of your source code for programmatic and stylistic errors. This is done by using a lint tool (otherwise known as linter). A lint tool is a basic static code analyzer.

The term linting originally comes from a Unix utility for C, and it is important to reduce errors and improve the overall quality of your code. Using lint tools can help you accelerate development and reduce costs by finding errors earlier.

More about Super Linter

The super-linter finds issues and reports them to the console output. Fixes are suggested in the console output but not automatically fixed, and a status check will show up as failed on the pull request. It includes many linters such as:

To locally test specific files (and ignore the reset) please use the FILTER_REGEX_INCLUDE environment variable in the super-linter target on Makefile, e.g. for only linting files with names include Makefile or README.md append -e FILTER_REGEX_INCLUDE="Makefile|README.md" \.

In addition, we can exclude directories or files based on regex, e.g. -e FILTER_REGEX_EXCLUDE="/vendor/"

https://issues.redhat.com/browse/ECOPROJECT-1207

razo7 avatar Mar 14 '23 09:03 razo7

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: razo7

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

openshift-ci[bot] avatar Mar 14 '23 09:03 openshift-ci[bot]

ATM I am expecting Pre Submit / Test and build PRs to fail until we fix the suggestion and errors from super-linter. Corrections will be implemented in a follow up PR

razo7 avatar Mar 19 '23 08:03 razo7

/retest

razo7 avatar Mar 19 '23 10:03 razo7

in general looks good now 🙂

  • can you decrease verbosity with LOG_LEVEL="NOTICE" please?
  • there are many false positives from golangci-lint like undeclared name: AddOrRemoveTaint (typecheck). Looks like it only checks the current file for declarations? I hope that can be fixed somehow?
  • for me IGNORE_GITIGNORED_FILES doesn't seem to work, I see that it tries to check /bin and /.idea directories? 🤔

I would also prefer to fix actual lint issues in this PR, otherwise any other PR gets a red CI until a follow up PR is merged... WDYT?

slintes avatar Mar 20 '23 20:03 slintes

  • there are many false positives from golangci-lint like undeclared name: AddOrRemoveTaint (typecheck). Looks like it only checks the current file for declarations? I hope that can be fixed somehow?

Did some tests with golangci-lint directly, seems to be an issue with a too old version of it. Tested with $ golangci-lint run --disable-all --enable typecheck

slintes avatar Mar 20 '23 21:03 slintes

can you decrease verbosity with LOG_LEVEL="NOTICE" please?

Sure

there are many false positives from golangci-lint like undeclared name: AddOrRemoveTaint (typecheck). Looks like it only checks the current file for declarations? I hope that can be fixed somehow?

Yes, I have seen it as well, and will check it.

for me IGNORE_GITIGNORED_FILES doesn't seem to work, I see that it tries to check /bin and /.idea directories?

For me as well, but I have manged to exclude the bin directory using this environment variable FILTER_REGEX_EXCLUDE="/vendor/|/bin/"

I would also prefer to fix actual lint issues in this PR, otherwise any other PR gets a red CI until a follow up PR is merged... WDYT?

I agree, and I will add a commit with a fix per linter (and each commit message will include the errors and warnings it fixes or ignored).

razo7 avatar May 31 '23 13:05 razo7

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-merge-robot avatar Jan 25 '24 14:01 openshift-merge-robot

@razo7: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/4.11-ci-index b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.11-ci-index
ci/prow/4.11-images b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.11-images
ci/prow/4.11-openshift-e2e b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.11-openshift-e2e
ci/prow/4.12-images b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.12-images
ci/prow/4.12-ci-index b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.12-ci-index
ci/prow/4.13-ci-index b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.13-ci-index
ci/prow/4.13-images b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.13-images
ci/prow/4.13-openshift-e2e b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.13-openshift-e2e
ci/prow/4.14-ci-index b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.14-ci-index
ci/prow/4.14-images b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.14-images
ci/prow/4.12-openshift-e2e b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.12-openshift-e2e
ci/prow/4.14-openshift-e2e b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.14-openshift-e2e
ci/prow/4.15-ci-index b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.15-ci-index
ci/prow/4.15-images b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.15-images
ci/prow/4.15-openshift-e2e b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.15-openshift-e2e
ci/prow/4.12-ci-bundle-my-bundle b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.12-ci-bundle-my-bundle
ci/prow/4.13-ci-bundle-my-bundle b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.13-ci-bundle-my-bundle
ci/prow/4.15-ci-bundle-my-bundle b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.15-ci-bundle-my-bundle
ci/prow/4.14-ci-bundle-my-bundle b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.14-ci-bundle-my-bundle
ci/prow/4.16-images b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.16-images
ci/prow/4.12-unit-test b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.12-unit-test
ci/prow/4.16-ci-bundle-my-bundle b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.16-ci-bundle-my-bundle
ci/prow/4.16-unit-test b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.16-unit-test
ci/prow/4.16-openshift-e2e b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.16-openshift-e2e
ci/prow/4.13-unit-test b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.13-unit-test
ci/prow/4.15-unit-test b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.15-unit-test
ci/prow/4.14-unit-test b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.14-unit-test
ci/prow/4.17-ci-bundle-my-bundle b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.17-ci-bundle-my-bundle
ci/prow/4.17-images b9a961ad5f4e9973f7339f20d8615ee53912291f link true /test 4.17-images

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

openshift-ci[bot] avatar Jun 29 '24 12:06 openshift-ci[bot]

will close to save test resources, feel free to reopen when going on with this

/close

slintes avatar Jul 01 '24 07:07 slintes

@slintes: Closed this PR.

In response to this:

will close to save test resources, feel free to reopen when going on with this

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

openshift-ci[bot] avatar Jul 01 '24 07:07 openshift-ci[bot]