diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml index 5a18916e..1cfc5c6a 100644 --- a/.github/workflows/ci-backend.yml +++ b/.github/workflows/ci-backend.yml @@ -32,7 +32,7 @@ jobs: - name: install go uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.23" - name: test and build backend run: | @@ -54,13 +54,13 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.58 + version: v1.61.0 working-directory: backend/app - name: golangci-lint on example directory uses: golangci/golangci-lint-action@v6 with: - version: v1.58 + version: v1.61.0 args: --config ../../.golangci.yml working-directory: backend/_example/memory_store diff --git a/Dockerfile b/Dockerfile index 01e0e06f..6bd06c8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,7 +45,7 @@ RUN \ echo 'Skip frontend build'; \ fi -FROM umputun/baseimage:buildgo-v1.13.0 as build-backend +FROM umputun/baseimage:buildgo-v1.14.0 as build-backend ARG CI ARG GITHUB_REF @@ -81,7 +81,7 @@ RUN \ echo "version=$version" && \ go build -o remark42 -ldflags "-X main.revision=${version} -s -w" ./app -FROM umputun/baseimage:app-v1.13.0 +FROM umputun/baseimage:app-v1.14.0 ARG GITHUB_SHA diff --git a/Dockerfile.artifacts b/Dockerfile.artifacts index 0d627d26..419dca68 100644 --- a/Dockerfile.artifacts +++ b/Dockerfile.artifacts @@ -19,7 +19,7 @@ WORKDIR /srv/frontend/apps/remark42/ COPY ./frontend/apps/remark42/ /srv/frontend/apps/remark42/ RUN pnpm build -FROM umputun/baseimage:buildgo-v1.13.0 as build-backend +FROM umputun/baseimage:buildgo-v1.14.0 as build-backend ARG GITHUB_TOKEN ARG GITHUB_REF diff --git a/backend/.golangci.yml b/backend/.golangci.yml index 5a9ed665..e6929d67 100644 --- a/backend/.golangci.yml +++ b/backend/.golangci.yml @@ -26,8 +26,8 @@ linters-settings: linters: enable: - bodyclose + - copyloopvar - dupl - - exportloopref - gochecknoinits - gocritic - gocyclo diff --git a/backend/_example/memory_store/Dockerfile b/backend/_example/memory_store/Dockerfile index d9abf6fa..f4f15cd8 100644 --- a/backend/_example/memory_store/Dockerfile +++ b/backend/_example/memory_store/Dockerfile @@ -1,11 +1,11 @@ -FROM umputun/baseimage:buildgo-v1.13.0 as build-backend +FROM umputun/baseimage:buildgo-v1.14.0 as build-backend ADD backend /build/backend WORKDIR /build/backend/_example/memory_store RUN go build -o /build/bin/memory_store -ldflags "-X main.revision=0.0.0 -s -w" -FROM umputun/baseimage:app-v1.13.0 +FROM umputun/baseimage:app-v1.14.0 ARG GITHUB_SHA diff --git a/backend/_example/memory_store/go.mod b/backend/_example/memory_store/go.mod index 9e7c34c2..f3a3e83e 100644 --- a/backend/_example/memory_store/go.mod +++ b/backend/_example/memory_store/go.mod @@ -1,6 +1,6 @@ module github.com/umputun/remark42/memory_store -go 1.21 +go 1.23 require ( github.com/go-pkgz/jrpc v0.3.0 @@ -36,7 +36,6 @@ require ( golang.org/x/image v0.22.0 // indirect golang.org/x/net v0.29.0 // indirect golang.org/x/sys v0.25.0 // indirect - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/backend/_example/memory_store/go.sum b/backend/_example/memory_store/go.sum index f605ebbd..93cbf3be 100644 --- a/backend/_example/memory_store/go.sum +++ b/backend/_example/memory_store/go.sum @@ -119,9 +119,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 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= diff --git a/backend/app/cmd/cleanup_test.go b/backend/app/cmd/cleanup_test.go index 05bbd678..4a102874 100644 --- a/backend/app/cmd/cleanup_test.go +++ b/backend/app/cmd/cleanup_test.go @@ -46,7 +46,6 @@ func TestCleanup_IsSpam(t *testing.T) { } for n, tt := range tbl { - tt := tt checkName := fmt.Sprintf("check-%d-%s", n, tt.name) t.Run(checkName, func(t *testing.T) { c := store.Comment{ID: checkName, Text: tt.text, Score: tt.score} diff --git a/backend/app/cmd/server_test.go b/backend/app/cmd/server_test.go index ff6664e7..9cd03c65 100644 --- a/backend/app/cmd/server_test.go +++ b/backend/app/cmd/server_test.go @@ -701,7 +701,6 @@ func TestServerCommand_parseSameSite(t *testing.T) { cmd := ServerCommand{} for i, tt := range tbl { - tt := tt t.Run(strconv.Itoa(i), func(t *testing.T) { assert.Equal(t, tt.res, cmd.parseSameSite(tt.inp)) }) diff --git a/backend/app/notify/email_test.go b/backend/app/notify/email_test.go index 622882d0..87f42ad4 100644 --- a/backend/app/notify/email_test.go +++ b/backend/app/notify/email_test.go @@ -88,7 +88,6 @@ func Test_initTemplatesErr(t *testing.T) { } for _, d := range testSet { - d := d t.Run(d.name, func(t *testing.T) { e, err := NewEmail(d.emailParams, ntf.SMTPParams{}) require.Error(t, err) diff --git a/backend/app/rest/api/rest_private_test.go b/backend/app/rest/api/rest_private_test.go index b9ba503d..cea721fb 100644 --- a/backend/app/rest/api/rest_private_test.go +++ b/backend/app/rest/api/rest_private_test.go @@ -916,7 +916,6 @@ func TestRest_EmailAndTelegram(t *testing.T) { client := http.Client{} defer client.CloseIdleConnections() for _, x := range testData { - x := x t.Run(x.description, func(t *testing.T) { reqBody := io.NopCloser(strings.NewReader(x.body)) if x.body == "" { diff --git a/backend/app/rest/api/rest_test.go b/backend/app/rest/api/rest_test.go index fb1f7ace..804e2c21 100644 --- a/backend/app/rest/api/rest_test.go +++ b/backend/app/rest/api/rest_test.go @@ -227,7 +227,6 @@ func Test_URLKey(t *testing.T) { } for i, tt := range tbl { - tt := tt t.Run(strconv.Itoa(i), func(t *testing.T) { r, err := http.NewRequest("GET", tt.url, http.NoBody) require.NoError(t, err) @@ -252,7 +251,6 @@ func Test_URLKeyWithUser(t *testing.T) { } for i, tt := range tbl { - tt := tt t.Run(strconv.Itoa(i), func(t *testing.T) { r, err := http.NewRequest("GET", tt.url, http.NoBody) require.NoError(t, err) @@ -279,7 +277,6 @@ func TestRest_parseError(t *testing.T) { } for n, tt := range tbl { - tt := tt t.Run(strconv.Itoa(n), func(t *testing.T) { res := parseError(tt.err, rest.ErrInternal) assert.Equal(t, tt.res, res) @@ -302,7 +299,6 @@ func TestRest_cacheControl(t *testing.T) { } for i, tt := range tbl { - tt := tt t.Run(strconv.Itoa(i), func(t *testing.T) { req := httptest.NewRequest("GET", tt.url, http.NoBody) w := httptest.NewRecorder() @@ -388,7 +384,6 @@ func TestRest_subscribersOnly(t *testing.T) { } for i, tt := range tbl { - tt := tt t.Run(strconv.Itoa(i), func(t *testing.T) { req := httptest.NewRequest("GET", "http://example.com", http.NoBody) if tt.setUser { diff --git a/backend/app/rest/proxy/image_test.go b/backend/app/rest/proxy/image_test.go index 0314b243..22c61f1b 100644 --- a/backend/app/rest/proxy/image_test.go +++ b/backend/app/rest/proxy/image_test.go @@ -77,7 +77,6 @@ func TestImage_Extract(t *testing.T) { img := Image{HTTP2HTTPS: true} for i, tt := range tbl { - tt := tt t.Run(strconv.Itoa(i), func(t *testing.T) { res, err := img.extract(tt.inp, func(src string) bool { return strings.HasPrefix(src, "http://") }) assert.NoError(t, err) diff --git a/backend/app/store/comment_test.go b/backend/app/store/comment_test.go index fe44817f..ce48d37e 100644 --- a/backend/app/store/comment_test.go +++ b/backend/app/store/comment_test.go @@ -209,7 +209,6 @@ func TestComment_Snippet(t *testing.T) { } for i, tt := range tbl { - tt := tt t.Run(strconv.Itoa(i), func(t *testing.T) { c := Comment{Text: tt.inp} out := c.Snippet(tt.limit) @@ -245,7 +244,6 @@ func TestComment_sanitizeAsURL(t *testing.T) { } for i, tt := range tbl { - tt := tt c := Comment{} t.Run(strconv.Itoa(i), func(t *testing.T) { assert.Equal(t, tt.out, c.SanitizeAsURL(tt.inp)) @@ -276,7 +274,6 @@ func TestComment_sanitizeText(t *testing.T) { } for i, tt := range tbl { - tt := tt c := Comment{} t.Run(strconv.Itoa(i), func(t *testing.T) { assert.Equal(t, tt.out, c.SanitizeText(tt.inp)) diff --git a/backend/app/store/engine/bolt.go b/backend/app/store/engine/bolt.go index 6e2abc7f..38b8e29b 100644 --- a/backend/app/store/engine/bolt.go +++ b/backend/app/store/engine/bolt.go @@ -865,7 +865,6 @@ func (b *BoltDB) deleteUser(bdb *bolt.DB, siteID, userID string, mode store.Dele // get list of commentID for all user's comment comments := []commentInfo{} for _, postInfo := range posts { - postInfo := postInfo err = bdb.View(func(tx *bolt.Tx) error { postsBkt := tx.Bucket([]byte(postsBucketName)) postBkt := postsBkt.Bucket([]byte(postInfo.URL)) diff --git a/backend/app/store/formatter_test.go b/backend/app/store/formatter_test.go index 0b954798..3e11f043 100644 --- a/backend/app/store/formatter_test.go +++ b/backend/app/store/formatter_test.go @@ -50,7 +50,6 @@ func TestFormatter_FormatText(t *testing.T) { } f := NewCommentFormatter(mockConverter{}) for _, tt := range tbl { - tt := tt t.Run(tt.name, func(t *testing.T) { raw := strings.HasPrefix(tt.in, `no_smartpants`) t.Logf("raw: %v", raw) @@ -146,7 +145,6 @@ func TestCommentFormatter_lazyImage(t *testing.T) { f := NewCommentFormatter(nil) for i, tt := range tbl { - tt := tt t.Run(strconv.Itoa(i), func(t *testing.T) { assert.Equal(t, tt.out, f.lazyImage(tt.inp)) }) diff --git a/backend/app/store/image/fs_store_test.go b/backend/app/store/image/fs_store_test.go index 1c5e564a..82083e4a 100644 --- a/backend/app/store/image/fs_store_test.go +++ b/backend/app/store/image/fs_store_test.go @@ -173,7 +173,6 @@ func TestFsStore_location(t *testing.T) { {0, "user/12345", "/tmp/user/12345"}, } for n, tt := range tbl { - tt := tt t.Run(strconv.Itoa(n), func(t *testing.T) { svc := FileSystem{Location: "/tmp", Partitions: tt.partitions} assert.Equal(t, tt.res, svc.location("/tmp", tt.id)) diff --git a/backend/app/store/image/image_test.go b/backend/app/store/image/image_test.go index baf9f9e5..edc616f4 100644 --- a/backend/app/store/image/image_test.go +++ b/backend/app/store/image/image_test.go @@ -259,7 +259,6 @@ func TestGetProportionalSizes(t *testing.T) { } for i, tt := range tbl { - tt := tt t.Run(strconv.Itoa(i), func(t *testing.T) { resW, resH := getProportionalSizes(tt.inpW, tt.inpH, tt.limitW, tt.limitH) assert.Equal(t, tt.resW, resW, "width") diff --git a/backend/app/store/service/service_test.go b/backend/app/store/service/service_test.go index 56ae8c10..1c203669 100644 --- a/backend/app/store/service/service_test.go +++ b/backend/app/store/service/service_test.go @@ -771,7 +771,6 @@ func TestService_Controversy(t *testing.T) { b := DataStore{} for i, tt := range tbl { - tt := tt t.Run(fmt.Sprintf("check-%d-%d:%d", i, tt.ups, tt.downs), func(t *testing.T) { assert.InDelta(t, tt.res, b.controversy(tt.ups, tt.downs), 0.01) }) diff --git a/backend/app/store/service/title_test.go b/backend/app/store/service/title_test.go index 5a949edd..3e362b33 100644 --- a/backend/app/store/service/title_test.go +++ b/backend/app/store/service/title_test.go @@ -31,7 +31,6 @@ func TestTitle_GetTitle(t *testing.T) { ex := NewTitleExtractor(http.Client{Timeout: 5 * time.Second}, []string{}) defer ex.Close() for i, tt := range tbl { - tt := tt t.Run(fmt.Sprintf("check-%d", i), func(t *testing.T) { title, ok := ex.getTitle(strings.NewReader(tt.page)) assert.Equal(t, tt.ok, ok) diff --git a/backend/go.mod b/backend/go.mod index 79717776..a40d7f54 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -1,6 +1,7 @@ module github.com/umputun/remark42/backend -go 1.21 +go 1.23 + toolchain go1.23.3 require (