Skip to content

Commit

Permalink
chore: upgrade go to 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
hedhyw committed Jun 19, 2024
1 parent fda2b0c commit a712410
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21.4'
go-version: '1.22.4'
id: go

- name: Check out code into the Go module directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21.4'
go-version: '1.22.4'

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
Expand Down
14 changes: 3 additions & 11 deletions .golangci.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"bodyclose",
"wsl",
"funlen",
"maligned",
"exhaustivestruct",
"gci",
"wrapcheck",
"varnamelen",
Expand All @@ -18,20 +16,14 @@
"thelper",
"paralleltest",
"tagliatelle",
"scopelint",
"golint",
"interfacer",
"nonamedreturns",
"exhaustruct",
"nolintlint",
"deadcode",
"wastedassign",
"structcheck",
"varcheck",
"ifshort",
"nosnakecase",
"rowserrcheck",
"depguard"
"depguard",
"mnd",
"execinquery"
]
},
"linters-settings": {
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG GOLANG_DOCKER_TAG=1.21.4-alpine3.18
ARG ALPINE_DOCKER_TAG=3.18
ARG GOLANG_DOCKER_TAG=1.22.4-alpine3.19
ARG ALPINE_DOCKER_TAG=3.19

FROM golang:$GOLANG_DOCKER_TAG as builder

Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GOLANG_CI_LINT_VER:=v1.53.2
GOLANG_CI_LINT_VER:=v1.59.1
OUT_BIN?=${PWD}/bin/gherkingen
COVER_PACKAGES=./...
VERSION?=${shell git describe --tags}
Expand All @@ -11,8 +11,8 @@ build:
cmd/gherkingen/main.go
.PHONY: build

lint: bin/golangci-lint
./bin/golangci-lint run
lint: bin/golangci-lint-${GOLANG_CI_LINT_VER}
./bin/golangci-lint-${GOLANG_CI_LINT_VER} run
.PHONY: lint

test:
Expand All @@ -37,8 +37,9 @@ vendor:
go mod vendor
.PHONY: vendor

bin/golangci-lint:
bin/golangci-lint-${GOLANG_CI_LINT_VER}:
curl \
-sSfL \
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s $(GOLANG_CI_LINT_VER)
mv ./bin/golangci-lint ./bin/golangci-lint-${GOLANG_CI_LINT_VER}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hedhyw/gherkingen/v3

go 1.20
go 1.22

require (
github.com/cucumber/common/gherkin/go/v24 v24.1.0
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ github.com/hedhyw/semerr v0.6.7/go.mod h1:GqxYzQ0igy0bi6pc0e38FScn9rQk1n4l+PuVKl
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand All @@ -29,6 +31,7 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 0 additions & 14 deletions internal/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ func TestApplicationCommandLineTool(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -62,7 +60,6 @@ func TestApplicationCommandLineTool(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand All @@ -87,8 +84,6 @@ func TestApplicationCommandLineTool(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand All @@ -114,7 +109,6 @@ func TestApplicationCommandLineTool(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -147,8 +141,6 @@ func TestApplicationCommandLineToolCustom(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -177,8 +169,6 @@ func TestApplicationCommandLineToolCustom(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand All @@ -205,8 +195,6 @@ func TestApplicationCommandLineToolCustom(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -263,8 +251,6 @@ func TestApplicationCommandLineToolFailures(t *testing.T) {
}

for name, testCase := range testCases {
testCase := testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions internal/assets/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ func TestOpenTemplate(t *testing.T) {
}

for _, f := range files {
f := f

t.Run(f, func(t *testing.T) {
t.Parallel()

Expand Down
12 changes: 4 additions & 8 deletions internal/docplugin/goplugin/goaliaser/goaliaser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ func TestStringValue(t *testing.T) {

p := goaliaser.New()

for i, tc := range testCases {
i, tc := i, tc

t.Run(tc.In, func(t *testing.T) {
for i, testCase := range testCases {
t.Run(testCase.In, func(t *testing.T) {
t.Parallel()

got := p.StringValue(tc.In)
assert.Equal(t, tc.Exp, got, i)
got := p.StringValue(testCase.In)
assert.Equal(t, testCase.Exp, got, i)
})
}
}
Expand Down Expand Up @@ -200,8 +198,6 @@ func TestNameAlias(t *testing.T) {
p := goaliaser.New()

for i, tc := range testCases {
i, tc := i, tc

t.Run(tc.In, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions internal/docplugin/goplugin/goplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (p GoPlugin) walkStruct(
return fmt.Errorf("handling struct: %s: %w", rt.Name(), err)
}

for i := 0; i < rt.NumField(); i++ {
for i := range rt.NumField() {
if !rv.Field(i).CanInterface() {
continue
}
Expand All @@ -121,7 +121,7 @@ func (p GoPlugin) walkSlice(
) (err error) {
rt := rv.Type()

for i := 0; i < rv.Len(); i++ {
for i := range rv.Len() {
el := rv.Index(i)

if !el.CanInterface() {
Expand Down
16 changes: 7 additions & 9 deletions internal/docplugin/goplugin/goplugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func TestExample(t *testing.T) {

examples := make([]*model.TableRow, 0, count)

for i := 0; i < count; i++ {
for range count {
examples = append(examples, &model.TableRow{
Cells: []*model.TableCell{{
Value: "hello_world",
Expand Down Expand Up @@ -449,21 +449,19 @@ func TestParallel(t *testing.T) {

ctx := context.Background()

for _, tc := range [2]bool{true, false} {
tc := tc

t.Run(strconv.FormatBool(tc), func(t *testing.T) {
for _, testCase := range [2]bool{true, false} {
t.Run(strconv.FormatBool(testCase), func(t *testing.T) {
t.Parallel()

p := goplugin.New(goplugin.Args{
Parallel: tc,
Parallel: testCase,
})
doc := getExampleDocument()

if assert.NoError(t, p.Process(ctx, doc)) {
assert.Equal(t, tc, doc.Feature.PluginData["GoParallel"])
assert.Equal(t, tc, doc.Feature.Children[0].Scenario.PluginData["GoParallel"])
assert.Equal(t, tc, doc.Feature.Children[0].Rule.PluginData["GoParallel"])
assert.Equal(t, testCase, doc.Feature.PluginData["GoParallel"])
assert.Equal(t, testCase, doc.Feature.Children[0].Scenario.PluginData["GoParallel"])
assert.Equal(t, testCase, doc.Feature.Children[0].Rule.PluginData["GoParallel"])
}
})
}
Expand Down
26 changes: 11 additions & 15 deletions internal/docplugin/goplugin/gotype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ func TestDeterminateGoType(t *testing.T) {
Exp: goTypeString,
}}

for i, tc := range testCases {
i, tc := i, tc

t.Run(strings.Join(tc.In, "_"), func(t *testing.T) {
for i, testCase := range testCases {
t.Run(strings.Join(testCase.In, "_"), func(t *testing.T) {
t.Parallel()

got := determinateGoType(tc.In)
assert.Equal(t, tc.Exp, got, i)
got := determinateGoType(testCase.In)
assert.Equal(t, testCase.Exp, got, i)
})
}
}
Expand Down Expand Up @@ -123,19 +121,17 @@ func TestGoValue(t *testing.T) {
ExpGoType: goTypeFloat64,
}}

for i, tc := range testCases {
i, tc := i, tc

t.Run(string(tc.InGoType)+"_"+tc.In, func(t *testing.T) {
for i, testCase := range testCases {
t.Run(string(testCase.InGoType)+"_"+testCase.In, func(t *testing.T) {
t.Parallel()

gotVal, gotType := goValue(goaliaser.New(), tc.In, tc.InGoType)
if gotVal != tc.Exp {
t.Errorf("%d:\n\tin: %s\n\texp: %s\n\tgot: %s", i, tc.In, tc.Exp, gotVal)
gotVal, gotType := goValue(goaliaser.New(), testCase.In, testCase.InGoType)
if gotVal != testCase.Exp {
t.Errorf("%d:\n\tin: %s\n\texp: %s\n\tgot: %s", i, testCase.In, testCase.Exp, gotVal)
}

if gotType != tc.ExpGoType {
t.Errorf("%d:\n\tin: %s\n\texp: %s\n\tgot: %s", i, tc.In, tc.ExpGoType, gotType)
if gotType != testCase.ExpGoType {
t.Errorf("%d:\n\tin: %s\n\texp: %s\n\tgot: %s", i, testCase.In, testCase.ExpGoType, gotType)
}
})
}
Expand Down
12 changes: 5 additions & 7 deletions internal/generator/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestGenerateFailed(t *testing.T) {
}{{
OK: true,
Name: "ok",
Prepare: func(args *generator.Args) {},
Prepare: func(*generator.Args) {},
}, {
OK: false,
Name: "invalid_format",
Expand All @@ -50,10 +50,8 @@ func TestGenerateFailed(t *testing.T) {
},
}}

for _, tc := range testCases {
tc := tc

t.Run(tc.Name, func(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

args := generator.Args{
Expand All @@ -65,10 +63,10 @@ func TestGenerateFailed(t *testing.T) {
GenerateUUID: uuid.NewString,
}

tc.Prepare(&args)
testCase.Prepare(&args)

_, err := generator.Generate(args)
if tc.OK {
if testCase.OK {
assert.NoError(t, err)
} else {
assert.Error(t, err)
Expand Down
2 changes: 0 additions & 2 deletions internal/generator/golang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ func TestGenerateAssetTemplatesShouldNotFail(t *testing.T) {
require.NoError(t, err)

for _, tmpl := range templates {
tmpl := tmpl

t.Run(tmpl, func(t *testing.T) {
t.Parallel()

Expand Down
10 changes: 4 additions & 6 deletions internal/generator/raw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,20 @@ func TestGenerateRaw(t *testing.T) {
},
}

for _, tc := range testCases {
tc := tc

t.Run(tc.Template, func(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.Template, func(t *testing.T) {
t.Parallel()

gotDataRaw, err := generator.Generate(generator.Args{
Format: model.FormatRaw,
InputSource: exampleFeature,
TemplateSource: []byte(tc.Template),
TemplateSource: []byte(testCase.Template),
PackageName: "generated_test.go",
Plugin: requireNewPlugin(t),
GenerateUUID: uuid.NewString,
})
if assert.NoError(t, err) {
assert.Equal(t, tc.Exp, string(gotDataRaw))
assert.Equal(t, testCase.Exp, string(gotDataRaw))
}
})
}
Expand Down
Loading

0 comments on commit a712410

Please sign in to comment.