From cbe862d7d3ffc18832b53a91acf0b8e6f6217401 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Wed, 17 Dec 2025 16:41:44 -0500 Subject: [PATCH] update to go1.25, node24, golangci-lint v2, trixie Considered pinning `gopls` again, but we want to be relatively up-to-date so figured I'd update things. I'm sure there's a better way to manage the node version, but this gets updated less than yearly so I'm not worried about it. Made a few tweaks to satisfy golangci-lint but nothing significant. fixes #482 --- .devcontainer/devcontainer.json | 2 +- .github/workflows/examples-autocomplete.yml | 6 ++++-- .github/workflows/examples-ref-browser.yml | 6 ++++-- .github/workflows/reference-converter.daily.yml | 2 ++ .github/workflows/reference-converter.yml | 2 +- .github/workflows/reference-lib.publish.yml | 2 +- .golangci.yml | 3 ++- reference-converter/go.mod | 2 +- reference-converter/internal/atom/atom.go | 2 +- reference-converter/internal/parse/link.go | 2 +- reference-converter/internal/tarball/tarball.go | 6 +++--- reference-converter/main.go | 2 +- tools/devtools/Dockerfile | 10 +++++----- 13 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index de0b84d..4d0bc86 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,7 @@ "build": { "dockerfile": "../tools/devtools/Dockerfile", "args": { - "BASE_IMG": "mcr.microsoft.com/devcontainers/typescript-node:18-bullseye" + "BASE_IMG": "mcr.microsoft.com/devcontainers/typescript-node:24-trixie" } }, "postCreateCommand": "sudo find . -name node_modules -exec chown node:node {} \\;", diff --git a/.github/workflows/examples-autocomplete.yml b/.github/workflows/examples-autocomplete.yml index c4c9817..3c9c392 100644 --- a/.github/workflows/examples-autocomplete.yml +++ b/.github/workflows/examples-autocomplete.yml @@ -2,10 +2,10 @@ name: builds the autocomplete example usage of reference-lib on: push: branches: ['main'] - paths: ['examples/autocomplete/**', 'reference-lib/**'] + paths: ['examples/autocomplete/**', '.github/workflows/examples-autocomplete.yml', 'reference-lib/**'] pull_request: branches: ['main'] - paths: ['examples/autocomplete/**', 'reference-lib/**'] + paths: ['examples/autocomplete/**', '.github/workflows/examples-autocomplete.yml', 'reference-lib/**'] defaults: run: @@ -18,6 +18,8 @@ jobs: steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v6 + with: + node-version: 24 - name: build the reference-lib working-directory: ./reference-lib run: | diff --git a/.github/workflows/examples-ref-browser.yml b/.github/workflows/examples-ref-browser.yml index 84aded4..c7cf7a7 100644 --- a/.github/workflows/examples-ref-browser.yml +++ b/.github/workflows/examples-ref-browser.yml @@ -2,10 +2,10 @@ name: builds the example ref-browser usage of reference-lib on: push: branches: ['main'] - paths: ['examples/ref-browser/**', 'reference-lib/**'] + paths: ['examples/ref-browser/**', '.github/workflows/examples-ref-browser.yml', 'reference-lib/**'] pull_request: branches: ['main'] - paths: ['examples/ref-browser/**', 'reference-lib/**'] + paths: ['examples/ref-browser/**', '.github/workflows/examples-ref-browser.yml', 'reference-lib/**'] defaults: run: @@ -18,6 +18,8 @@ jobs: steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v6 + with: + node-version: 24 - name: build the reference-lib working-directory: ./reference-lib run: | diff --git a/.github/workflows/reference-converter.daily.yml b/.github/workflows/reference-converter.daily.yml index a2cff72..21d8d9d 100644 --- a/.github/workflows/reference-converter.daily.yml +++ b/.github/workflows/reference-converter.daily.yml @@ -32,6 +32,8 @@ jobs: fi - uses: actions/setup-node@v6 + with: + node-version: 24 - name: update npm package version if: steps.diff.outputs.reference_change run: npm version patch --no-git-tag-version diff --git a/.github/workflows/reference-converter.yml b/.github/workflows/reference-converter.yml index d5443bc..be832d9 100644 --- a/.github/workflows/reference-converter.yml +++ b/.github/workflows/reference-converter.yml @@ -51,7 +51,7 @@ jobs: cache: false - name: use the same version of GOLANGCI_LINT_VERSION as devtools run: make devtools-versions >> "$GITHUB_ENV" - - uses: golangci/golangci-lint-action@v6 + - uses: golangci/golangci-lint-action@v9 with: working-directory: ${{ env.working-directory }} version: v${{ env.GOLANGCI_LINT_VERSION }} diff --git a/.github/workflows/reference-lib.publish.yml b/.github/workflows/reference-lib.publish.yml index 226217f..36f0336 100644 --- a/.github/workflows/reference-lib.publish.yml +++ b/.github/workflows/reference-lib.publish.yml @@ -19,8 +19,8 @@ jobs: - uses: actions/checkout@v5 - uses: actions/setup-node@v6 with: - node-version: '16.x' registry-url: 'https://registry.npmjs.org' + node-version: 24 - name: Install dependencies run: npm ci - name: Test it out diff --git a/.golangci.yml b/.golangci.yml index ea1a51e..d0a2f2c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,6 @@ +version: "2" linters: - # add non-default linters https://golangci-lint.run/usage/linters/#disabled-by-default + # add non-default linters https://golangci-lint.run/docs/linters/ enable: - bodyclose - errorlint diff --git a/reference-converter/go.mod b/reference-converter/go.mod index dfea9b0..42c8fcd 100644 --- a/reference-converter/go.mod +++ b/reference-converter/go.mod @@ -1,6 +1,6 @@ module github.com/nginxinc/nginx-directive-reference/reference-converter -go 1.24 +go 1.25 require ( github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62 diff --git a/reference-converter/internal/atom/atom.go b/reference-converter/internal/atom/atom.go index bcb8e90..d52fef6 100644 --- a/reference-converter/internal/atom/atom.go +++ b/reference-converter/internal/atom/atom.go @@ -47,7 +47,7 @@ func openURL(ctx context.Context, url string, client http.Client) ([]byte, error if err != nil { return nil, fmt.Errorf("unable to download %s: %w", url, err) } - defer res.Body.Close() + defer res.Body.Close() //nolint:errcheck // nothing to do about it if res.StatusCode != http.StatusOK { return nil, fmt.Errorf("unable to download %s: %s", url, res.Status) diff --git a/reference-converter/internal/parse/link.go b/reference-converter/internal/parse/link.go index 9fc8f91..3001e56 100644 --- a/reference-converter/internal/parse/link.go +++ b/reference-converter/internal/parse/link.go @@ -35,7 +35,7 @@ func (l *link) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { title = p.Name } - title = strings.Replace(title, "\n", " ", -1) + title = strings.ReplaceAll(title, "\n", " ") href := attrs["url"] if href == "" { diff --git a/reference-converter/internal/tarball/tarball.go b/reference-converter/internal/tarball/tarball.go index c073af5..2860d9e 100644 --- a/reference-converter/internal/tarball/tarball.go +++ b/reference-converter/internal/tarball/tarball.go @@ -59,7 +59,7 @@ func openURL(ctx context.Context, url string, client http.Client) ([]File, error if err != nil { return nil, fmt.Errorf("unabled to download %s: %w", url, err) } - defer res.Body.Close() + defer res.Body.Close() //nolint:errcheck // nothing to do about it if res.StatusCode != http.StatusOK { return nil, fmt.Errorf("unabled to download %s: %s", url, res.Status) } @@ -71,7 +71,7 @@ func openFile(ctx context.Context, path string) ([]File, error) { if err != nil { return nil, err } - defer f.Close() + defer f.Close() //nolint:errcheck // nothing to do about it return open(ctx, f, slog.With(slog.String("path", path))) } @@ -81,7 +81,7 @@ func open(ctx context.Context, raw io.Reader, log *slog.Logger) ([]File, error) if err != nil { return nil, err } - defer gz.Close() + defer gz.Close() //nolint:errcheck // nothing to do about it tr := tar.NewReader(gz) diff --git a/reference-converter/main.go b/reference-converter/main.go index c91551d..25b3de8 100644 --- a/reference-converter/main.go +++ b/reference-converter/main.go @@ -74,7 +74,7 @@ func runConverter() error { slog.ErrorContext(ctx, "failed to open dst", slog.Any("error", err)) return err } - defer dst.Close() + defer dst.Close() //nolint:errcheck // nothing to do about it if err := ref.Write(ctx, dst); err != nil { slog.ErrorContext(ctx, "failed to save", slog.Any("error", err)) return err diff --git a/tools/devtools/Dockerfile b/tools/devtools/Dockerfile index 8a04b0d..94d665e 100644 --- a/tools/devtools/Dockerfile +++ b/tools/devtools/Dockerfile @@ -1,12 +1,12 @@ -ARG GO_VERSION=1.24 -ARG NODE_VERSION=18 -ARG BASE_IMG=docker.io/library/node:${NODE_VERSION}-bullseye +ARG GO_VERSION=1.25 +ARG NODE_VERSION=24 +ARG BASE_IMG=docker.io/library/node:${NODE_VERSION}-trixie -FROM docker.io/library/golang:${GO_VERSION}-bullseye AS golang +FROM docker.io/library/golang:${GO_VERSION}-trixie AS golang ARG GO_JUNIT_REPORT_VERSION=latest ARG GOPLS_VERSION=latest ARG DELVE_VERSION=latest -ARG GOLANGCI_LINT_VERSION=1.64.8 +ARG GOLANGCI_LINT_VERSION=2.7.2 RUN go install github.com/jstemmer/go-junit-report/v2@${GO_JUNIT_REPORT_VERSION} \ && go install -v golang.org/x/tools/gopls@${GOPLS_VERSION} \