Skip to content

Add golangci-lint CI check#58

Merged
volcano-sh-bot merged 2 commits intomainfrom
copilot/add-golangci-lint-check
Dec 8, 2025
Merged

Add golangci-lint CI check#58
volcano-sh-bot merged 2 commits intomainfrom
copilot/add-golangci-lint-check

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 8, 2025

Adds automated Go code linting via golangci-lint to enforce code quality standards on PRs.

Changes

  • .golangci.yml: Configuration enabling 12 linters (errcheck, govet, staticcheck, gosec, revive, etc.) with exclusions for generated client-go code
  • .github/workflows/lint.yml: GitHub Actions workflow running golangci-lint on pull requests to main and release-* branches with path filters for Go-related files only
  • Makefile: Added golangci-lint v1.64.1 installation and updated lint target to use the versioned binary

Configuration highlights

linters:
  enable:
    - errcheck        # Unchecked errors
    - govet           # Suspicious constructs
    - staticcheck     # Static analysis
    - gosec           # Security issues
    - revive          # Style and best practices
    # ... + 7 more
    
issues:
  exclude-rules:
    - path: client-go/  # Skip generated code
    - path: _test\.go   # Relaxed rules for tests

Workflow triggers

The lint workflow runs only on pull requests (not on push) and includes path filters to run only when Go-related files change:

  • **.go - Go source files
  • go.mod, go.sum - Go module files
  • .golangci.yml - Linter configuration
  • .github/workflows/lint.yml - Workflow file

Implementation

Following the pattern from volcano-sh/kthena#43, the workflow uses an explicit golangci-lint version (v1.64.1) installed via Makefile rather than golangci-lint-action. The workflow runs make lint which downloads and uses the versioned binary from the bin/ directory, ensuring consistent linting across local development and CI environments.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add a golangci-lint check for the project</issue_title>
<issue_description>We should provide a ci check for golang code, prefer to use golangci-lint</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add golangci-lint check for the project Add golangci-lint CI check Dec 8, 2025
Copilot AI requested a review from hzxuzhonghu December 8, 2025 07:04

on:
pull_request:
branches: [ main ]
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.

@copilot Please using path ignore to ignore non related files update

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added path filters to only run on Go-related files (*.go, go.mod, go.sum, .golangci.yml, and the workflow itself). Fixed in 8956d6a.

on:
pull_request:
branches: [ main ]
push:
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.

@copilot remove execution on push

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the push trigger - workflow now only runs on pull_request events. Fixed in 8956d6a.


on:
pull_request:
branches: [ main ]
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.

@copilot add also branch matches release-*

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added 'release-*' branch pattern to trigger the workflow on release branches. Fixed in 8956d6a.

@hzxuzhonghu
Copy link
Copy Markdown
Member

/label tide/merge-method-squash

@hzxuzhonghu
Copy link
Copy Markdown
Member

@copilot please remove using golangci-lint-action, we want to use explicit golangci-lint version. Please follow volcano-sh/kthena#43

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 8, 2025

@copilot please remove using golangci-lint-action, we want to use explicit golangci-lint version. Please follow volcano-sh/kthena#43

Replaced golangci-lint-action with explicit version (v1.64.1) installed via Makefile, following the pattern from volcano-sh/kthena#43. The workflow now runs make lint which uses the versioned golangci-lint binary. Fixed in ee65f10.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/volcano-sh/kthena/contents/.github/workflows
    • Triggering command: /usr/bin/curl curl -sL REDACTED (http block)
  • https://api.github.com/repos/volcano-sh/kthena/pulls/43/files
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 2 commits December 8, 2025 16:58
Co-authored-by: hzxuzhonghu <13374016+hzxuzhonghu@users.noreply.github.com>
Signed-off-by: Zhonghu Xu <xuzhonghu@huawei.com>
@hzxuzhonghu hzxuzhonghu force-pushed the copilot/add-golangci-lint-check branch from ee65f10 to add96eb Compare December 8, 2025 09:00
@hzxuzhonghu hzxuzhonghu marked this pull request as ready for review December 8, 2025 09:00
Copilot AI review requested due to automatic review settings December 8, 2025 09:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds automated Go code linting via golangci-lint to enforce code quality standards on pull requests. It introduces a GitHub Actions workflow that runs golangci-lint v1.64.1 on PRs to main and release-* branches, with path filters to run only when Go-related files change. The PR also includes comprehensive code fixes across the codebase to address existing linting issues.

Key Changes

  • Added golangci-lint configuration enabling 11 linters (errcheck, govet, staticcheck, gosec, revive, etc.) with gosimple explicitly disabled
  • Implemented GitHub Actions workflow to run linting on pull requests with appropriate path filters
  • Fixed numerous linting issues including unused parameters, deprecated imports, naming conventions, dead code removal, and simplified error handling

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.golangci.yml Configuration file enabling 11 linters with 5-minute timeout and specific settings for complexity and type assertion checks
.github/workflows/lint.yml GitHub Actions workflow running golangci-lint on PRs with path filters for Go files
Makefile Added golangci-lint v1.64.1 installation target and updated lint target to use versioned binary from bin/ directory
test/e2e/e2e_test.go Added nolint directives for unparam and gosec issues with explanatory comments; removed redundant type conversion
pkg/workloadmanager/workload_builder.go Migrated from deprecated k8s.io/utils/pointer to k8s.io/utils/ptr; fixed variable naming from sessionId to sessionID
pkg/workloadmanager/store.go Renamed unused parameters to underscore; captured return values from AddEventHandler; removed unused error return from convertSandboxToRedisCache
pkg/workloadmanager/sandbox_controller.go Renamed unused ctx parameter to underscore in WatchSandboxOnce
pkg/workloadmanager/k8s_client.go Removed unused token parameter from clientCache.Get(); added revive disable directive for SessionIdLabelKey naming
pkg/workloadmanager/handlers.go Added nolint directive for gocyclo; simplified convertSandboxToRedisCache call by removing unused error handling
pkg/workloadmanager/codeinterpreter_controller.go Renamed unused ci parameter to underscore in convertToPodTemplate
pkg/workloadmanager/client_cache.go Removed unused token parameter from Get method; added nolint directives for errcheck on type assertions
pkg/workloadmanager/auth.go Removed unused checkSandboxAccess function
pkg/redis/client.go Removed unused loadSandboxesByIDs function
pkg/agentd/agentd_test.go Fixed test function naming from TestAgentdReconciler_* to TestReconciler_*
pkg/agentd/agentd.go Renamed AgentdReconciler struct to Reconciler for better naming convention
cmd/agentd/main.go Updated struct reference from agentd.AgentdReconciler to agentd.Reconciler

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

// handleCreateSandbox handles sandbox creation requests
// nolint :gocyclo
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The nolint directive has incorrect syntax. There should be no space between nolint and the colon. Change // nolint :gocyclo to // nolint:gocyclo for golangci-lint to properly recognize and apply the directive.

Suggested change
// nolint :gocyclo
// nolint:gocyclo

Copilot uses AI. Check for mistakes.
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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

@volcano-sh-bot volcano-sh-bot merged commit 6455626 into main Dec 8, 2025
11 checks passed
@hzxuzhonghu hzxuzhonghu deleted the copilot/add-golangci-lint-check branch December 26, 2025 07:44
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.

Add a golangci-lint check for the project

5 participants