Skip to content

Commit 305cd14

Browse files
authored
Merge pull request #1 from hslatman/modernize
Update CI actions
2 parents 97c9c04 + e9e2000 commit 305cd14

File tree

12 files changed

+63
-21
lines changed

12 files changed

+63
-21
lines changed

.github/workflows/go.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,41 @@ jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1515

1616
- name: Set up Go
17-
uses: actions/setup-go@v2
17+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
1818
with:
19-
go-version: 1.17
19+
go-version: 1.24 # TODO: matrix
2020

21-
- name: build
21+
- name: Build
2222
run: go build -v ./...
2323

2424
test:
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2828

2929
- name: Set up Go
30-
uses: actions/setup-go@v2
30+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
3131
with:
32-
go-version: 1.17
32+
go-version: 1.24 # TODO: matrix
3333

3434
- name: Test
3535
run: go test -v -race ./...
3636

3737
check:
3838
runs-on: ubuntu-latest
3939
steps:
40-
- uses: actions/checkout@v2
40+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4141

4242
- name: golangci-lint
43-
run: docker run -v $GITHUB_WORKSPACE:/repo -w /repo golangci/golangci-lint:v1.42 golangci-lint run
43+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
44+
with:
45+
version: v2.5.0
46+
47+
- name: Run linter
48+
uses: magefile/mage-action@6f50bbb8ea47d56e62dee92392788acbc8192d0b # v3.1.0
49+
with:
50+
version: latest
51+
args: lint

.golangci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
issues:
2-
exclude:
3-
- "SA1019: .* has been deprecated since Go 1.*: Drivers should implement .*"
1+
version: "2"
2+
linters:
3+
exclusions:
4+
rules:
5+
- linters:
6+
- staticcheck
7+
text: "SA1019: .* has been deprecated since Go 1.*: Drivers should implement .*" # TODO: upgrade Go version, and drop these functions?

.tools/go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module tools
2+
3+
go 1.24.0
4+
5+
tool github.com/magefile/mage
6+
7+
require github.com/magefile/mage v1.15.0 // indirect

.tools/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
2+
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
[![GoDoc](https://godoc.org/github.com/ngrok/sqlmw?status.svg)](https://godoc.org/github.com/ngrok/sqlmw)
1+
[![docs](https://pkg.go.dev/badge/github.com/ngrok/sqlmw?status.svg)](https://pkg.go.dev/github.com/ngrok/sqlmw)
22

33
# sqlmw
4+
45
sqlmw provides an absurdly simple API that allows a caller to wrap a `database/sql` driver
56
with middleware.
67

conn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (c wrappedParentConn) BeginTx(ctx context.Context, opts driver.TxOptions) (
129129
case <-ctx.Done():
130130
return nil, ctx.Err()
131131
default:
132-
return c.Conn.Begin()
132+
return c.Begin()
133133
}
134134
}
135135

@@ -142,7 +142,7 @@ func (c wrappedParentConn) PrepareContext(ctx context.Context, query string) (dr
142142
case <-ctx.Done():
143143
return nil, ctx.Err()
144144
default:
145-
return c.Conn.Prepare(query)
145+
return c.Prepare(query)
146146
}
147147
}
148148

conn_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func TestConnQueryContext_PassWrappedRowContext(t *testing.T) {
124124
}
125125

126126
rows.Next()
127-
rows.Close()
127+
_ = rows.Close()
128128

129129
if !ti.RowsCloseValid {
130130
t.Error("RowsClose context not valid")
@@ -169,7 +169,7 @@ func TestConnPrepareContext_PassWrappedStmtContext(t *testing.T) {
169169
t.Fatalf("Prepare failed: %s", err)
170170
}
171171

172-
stmt.Close()
172+
_ = stmt.Close()
173173

174174
if !ti.StmtCloseValid {
175175
t.Error("StmtClose context not valid")

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module github.com/ngrok/sqlmw
22

33
go 1.13
4+
5+
require github.com/magefile/mage v1.15.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
2+
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=

magefiles/mage.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//go:build mage
2+
3+
package main
4+
5+
import (
6+
"context"
7+
8+
"github.com/magefile/mage/sh"
9+
)
10+
11+
// Lint runs the linter
12+
func Lint(ctx context.Context) error {
13+
//args := []string{"tool", "-modfile=./.tools/go.mod", "github.com/golangci/golangci-lint/v2/cmd/golangci-lint", "run", "--config", ".golangci.yml"}
14+
args := []string{"run", "--config", ".golangci.yml"}
15+
return sh.RunV("golangci-lint", args...)
16+
}

0 commit comments

Comments
 (0)