mirror of https://github.com/pressly/goose.git
Upgrade golangci-lint (#928)
parent
ed6d53eb80
commit
99d73b7c76
|
@ -21,7 +21,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version: "stable"
|
go-version: "stable"
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v6
|
uses: golangci/golangci-lint-action@v7
|
||||||
with:
|
with:
|
||||||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
||||||
version: latest
|
version: latest
|
||||||
|
|
|
@ -1,14 +1,31 @@
|
||||||
|
version: "2"
|
||||||
linters:
|
linters:
|
||||||
disable-all: true
|
default: none
|
||||||
enable:
|
enable:
|
||||||
# Default
|
|
||||||
- errcheck
|
- errcheck
|
||||||
- gosimple
|
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- staticcheck
|
|
||||||
- unused
|
|
||||||
- gofmt
|
|
||||||
# Added
|
|
||||||
- testifylint
|
|
||||||
- misspell
|
- misspell
|
||||||
|
- staticcheck
|
||||||
|
- testifylint
|
||||||
|
- unused
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -37,7 +37,7 @@ lint: tools
|
||||||
|
|
||||||
.PHONY: tools
|
.PHONY: tools
|
||||||
tools:
|
tools:
|
||||||
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
|
||||||
@go install github.com/mfridman/tparse@main
|
@go install github.com/mfridman/tparse@main
|
||||||
|
|
||||||
test-packages:
|
test-packages:
|
||||||
|
|
|
@ -18,7 +18,9 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flags.Parse(os.Args[1:])
|
if err := flags.Parse(os.Args[1:]); err != nil {
|
||||||
|
log.Fatalf("goose: failed to parse flags: %v", err)
|
||||||
|
}
|
||||||
args := flags.Args()
|
args := flags.Args()
|
||||||
|
|
||||||
if len(args) < 3 {
|
if len(args) < 3 {
|
||||||
|
|
|
@ -17,7 +17,7 @@ func TestNewGoMigration(t *testing.T) {
|
||||||
require.True(t, m.Registered)
|
require.True(t, m.Registered)
|
||||||
require.EqualValues(t, -1, m.Next)
|
require.EqualValues(t, -1, m.Next)
|
||||||
require.EqualValues(t, -1, m.Previous)
|
require.EqualValues(t, -1, m.Previous)
|
||||||
require.Equal(t, "", m.Source)
|
require.Empty(t, m.Source)
|
||||||
require.Nil(t, m.UpFnNoTxContext)
|
require.Nil(t, m.UpFnNoTxContext)
|
||||||
require.Nil(t, m.DownFnNoTxContext)
|
require.Nil(t, m.DownFnNoTxContext)
|
||||||
require.Nil(t, m.UpFnContext)
|
require.Nil(t, m.UpFnContext)
|
||||||
|
@ -136,7 +136,7 @@ func TestLegacyFunctions(t *testing.T) {
|
||||||
require.True(t, m.Registered)
|
require.True(t, m.Registered)
|
||||||
require.EqualValues(t, -1, m.Next)
|
require.EqualValues(t, -1, m.Next)
|
||||||
require.EqualValues(t, -1, m.Previous)
|
require.EqualValues(t, -1, m.Previous)
|
||||||
require.Equal(t, "", m.Source)
|
require.Empty(t, m.Source)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("all_tx", func(t *testing.T) {
|
t.Run("all_tx", func(t *testing.T) {
|
||||||
|
|
|
@ -25,11 +25,11 @@ func NewPostgresSessionLocker(opts ...SessionLockerOption) (SessionLocker, error
|
||||||
cfg := sessionLockerConfig{
|
cfg := sessionLockerConfig{
|
||||||
lockID: DefaultLockID,
|
lockID: DefaultLockID,
|
||||||
lockProbe: probe{
|
lockProbe: probe{
|
||||||
periodSeconds: 5 * time.Second,
|
intervalDuration: 5 * time.Second,
|
||||||
failureThreshold: 60,
|
failureThreshold: 60,
|
||||||
},
|
},
|
||||||
unlockProbe: probe{
|
unlockProbe: probe{
|
||||||
periodSeconds: 2 * time.Second,
|
intervalDuration: 2 * time.Second,
|
||||||
failureThreshold: 30,
|
failureThreshold: 30,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,11 @@ func NewPostgresSessionLocker(opts ...SessionLockerOption) (SessionLocker, error
|
||||||
lockID: cfg.lockID,
|
lockID: cfg.lockID,
|
||||||
retryLock: retry.WithMaxRetries(
|
retryLock: retry.WithMaxRetries(
|
||||||
cfg.lockProbe.failureThreshold,
|
cfg.lockProbe.failureThreshold,
|
||||||
retry.NewConstant(cfg.lockProbe.periodSeconds),
|
retry.NewConstant(cfg.lockProbe.intervalDuration),
|
||||||
),
|
),
|
||||||
retryUnlock: retry.WithMaxRetries(
|
retryUnlock: retry.WithMaxRetries(
|
||||||
cfg.unlockProbe.failureThreshold,
|
cfg.unlockProbe.failureThreshold,
|
||||||
retry.NewConstant(cfg.unlockProbe.periodSeconds),
|
retry.NewConstant(cfg.unlockProbe.intervalDuration),
|
||||||
),
|
),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ func WithLockTimeout(period, failureThreshold uint64) SessionLockerOption {
|
||||||
return errors.New("failure threshold must be greater than 0, minimum is 1")
|
return errors.New("failure threshold must be greater than 0, minimum is 1")
|
||||||
}
|
}
|
||||||
c.lockProbe = probe{
|
c.lockProbe = probe{
|
||||||
periodSeconds: time.Duration(period) * time.Second,
|
intervalDuration: time.Duration(period) * time.Second,
|
||||||
failureThreshold: failureThreshold,
|
failureThreshold: failureThreshold,
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -67,7 +67,7 @@ func WithUnlockTimeout(period, failureThreshold uint64) SessionLockerOption {
|
||||||
return errors.New("failure threshold must be greater than 0, minimum is 1")
|
return errors.New("failure threshold must be greater than 0, minimum is 1")
|
||||||
}
|
}
|
||||||
c.unlockProbe = probe{
|
c.unlockProbe = probe{
|
||||||
periodSeconds: time.Duration(period) * time.Second,
|
intervalDuration: time.Duration(period) * time.Second,
|
||||||
failureThreshold: failureThreshold,
|
failureThreshold: failureThreshold,
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -84,7 +84,7 @@ type sessionLockerConfig struct {
|
||||||
// total timeout will be the period times the failure threshold.
|
// total timeout will be the period times the failure threshold.
|
||||||
type probe struct {
|
type probe struct {
|
||||||
// How often (in seconds) to perform the probe.
|
// How often (in seconds) to perform the probe.
|
||||||
periodSeconds time.Duration
|
intervalDuration time.Duration
|
||||||
// Number of times to retry the probe.
|
// Number of times to retry the probe.
|
||||||
failureThreshold uint64
|
failureThreshold uint64
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ func TestCollectFileSources(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
got, err := collectFilesystemSources(f, false, nil, nil)
|
got, err := collectFilesystemSources(f, false, nil, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, len(got.sqlSources), len(sqlSources))
|
require.Len(t, sqlSources, len(got.sqlSources))
|
||||||
require.Empty(t, got.goSources)
|
require.Empty(t, got.goSources)
|
||||||
for i := 0; i < len(got.sqlSources); i++ {
|
for i := 0; i < len(got.sqlSources); i++ {
|
||||||
require.Equal(t, got.sqlSources[i], sqlSources[i])
|
require.Equal(t, got.sqlSources[i], sqlSources[i])
|
||||||
|
|
|
@ -187,7 +187,7 @@ func TestProviderRun(t *testing.T) {
|
||||||
// Apply all up migrations
|
// Apply all up migrations
|
||||||
upResult, err := p.Up(ctx)
|
upResult, err := p.Up(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, len(upResult), len(sources))
|
require.Len(t, sources, len(upResult))
|
||||||
currentVersion, err := p.GetDBVersion(ctx)
|
currentVersion, err := p.GetDBVersion(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, currentVersion, p.ListSources()[len(sources)-1].Version)
|
require.Equal(t, currentVersion, p.ListSources()[len(sources)-1].Version)
|
||||||
|
@ -207,7 +207,7 @@ func TestProviderRun(t *testing.T) {
|
||||||
// Apply all down migrations
|
// Apply all down migrations
|
||||||
downResult, err := p.DownTo(ctx, 0)
|
downResult, err := p.DownTo(ctx, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, len(downResult), len(sources))
|
require.Len(t, sources, len(downResult))
|
||||||
gotVersion, err := getMaxVersionID(db, goose.DefaultTablename)
|
gotVersion, err := getMaxVersionID(db, goose.DefaultTablename)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.EqualValues(t, 0, gotVersion)
|
require.EqualValues(t, 0, gotVersion)
|
||||||
|
|
|
@ -68,6 +68,6 @@ func TestGoMigrationByOne(t *testing.T) {
|
||||||
// running within a tx we expect none of the inserts to persist.
|
// running within a tx we expect none of the inserts to persist.
|
||||||
err = db.QueryRow("SELECT COUNT(*) FROM foo").Scan(&count)
|
err = db.QueryRow("SELECT COUNT(*) FROM foo").Scan(&count)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.EqualValues(t, 0, count)
|
require.Equal(t, 0, count)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue