From 2bc2a5b7000d1e28fd332cd880169d7807ff6c9b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 30 Aug 2024 12:25:18 +0200 Subject: [PATCH 1/4] fix: linter are not always right --- .golangci.yml | 8 +++++++- pkg/repository/repository_update.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 04e179c..c64d661 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,7 +3,8 @@ run: linters-settings: govet: - shadow: true + enable: + - shadow gocyclo: min-complexity: 23 goconst: @@ -19,6 +20,11 @@ linters-settings: desc: not allowed - pkg: "github.com/pkg/errors" desc: Should be replaced by standard lib errors package + perfsprint: + err-error: true + errorf: true + sprintf1: true + strconcat: false linters: enable-all: true diff --git a/pkg/repository/repository_update.go b/pkg/repository/repository_update.go index 9323f4d..a885f6f 100644 --- a/pkg/repository/repository_update.go +++ b/pkg/repository/repository_update.go @@ -143,7 +143,7 @@ func (r *Repository) getUpdateAction(ctx context.Context, pr *github.PullRequest output, err := git.RawWithContext(ctx, "log", func(g *types.Cmd) { g.AddOptions("--oneline") g.AddOptions("--merges") - g.AddOptions(firstCommit.GetSHA() + "^..HEAD") + g.AddOptions(fmt.Sprintf("%s^..HEAD", firstCommit.GetSHA())) }) if err != nil { log.Ctx(ctx).Error().Err(err).Msg(output) From d31bd8d41f8eccb931a1def0664a56d0fe57637c Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 30 Aug 2024 12:25:54 +0200 Subject: [PATCH 2/4] chore: clean workflows --- .github/workflows/ci.yml | 12 ++---------- .github/workflows/go-cross.yml | 9 ++------- .github/workflows/release.yml | 15 ++++----------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b514290..5e6c5e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,19 +17,11 @@ jobs: CGO_ENABLED: 0 steps: - - # https://github.com/marketplace/actions/setup-go-environment - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v5 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - # https://github.com/marketplace/actions/checkout - - name: Check out code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Check and get dependencies run: | go mod tidy diff --git a/.github/workflows/go-cross.yml b/.github/workflows/go-cross.yml index 06e2370..8b55fe9 100644 --- a/.github/workflows/go-cross.yml +++ b/.github/workflows/go-cross.yml @@ -15,16 +15,11 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] steps: - # https://github.com/marketplace/actions/setup-go-environment - - name: Set up Go ${{ matrix.go-version }} - uses: actions/setup-go@v5 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - # https://github.com/marketplace/actions/checkout - - name: Checkout code - uses: actions/checkout@v4 - - name: Test run: go test -v -cover ./... diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2cc2943..185014e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,19 +13,12 @@ jobs: CGO_ENABLED: 0 steps: - - # https://github.com/marketplace/actions/setup-go-environment - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - # https://github.com/marketplace/actions/checkout - - name: Check out code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: fetch-depth: 0 - + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} - name: dockerhub-login uses: docker/login-action@v1 with: From 330bf6195f8fc5aa8f5ad17f3f574966ef3e9c28 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 30 Aug 2024 12:26:15 +0200 Subject: [PATCH 3/4] fix: goreleaser configuration --- .goreleaser.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.goreleaser.yml b/.goreleaser.yml index fcc180c..c2cc28a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,5 @@ project_name: lobicornis +version: 2 builds: - binary: lobicornis From 0ca5dd096f0d98d385ba1e93e5db6535ea4c3887 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 30 Aug 2024 12:28:06 +0200 Subject: [PATCH 4/4] chore: update to go1.23 --- .golangci.yml | 1 + Dockerfile | 2 +- buildx.Dockerfile | 2 +- go.mod | 18 ++++------ go.sum | 42 +++++++----------------- pkg/conf/config_test.go | 1 - pkg/repository/clone_test.go | 1 - pkg/repository/mjolnir_test.go | 1 - pkg/repository/repository_merge_test.go | 3 -- pkg/repository/repository_review_test.go | 2 -- pkg/search/search_test.go | 1 - 11 files changed, 22 insertions(+), 52 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c64d661..a5b0c8d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -29,6 +29,7 @@ linters-settings: linters: enable-all: true disable: + - exportloopref # Deprecated - execinquery # not relevant (SQL) - sqlclosecheck # not relevant (SQL) - rowserrcheck # not relevant (SQL) diff --git a/Dockerfile b/Dockerfile index 2f79502..c18a7a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN go mod download COPY . . RUN make build -FROM alpine:3.19 +FROM alpine:3.20 RUN apk --no-cache --no-progress add ca-certificates git \ && rm -rf /var/cache/apk/* diff --git a/buildx.Dockerfile b/buildx.Dockerfile index 0a87a35..03e68ef 100644 --- a/buildx.Dockerfile +++ b/buildx.Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.4 -FROM alpine:3.16 +FROM alpine:3.20 RUN apk --no-cache --no-progress add ca-certificates git \ && rm -rf /var/cache/apk/* diff --git a/go.mod b/go.mod index 2a1d168..042b9d9 100644 --- a/go.mod +++ b/go.mod @@ -1,25 +1,21 @@ module github.com/traefik/lobicornis/v3 -go 1.21 +go 1.23.0 require ( github.com/google/go-github/v58 v58.0.0 - github.com/ldez/go-git-cmd-wrapper/v2 v2.6.0 - github.com/rs/zerolog v1.31.0 - github.com/stretchr/testify v1.8.4 - golang.org/x/oauth2 v0.16.0 + github.com/ldez/go-git-cmd-wrapper/v2 v2.7.0 + github.com/rs/zerolog v1.33.0 + github.com/stretchr/testify v1.9.0 + golang.org/x/oauth2 v0.22.0 gopkg.in/yaml.v3 v3.0.1 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.31.0 // indirect + golang.org/x/sys v0.24.0 // indirect ) diff --git a/go.sum b/go.sum index 70f771e..8087f95 100644 --- a/go.sum +++ b/go.sum @@ -2,55 +2,37 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV 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= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v58 v58.0.0 h1:Una7GGERlF/37XfkPwpzYJe0Vp4dt2k1kCjlxwjIvzw= github.com/google/go-github/v58 v58.0.0/go.mod h1:k4hxDKEfoWpSqFlc8LTpGd9fu2KrV1YAa6Hi6FmDNY4= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -github.com/ldez/go-git-cmd-wrapper/v2 v2.6.0 h1:o5QIusOiH9phm1gY2UGO6JQjYSPFYbgFCcntOigBvMg= -github.com/ldez/go-git-cmd-wrapper/v2 v2.6.0/go.mod h1:whnaSah+AmezZS8vwp8FyFzEBHZCLKywWILUj5D8Jq0= +github.com/ldez/go-git-cmd-wrapper/v2 v2.7.0 h1:p+ddlPLvlBy15FCy8b9P5RkO81i+I2uIPWjaq6D1lO0= +github.com/ldez/go-git-cmd-wrapper/v2 v2.7.0/go.mod h1:0eUeas7XtKDPKQbB0KijfaMPbuQ/cIprtoTRiwaUoFg= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= +golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/pkg/conf/config_test.go b/pkg/conf/config_test.go index 74ccd32..73d38de 100644 --- a/pkg/conf/config_test.go +++ b/pkg/conf/config_test.go @@ -158,7 +158,6 @@ func TestLoad(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/repository/clone_test.go b/pkg/repository/clone_test.go index f320101..5f69788 100644 --- a/pkg/repository/clone_test.go +++ b/pkg/repository/clone_test.go @@ -181,7 +181,6 @@ func Test_makeRepositoryURL(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() url := makeRepositoryURL(test.url, test.ssh, test.token) diff --git a/pkg/repository/mjolnir_test.go b/pkg/repository/mjolnir_test.go index 984350b..f479b81 100644 --- a/pkg/repository/mjolnir_test.go +++ b/pkg/repository/mjolnir_test.go @@ -60,7 +60,6 @@ func Test_parseIssueFixes(t *testing.T) { mjolnir := newMjolnir(nil, "", "", true) for _, test := range testCases { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/repository/repository_merge_test.go b/pkg/repository/repository_merge_test.go index 63d64ea..d47961c 100644 --- a/pkg/repository/repository_merge_test.go +++ b/pkg/repository/repository_merge_test.go @@ -70,7 +70,6 @@ Goat port-salut st. agur blue cheese camembert de normandie manchego. } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -146,8 +145,6 @@ func TestRepository_getMergeMethod(t *testing.T) { } for i, test := range testCases { - test := test - i := i t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/repository/repository_review_test.go b/pkg/repository/repository_review_test.go index 50f9acc..0479866 100644 --- a/pkg/repository/repository_review_test.go +++ b/pkg/repository/repository_review_test.go @@ -41,8 +41,6 @@ func TestRepository_getMinReview(t *testing.T) { } for i, test := range testCases { - test := test - i := i t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/search/search_test.go b/pkg/search/search_test.go index c70ec26..56498e4 100644 --- a/pkg/search/search_test.go +++ b/pkg/search/search_test.go @@ -140,7 +140,6 @@ func TestFinder_GetCurrentPull(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel()