From 28ff28b29a1602189deeaba64bc71d8e09a2ca4e Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 27 Jun 2025 11:25:16 +0100 Subject: [PATCH] chore(ci/deps): upgrade CI dependencies and fix linting issues (#136) --- .github/release-please-config.json | 1 + .github/workflows/ci.yml | 18 +++-- .golangci.yml | 123 ++++++++++++++++------------- Makefile | 2 +- pkg/cask/update.go | 4 +- pkg/osinfo/osinfo.go | 7 +- 6 files changed, 85 insertions(+), 70 deletions(-) diff --git a/.github/release-please-config.json b/.github/release-please-config.json index 70af3c7..ab44fdd 100644 --- a/.github/release-please-config.json +++ b/.github/release-please-config.json @@ -1,5 +1,6 @@ { "bootstrap-sha": "3d6c7fff64bda8ba0dbea181c9f94fb9716dd188", + "always-update": true, "packages": { ".": { "release-type": "simple", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6955e01..e7b51bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,11 +10,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version-file: go.mod - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v8 with: - version: v1.61 + version: v2.1 env: VERBOSE: "true" @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version-file: go.mod - name: Check if mods are tidy run: make check-tidy @@ -36,14 +36,18 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version-file: go.mod - name: Run tests run: make test env: VERBOSE: "true" release-please: + name: Release Please runs-on: ubuntu-latest - if: github.ref_name == 'main' || github.ref_name == 'master' + if: ${{ github.ref_name == 'main' || github.ref_name == 'master' }} + permissions: + contents: read + pull-requests: write steps: - - uses: jimeh/release-please-manifest-action@v1 + - uses: jimeh/release-please-manifest-action@v2 diff --git a/.golangci.yml b/.golangci.yml index 5081642..697aaa6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,25 +1,9 @@ -linters-settings: - funlen: - lines: 100 - statements: 150 - goconst: - min-occurrences: 5 - gocyclo: - min-complexity: 20 - govet: - enable-all: true - disable: - - fieldalignment - lll: - line-length: 80 - tab-width: 4 - maligned: - suggest-new: true - misspell: - locale: US - +version: "2" +run: + modules-download-mode: readonly + allow-parallel-runners: true linters: - disable-all: true + default: none enable: - bodyclose - copyloopvar @@ -30,12 +14,8 @@ linters: - goconst - gocritic - gocyclo - - gofumpt - - goimports - - goprintffuncname - goprintffuncname - gosec - - gosimple - govet - ineffassign - lll @@ -47,36 +27,69 @@ linters: - revive - sqlclosecheck - staticcheck - - typecheck - unconvert - unused - whitespace - -issues: - exclude: - - Using the variable on range scope `tt` in function literal - - Using the variable on range scope `tc` in function literal - exclude-rules: - - path: "_test\\.go" - linters: - - funlen - - dupl - - goconst - - source: "^//go:generate " - linters: - - lll - - source: "`json:" - linters: - - lll - - source: "`yaml:" - linters: - - lll - exclude-dirs: - - builds - - sources - - tarballs - -run: - timeout: 2m - allow-parallel-runners: true - modules-download-mode: readonly + settings: + funlen: + lines: 100 + statements: 150 + goconst: + min-occurrences: 5 + gocyclo: + min-complexity: 20 + govet: + disable: + - fieldalignment + enable-all: true + lll: + line-length: 80 + tab-width: 4 + misspell: + locale: US + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - dupl + - funlen + - goconst + path: _test\.go + - linters: + - lll + source: "^//go:generate " + - linters: + - lll + source: "`json:" + - linters: + - lll + source: "`yaml:" + - path: (.+)\.go$ + text: Using the variable on range scope `tt` in function literal + - path: (.+)\.go$ + text: Using the variable on range scope `tc` in function literal + paths: + - builds + - sources + - tarballs + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofumpt + - goimports + exclusions: + generated: lax + paths: + - builds + - sources + - tarballs + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index 9336103..45b1a6c 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,7 @@ $(TOOLDIR)/$(1): Makefile endef $(eval $(call tool,gofumpt,mvdan.cc/gofumpt@latest)) -$(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61)) +$(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1)) $(eval $(call tool,gomod,github.com/Helcaraxan/gomod@latest)) .PHONY: tools diff --git a/pkg/cask/update.go b/pkg/cask/update.go index ea30929..c4b7df2 100644 --- a/pkg/cask/update.go +++ b/pkg/cask/update.go @@ -287,7 +287,7 @@ func (s *Updater) createRepoFile( s.logger.Info( "new commit created", "commit", contResp.GetSHA(), "message", contResp.GetMessage(), - "url", contResp.Commit.GetHTMLURL(), + "url", contResp.GetHTMLURL(), ) return nil @@ -354,7 +354,7 @@ func (s *Updater) updateRepoFile( s.logger.Info( "new commit created", "commit", contResp.GetSHA(), "message", contResp.GetMessage(), - "url", contResp.Commit.GetHTMLURL(), + "url", contResp.GetHTMLURL(), ) return true, nil diff --git a/pkg/osinfo/osinfo.go b/pkg/osinfo/osinfo.go index 823db27..903dff3 100644 --- a/pkg/osinfo/osinfo.go +++ b/pkg/osinfo/osinfo.go @@ -65,10 +65,7 @@ func (s *OSInfo) distinctVersion(version string) string { return parts[0] } - max := len(parts) - if max > 2 { - max = 2 - } + end := min(len(parts), 2) - return strings.Join(parts[0:max], ".") + return strings.Join(parts[0:end], ".") }