From 3e29b826b30ccedbee6f3d20e3a742285a8cd3f3 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 15 May 2022 21:47:36 -0300 Subject: [PATCH] Upgrade Go / Improve CI / Add linting --- .github/workflows/lint.yml | 24 ++++++++++++++++++++++++ .github/workflows/test.yml | 12 +++++++++--- Taskfile.yml | 13 ++++--------- go.mod | 25 ++++++++++++++++++++++++- gormigrate_test.go | 3 +-- 5 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..0f837f4 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,24 @@ +name: Lint + +on: + pull_request: + push: + tags: + - v* + branches: + - master + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + + - uses: actions/checkout@v3 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.46.1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b66aef7..1ba4b17 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,12 @@ name: Test -on: [push, pull_request] +on: + pull_request: + push: + tags: + - v* + branches: + - master jobs: test: @@ -8,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Task - uses: Arduino/actions/setup-taskfile@master + uses: arduino/setup-task@v1 - name: Check out code - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Test run: task docker diff --git a/Taskfile.yml b/Taskfile.yml index e7df141..72d85e5 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,21 +1,16 @@ -# https://taskfile.org +# https://taskfile.dev -version: '2' +version: '3' tasks: - dl-deps: - desc: Downloads cli dependencies - cmds: - - go get -u golang.org/x/lint/golint - go-get-all: cmds: - go get -t -tags 'sqlite postgresql mysql sqlserver' ./... lint: - desc: Runs golint on this project + desc: Runs golangci-lint cmds: - - golint . + - golangci-lint run test-sqlite: desc: Run tests for SQLite diff --git a/go.mod b/go.mod index 473ea48..c16491b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/go-gormigrate/gormigrate/v2 -go 1.15 +go 1.17 require ( github.com/joho/godotenv v1.4.0 @@ -11,3 +11,26 @@ require ( gorm.io/driver/sqlserver v1.3.1 gorm.io/gorm v1.23.4 ) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/denisenkom/go-mssqldb v0.12.0 // indirect + github.com/go-sql-driver/mysql v1.6.0 // indirect + github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect + github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188 // indirect + github.com/jackc/chunkreader/v2 v2.0.1 // indirect + github.com/jackc/pgconn v1.10.1 // indirect + github.com/jackc/pgio v1.0.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgproto3/v2 v2.2.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect + github.com/jackc/pgtype v1.9.1 // indirect + github.com/jackc/pgx/v4 v4.14.1 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.4 // indirect + github.com/mattn/go-sqlite3 v1.14.9 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/gormigrate_test.go b/gormigrate_test.go index 8189e2d..73773a8 100644 --- a/gormigrate_test.go +++ b/gormigrate_test.go @@ -2,7 +2,6 @@ package gormigrate import ( "errors" - "fmt" "testing" _ "github.com/joho/godotenv/autoload" @@ -409,7 +408,7 @@ func forEachDatabase(t *testing.T, fn func(database *gorm.DB), dialects ...strin for _, database := range databases { if len(dialects) > 0 && !contains(dialects, database.dialect) { - t.Skip(fmt.Sprintf("test is not supported by [%s] dialect", database.dialect)) + t.Skipf("test is not supported by [%s] dialect", database.dialect) } // Ensure defers are not stacked up for each DB