Skip to content

chore: bump golangci-lint-action to v9.2.1 and fix v2 config format#5977

Merged
RongGu merged 7 commits into
fluid-cloudnative:masterfrom
cheyang:fix/golangci-v2-config
Jun 19, 2026
Merged

chore: bump golangci-lint-action to v9.2.1 and fix v2 config format#5977
RongGu merged 7 commits into
fluid-cloudnative:masterfrom
cheyang:fix/golangci-v2-config

Conversation

@cheyang

@cheyang cheyang commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Bump golangci/golangci-lint-action from v6.5.2 to v9.2.1
  • Add .golangci.yml with version 2 config format, using the correct issues.exclusions.rules key instead of the v1 issues.exclude-rules key
  • Fix printf format string in pkg/ddc/juicefs/transform.go (go vet: non-constant format string)
  • Fix unchecked file.Close in pkg/utils/metadata.go (errcheck)

Motivation

PR #5910 introduced .golangci.yml with version: "2" but used the v1 config key issues.exclude-rules. In golangci-lint v2 config format, this should be issues.exclusions.rules. The incorrect key caused the test file errcheck exclusion to silently not apply, resulting in 10 lint failures in _test.go files.

This PR supersedes #5910 with the corrected config format.

Test plan

  • CI lint job passes (errcheck exclusion for test files takes effect)
  • No new lint warnings introduced

- Bump golangci/golangci-lint-action from v6.5.2 to v9.2.1
- Add .golangci.yml with version 2 config format, using the correct
  `issues.exclusions.rules` key (not the v1 `issues.exclude-rules`)
- Fix printf format string in juicefs transform.go (go vet)
- Fix unchecked file.Close in metadata.go (errcheck)

Supersedes fluid-cloudnative#5910.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: cheyang <cheyang@163.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a .golangci.yml configuration file, fixes a format string bug in transform.go by using "%s" in Eventf, and wraps file.Close() in a defer block in metadata.go. The review feedback correctly identifies that the key issues.exclusions.rules in .golangci.yml is incorrect and should be issues.exclude.rules to avoid configuration errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread .golangci.yml
Comment on lines +18 to +19
exclusions:
rules:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

In the golangci-lint version 2 configuration format, the correct key for excluding rules is issues.exclude.rules, not issues.exclusions.rules. Using exclusions will cause the exclusion rules to be silently ignored, and the errcheck linter will not be disabled for test files as intended.

  exclude:
    rules:

cheyang and others added 4 commits June 11, 2026 20:53
The `defaults.run.working-directory` only applies to `run:` steps,
not `uses:` action steps. The golangci-lint-action was running in the
default working directory and could not find `.golangci.yml` in the
custom checkout path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: cheyang <cheyang@163.com>
In golangci-lint v2 config format, `exclusions` is a top-level key,
not nested under `issues`. The previous config caused schema validation
failure: "additional properties 'exclusions' not allowed" under issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: cheyang <cheyang@163.com>
In golangci-lint v2, `exclusions` is a child of `linters`, not a
top-level key or under `issues`. Move it to `linters.exclusions.rules`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: cheyang <cheyang@163.com>
These are pre-existing naming convention and package comment style
issues throughout the codebase. Suppressing them avoids a large-scale
refactor unrelated to the golangci-lint upgrade.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: cheyang <cheyang@163.com>
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.56%. Comparing base (35e26a8) to head (970e469).
⚠️ Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
pkg/ddc/juicefs/transform.go 0.00% 1 Missing ⚠️
pkg/utils/metadata.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5977   +/-   ##
=======================================
  Coverage   63.56%   63.56%           
=======================================
  Files         479      479           
  Lines       33275    33275           
=======================================
  Hits        21150    21150           
  Misses      10445    10445           
  Partials     1680     1680           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Pre-existing receiver naming inconsistencies (ST1016) and exported
method comment format issues (ST1020) throughout the codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: cheyang <cheyang@163.com>
@cheyang

cheyang commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

Review — golangci-lint v9.2.1 bump + config migration

The action bump and workflow fix look correct, and the two Go code fixes (Eventf format-string safety, deferred Close error handling) are solid improvements. However, the lint job is currently failing because the new .golangci.yml doesn't suppress enough staticcheck rules to pass on the existing codebase.


Lint failure — missing ST1021 / ST1022 suppressions

The config disables ST1020 (exported function/method comment form) but omits the closely related:

  • ST1021 — comment on exported type should be of the form "TypeName ..."
  • ST1022 — comment on exported var should be of the form "VarName ..."

This results in 19 failures against pre-existing code (e.g. common.go:145, types.go:33, runtime.go:60). Adding "-ST1021" and "-ST1022" to the checks list should fix it.


Other observations

  • working-directory addition in the workflow is necessary — v9.x changed directory resolution behavior when checkout targets a non-default path. Looks good.
  • The Eventf(runtime, ..., "%s", msg) fix correctly prevents accidental format-string interpretation.
  • defer func() { _ = file.Close() }() properly silences errcheck for a deferred close where the return value is intentionally discarded.

Verdict: needs-work

Please add the two missing suppressions (-ST1021, -ST1022) so the lint job passes.

Use wildcards to suppress all style (ST*) and quickfix (QF*) checks
rather than adding individual rules one by one. These are pre-existing
conventions throughout the codebase and not actionable bugs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: cheyang <cheyang@163.com>

@cheyang cheyang left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Re-review after addressing the ST1021/ST1022 suppression gap from the previous round.

Findings:

  1. The wildcard -ST* and -QF* approach in .golangci.yml is a pragmatic choice — it covers all pre-existing style/quickfix violations (including the previously flagged ST1021 and ST1022) without requiring a large-scale code refactor. Reasonable for a CI tooling upgrade PR.

  2. The working-directory addition to the lint action step is correct: uses: steps do not inherit defaults.run.working-directory, so the explicit path is needed to locate .golangci.yml.

  3. The printf format fix in transform.go ("%s", msg instead of bare msg) prevents potential format-string issues and satisfies go vet.

  4. The defer func() { _ = file.Close() }() pattern in metadata.go correctly silences errcheck for read-only file handles where the Close error is non-actionable.

  5. All relevant CI checks pass (lint, staticcheck, build, unittest, E2E). The sole failure (backward-compat-test v1.22.17) is in the Docker build step and is unrelated to this change — rerun triggered.

Verdict: ready-to-merge. No blocking issues remain.

@RongGu RongGu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm
/approve

@fluid-e2e-bot

fluid-e2e-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RongGu

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

The pull request process is described here

Details 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

@RongGu RongGu merged commit 0e27ebd into fluid-cloudnative:master Jun 19, 2026
28 of 29 checks passed
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants