瀏覽代碼

ci: fix up lint issues

Joe Chen 4 月之前
父節點
當前提交
300519d1ca
共有 7 個文件被更改,包括 21 次插入12 次删除
  1. 10 6
      .github/workflows/go.yml
  2. 5 0
      .golangci.yml
  3. 2 2
      gen.go
  4. 1 1
      internal/db/issue.go
  5. 1 1
      internal/db/milestone.go
  6. 1 1
      internal/db/mocks_test.go
  7. 1 1
      internal/route/lfs/mocks_test.go

+ 10 - 6
.github/workflows/go.yml

@@ -30,14 +30,13 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout code
-        uses: actions/checkout@v2
-      - name: Run golangci-lint
-        uses: golangci/golangci-lint-action@v2
+        uses: actions/checkout@v4
+      - name: Install Go
+        uses: actions/setup-go@v5
         with:
-          version: latest
-          args: --timeout=30m
+          go-version: 1.23.x
       - name: Install Task
-        uses: arduino/setup-task@v1
+        uses: arduino/setup-task@v2
         with:
           repo-token: ${{ secrets.GITHUB_TOKEN }}
       - name: Check Go module tidiness and generated files
@@ -52,6 +51,11 @@ jobs:
             echo "Run 'go mod tidy' or 'task generate' commit them"
             exit 1
           fi
+      - name: Run golangci-lint
+        uses: golangci/golangci-lint-action@v4
+        with:
+          version: latest
+          args: --timeout=30m
 
   test:
     name: Test

+ 5 - 0
.golangci.yml

@@ -6,6 +6,11 @@ linters-settings:
     ]
   nakedret:
     max-func-lines: 0 # Disallow any unnamed return statement
+  govet:
+    disable:
+      # printf: non-constant format string in call to fmt.Errorf (govet)
+      # showing up since golangci-lint version 1.60.1
+      - printf
 
 linters:
   enable:

+ 2 - 2
gen.go

@@ -4,5 +4,5 @@
 
 package main
 
-//go:generate go install golang.org/x/tools/cmd/goimports@v0.1.10
-//go:generate go run github.com/derision-test/go-mockgen/cmd/go-mockgen@v1.3.3
+//go:generate go install golang.org/x/tools/cmd/goimports@v0.17.0
+//go:generate go run github.com/derision-test/go-mockgen/v2/cmd/go-mockgen@v2.0.1

+ 1 - 1
internal/db/issue.go

@@ -361,7 +361,7 @@ func (issue *Issue) ClearLabels(doer *User) (err error) {
 		err = issue.PullRequest.LoadIssue()
 		if err != nil {
 			log.Error("LoadIssue: %v", err)
-			return
+			return err
 		}
 		err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
 			Action:      api.HOOK_ISSUE_LABEL_CLEARED,

+ 1 - 1
internal/db/milestone.go

@@ -357,7 +357,7 @@ func ChangeMilestoneAssign(doer *User, issue *Issue, oldMilestoneID int64) (err
 		err = issue.PullRequest.LoadIssue()
 		if err != nil {
 			log.Error("LoadIssue: %v", err)
-			return
+			return err
 		}
 		err = PrepareWebhooks(issue.Repo, HOOK_EVENT_PULL_REQUEST, &api.PullRequestPayload{
 			Action:      hookAction,

+ 1 - 1
internal/db/mocks_test.go

@@ -1,4 +1,4 @@
-// Code generated by go-mockgen 1.3.3; DO NOT EDIT.
+// Code generated by go-mockgen 1.3.7; DO NOT EDIT.
 //
 // This file was generated by running `go-mockgen` at the root of this repository.
 // To add additional mocks to this or another package, add a new entry to the

+ 1 - 1
internal/route/lfs/mocks_test.go

@@ -1,4 +1,4 @@
-// Code generated by go-mockgen 1.3.3; DO NOT EDIT.
+// Code generated by go-mockgen 1.3.7; DO NOT EDIT.
 //
 // This file was generated by running `go-mockgen` at the root of this repository.
 // To add additional mocks to this or another package, add a new entry to the