Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/release-diag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:

jobs:
release:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 30
outputs:
REL_VER: ${{ steps.build_diag.outputs.REL_VER }}
Expand All @@ -38,14 +38,14 @@ jobs:
env:
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
steps:
- name: Set up Go 1.24
uses: actions/setup-go@v4
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.24.x
go-version-file: 'go.mod'
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.git-ref || github.event.pull_request.head.sha }}
path: go/src/github.com/${{ github.repository }}
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/reprotest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,16 @@ on:
jobs:
reprotest:
# The type of runner that the job will run on
runs-on: ubuntu-22.04

strategy:
matrix:
go:
- 1.24.x
runs-on: ubuntu-24.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6

- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
go-version-file: 'go.mod'

- name: Install reprotest and prepare
id: prepare_env
Expand Down
22 changes: 6 additions & 16 deletions .github/workflows/static-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,22 @@ on:
jobs:
unit-test:
runs-on: ubuntu-latest
env:
working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
path: go/src/github.com/${{ github.repository }}
- name: Check out code
uses: actions/checkout@v6

- name: Set up Go 1.24
uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.24.x
id: go
go-version-file: 'go.mod'

- name: make unit-test
working-directory: ${{ env.working-directory }}
run: |
export GOPATH=${GITHUB_WORKSPACE}/go
export PATH=$PATH:$GOPATH/bin
make check
make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
working-directory: ${{ env.working-directory }}
files: ./tests/cov.unit-test.out
flags: unittests
98 changes: 60 additions & 38 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,64 @@
run:
timeout: 10m
version: "2"
linters:
disable-all: true
default: none
enable:
- misspell
- ineffassign
# - typecheck
# - varcheck
# - unused
# - deadcode
# - gosimple
# - goimports
# - errcheck
# - staticcheck
- stylecheck
- gosec
- asciicheck
- bodyclose
# - exportloopref
# - rowserrcheck
# - unconvert
# - makezero
# - durationcheck
# - prealloc

linters-settings:
staticcheck:
checks: ["S1002","S1004","S1007","S1009","S1010","S1012","S1019","S1020","S1021","S1024","S1030","SA2*","SA3*","SA4009","SA5*","SA6000","SA6001","SA6005", "-SA2002"]
stylecheck:
checks: ["-ST1003"]
gosec:
excludes:
- G115
issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gosec
- rowserrcheck
- makezero
- gosec
- ineffassign
- misspell
- staticcheck
settings:
gosec:
excludes:
- G115
- G117
- G703
- G704
staticcheck:
checks:
- -SA2002
- -ST1003
- S1002
- S1004
- S1007
- S1009
- S1010
- S1012
- S1019
- S1020
- S1021
- S1024
- S1030
- SA2*
- SA3*
- SA4009
- SA5*
- SA6000
- SA6001
- SA6005
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- errcheck
- gosec
- makezero
- rowserrcheck
path: _test\.go
paths:
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ tests/bin/revive: tests/check/go.mod
$(GO) build -o ../bin/revive github.com/mgechev/revive

tools/bin/golangci-lint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./tools/bin v1.64.8
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./tools/bin v2.10.1

check-static: tools/bin/golangci-lint
GO111MODULE=on CGO_ENABLED=0 tools/bin/golangci-lint run -v --config .golangci.yml
4 changes: 2 additions & 2 deletions cmd/diag/command/aduit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
package command

import (
"github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/cluster/audit"
"github.com/pingcap/tiup/pkg/cluster/spec"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)

// retainDays number of days to keep audit logs for deletion
// retainDays number of days to keep audit logs for deletion
var retainDays int

func newAuditCmd() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion cmd/diag/command/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func newCollectCmd() *cobra.Command {
}
cOpt.Mode = collector.CollectModeTiUP

if cOpt.CompressMetrics == false {
if !cOpt.CompressMetrics {
log.Warnf("%s", color.YellowString("Uncompressed metrics may not be handled correctly by Clinic, use it only when you really need it"))
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/diag/command/collectdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func newCollectDMCmd() *cobra.Command {
}
}

if cOpt.CompressMetrics == false {
if !cOpt.CompressMetrics {
log.Warnf("%s", color.YellowString("Uncompressed metrics may not be handled correctly by Clinic, use it only when you really need it"))
}

Expand Down
11 changes: 0 additions & 11 deletions cmd/diag/command/root_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions collector/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ func ParseCollectTree(include, exclude []string) (CollectTree, error) {
num := reflectV.NumField()
var i int
for i = 0; i < num; i++ {
if strings.ToLower(k) == strings.ToLower(reflectV.Type().Field(i).Name) {
if strings.EqualFold(k, reflectV.Type().Field(i).Name) {
reflectV = reflectV.Field(i)
break
}
Expand All @@ -710,7 +710,7 @@ func ParseCollectTree(include, exclude []string) (CollectTree, error) {
num := reflectV.NumField()
var i int
for i = 0; i < num; i++ {
if strings.ToLower(k) == strings.ToLower(reflectV.Type().Field(i).Name) {
if strings.EqualFold(k, reflectV.Type().Field(i).Name) {
reflectV = reflectV.Field(i)
break
}
Expand Down
6 changes: 3 additions & 3 deletions collector/plan_replayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
"github.com/joomcode/errorx"
"github.com/pingcap/diag/pkg/models"
perrs "github.com/pingcap/errors"
"github.com/pingcap/tidb/parser"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/pkg/parser"
"github.com/pingcap/tidb/pkg/parser/ast"

// Register some standard stuff
_ "github.com/pingcap/tidb/parser/test_driver"
_ "github.com/pingcap/tidb/pkg/parser/test_driver"
"github.com/pingcap/tiup/pkg/cluster/ctxt"
operator "github.com/pingcap/tiup/pkg/cluster/operation"
"github.com/pingcap/tiup/pkg/cluster/task"
Expand Down
2 changes: 1 addition & 1 deletion collector/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ func (c *SchemaCollectOptions) Collect(m *Manager, topo *models.TiDBCluster) err
var db *sql.DB
for _, inst := range tidbInstants {
trydb, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/", c.dbuser, c.dbpasswd, inst.Host(), inst.MainPort()))
defer trydb.Close()
if err != nil {
return err
}
defer trydb.Close()
err = trydb.Ping()
if err == nil {
db = trydb
Expand Down
Loading