Skip to content

fixes: enable golanci-lint in CI, fix complaints. #232

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

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

klihub
Copy link
Contributor

@klihub klihub commented Oct 15, 2024

This patch set

  • adds a local [golang]ci-lint Makefile target and hooks it in to pr-checks
  • addresses golangci-lint complaints
  • adds CI golangci-lint workflow

And hook it into [pre-]pr-checks.

Signed-off-by: Krisztian Litkey <[email protected]>
@klihub klihub requested a review from bart0sh October 15, 2024 15:26
@klihub klihub force-pushed the fixes/golangci-lint branch from 2a8ff38 to 776e36e Compare October 15, 2024 15:26
@klihub klihub requested review from kad and elezar October 15, 2024 15:28
@klihub klihub force-pushed the fixes/golangci-lint branch from 776e36e to 6b920fa Compare October 16, 2024 07:54
@klihub klihub requested review from elezar and bart0sh October 16, 2024 07:54
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to specify the version, or should we just use the "default"?

Copy link
Contributor Author

@klihub klihub Oct 16, 2024

Choose a reason for hiding this comment

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

I'm not sure what would make the most sense here. I simply took the provided sample workflow as a basis for this, then bumped the version to the latest release, which I then also used locally for linting.

Looking at the action implementation, it is stated that we could use an explicit 'latest' here. But TBH, I'm not too keen on a setup where we are not in control so without us changing anything, things already merged might start getting flagged in new PRs as linting errors.

Also looking at other projects, most of them seem to lock the version explicitly to one of their choice, which they then keep gradually updating. If we really wanted to go with an uncontrolled rolling version, then we'd need to add a nightly run, to catch extra-repo (IOW golangci-lint) changes breaking things for us...

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @klihub here. To have a reproducible builds (tests in this case) we need to lock lint version.

Copy link
Contributor

@elezar elezar left a comment

Choose a reason for hiding this comment

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

I think this looks good @klihub.

One thought is that for cases where we do record but ignore the errors, we should update the public API documentation to indiate that GetErrors() can be queried to return errors that were raised when refreshing the cache.

Out of scope: we could also look at further segmenting the API to functions that are used by our container runtime consumers (basically Cache instantiation and InjectDevices) so that we have more flexibility with other utility functions such as getting lists of devices.

@klihub
Copy link
Contributor Author

klihub commented Oct 16, 2024

I think this looks good @klihub.

One thought is that for cases where we do record but ignore the errors, we should update the public API documentation to indiate that GetErrors() can be queried to return errors that were raised when refreshing the cache.

@elezar I updated the doc strings of the relevant Cache public API functions, with a brief mention a possible implicit cache refresh and how to obtain any errors encountered it. PTAL.

Update public API documentation to point out a possible implicit
cache refresh and how to query any errors encountered during it.

Signed-off-by: Krisztian Litkey <[email protected]>
@klihub klihub force-pushed the fixes/golangci-lint branch from ef77ab5 to 84ea77f Compare October 16, 2024 11:55
@klihub klihub requested a review from bart0sh October 16, 2024 11:57
Copy link
Contributor

@bart0sh bart0sh left a comment

Choose a reason for hiding this comment

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

/lgtm

@bart0sh bart0sh merged commit 44fef1d into cncf-tags:main Oct 16, 2024
8 checks passed
@klihub klihub deleted the fixes/golangci-lint branch October 16, 2024 18:56
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.

3 participants