Skip to content

Commit

Permalink
Update CI, fix lint (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Nov 26, 2024
1 parent f91a122 commit 66a3996
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
GO111MODULE: "on"
CACHE_BENCHMARK: "off" # Enables benchmark result reuse between runs, may skew latency results.
RUN_BASE_BENCHMARK: "on" # Runs benchmark for PR base in case benchmark result is missing.
GO_VERSION: 1.22.x
GO_VERSION: 1.23.x
jobs:
bench:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.22.x
go-version: 1.23.x
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v4.0.0
uses: golangci/golangci-lint-action@v6.1.0
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.56.2
version: v1.61.0

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.22.x
GO_VERSION: 1.23.x
jobs:
gorelease:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
test:
strategy:
matrix:
go-version: [ 1.13.x, 1.21.x, 1.22.x ]
go-version: [ 1.13.x, 1.22.x, 1.23.x ]
runs-on: ubuntu-latest
steps:
- name: Install Go stable
Expand Down
20 changes: 8 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,40 @@ linters:
disable:
- musttag
- lll
- maligned
- gochecknoglobals
- gomnd
- wrapcheck
- paralleltest
- forbidigo
- exhaustivestruct
- interfacer # deprecated
- forcetypeassert
- scopelint # deprecated
- ifshort # too many false positives
- golint # deprecated
- varnamelen
- tagliatelle
- errname
- ireturn
- exhaustruct
- nonamedreturns
- nosnakecase
- structcheck
- varcheck
- deadcode
- testableexamples
- dupword
- depguard
- tagalign
- execinquery
- mnd
- testifylint

issues:
exclude-use-default: false
exclude-rules:
- linters:
- gomnd
- mnd
- goconst
- goerr113
- err113
- noctx
- funlen
- dupl
- structcheck
- unused
- unparam
- nosnakecase
path: "_test.go"
- linters:
- errcheck # Error checking omitted for brevity.
Expand All @@ -71,4 +64,7 @@ issues:
- ineffassign
- wastedassign
path: "example_"
- linters:
- revive
text: "unused-parameter: parameter"

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#GOLANGCI_LINT_VERSION := "v1.56.2" # Optional configuration to pinpoint golangci-lint version.
#GOLANGCI_LINT_VERSION := "v1.61.0" # Optional configuration to pinpoint golangci-lint version.

# The head of Makefile determines location of dev-go to include standard targets.
GO ?= go
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/Masterminds/squirrel v1.5.4
github.com/bool64/ctxd v1.2.1
github.com/bool64/dev v0.2.34
github.com/bool64/dev v0.2.36
github.com/jmoiron/sqlx v1.4.0
github.com/stretchr/testify v1.8.2
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/bool64/ctxd v1.2.1 h1:hARFteq0zdn4bwfmxLhak3fXFuvtJVKDH2X29VV/2ls=
github.com/bool64/ctxd v1.2.1/go.mod h1:ZG6QkeGVLTiUl2mxPpyHmFhDzFZCyocr9hluBV3LYuc=
github.com/bool64/dev v0.2.34 h1:P9n315P8LdpxusnYQ0X7MP1CZXwBK5ae5RZrd+GdSZE=
github.com/bool64/dev v0.2.34/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/bool64/dev v0.2.36 h1:yU3bbOTujoxhWnt8ig8t94PVmZXIkCaRj9C57OtqJBY=
github.com/bool64/dev v0.2.36/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
3 changes: 2 additions & 1 deletion storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func (s *Storage) Exec(ctx context.Context, qb ToSQL) (res sql.Result, err error

// Query queries database and returns raw result.
//
// You must close the rows after use to avoid resource leak.
// Select is recommended to use instead of Query.
func (s *Storage) Query(ctx context.Context, qb ToSQL) (*sqlx.Rows, error) {
query, args, err := qb.ToSql()
Expand All @@ -228,7 +229,7 @@ func (s *Storage) Query(ctx context.Context, qb ToSQL) (*sqlx.Rows, error) {
queryer = s.db
}

rows, err := queryer.QueryxContext(ctx, query, args...)
rows, err := queryer.QueryxContext(ctx, query, args...) //nolint:sqlclosecheck // Caller closes rows.
if err != nil {
return nil, s.error(ctx, err)
}
Expand Down
1 change: 1 addition & 0 deletions storage_go1.18_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestList(t *testing.T) {
for i := 0; i < 100; i++ {
mockedRows.AddRow(i, 2*i, 3*i)
}

mock.ExpectQuery("SELECT one, two, three FROM table").WillReturnRows(mockedRows)

rows, err := sqluct.List[row](ctx, st, qb)
Expand Down
3 changes: 2 additions & 1 deletion storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (d dumpConn) Close() error {
}

func (d dumpConn) Begin() (driver.Tx, error) {
return nil, nil
return nil, nil //nolint:nilnil
}

func (d dumpDriver) Open(name string) (driver.Conn, error) {
Expand Down Expand Up @@ -230,6 +230,7 @@ func TestStorage_SelectContext_slice(t *testing.T) {
for i := 0; i < 100; i++ {
mockedRows.AddRow(i, 2*i, 3*i)
}

mock.ExpectQuery("SELECT one, two, three FROM table").WillReturnRows(mockedRows)

err = st.Select(ctx, qb, &rows)
Expand Down

0 comments on commit 66a3996

Please sign in to comment.