diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 553fed5..4ef844f 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -14,18 +14,18 @@ jobs: steps: - name: Checkout GitHub Action - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version-file: ./go.mod cache-dependency-path: ./go.sum - name: Run golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v9 with: - version: v1.64.5 + version: v2.11.4 working-directory: ./ - name: Install dependencies diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3b36d8..60b8e0f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,20 +1,25 @@ name: deploy to ghcr.io on: + workflow_run: + workflows: ["audit"] + types: [completed] + tags: + - "*" push: - # run only against tags tags: - "*" permissions: contents: write + packages: write jobs: push-image: runs-on: ubuntu-latest steps: - name: Checkout GitHub Action - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Fetch tags run: git fetch --force --tags @@ -23,7 +28,7 @@ jobs: run: echo ${{github.ref_name}} - name: Login to GitHub Container Registry - uses: docker/login-action@v3 + uses: docker/login-action@v4 with: registry: ghcr.io username: ${{github.actor}} diff --git a/.golangci.yml b/.golangci.yml index ef8211d..a84190f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,49 +1,8 @@ +version: "2" run: concurrency: 4 - timeout: 5m - linters: - disable-all: - true - # Disabled linters: - # canonicalheader - # decorder - # dupword - # err113 - # exhaustruct - # forbidigo - # forcetypeassert # заменён на errcheck - # funlen - # ginkgolinter - # gofmt # заменён на goimports - # gofumpt # заменён на goimports - # goheader - # gomoddirectives - # gomodguard # используется более мощный depguard - # gosmopolitan - # grouper - # interfacebloat - # intrange - # ireturn - # lll - # loggercheck - # mirror - # misspell # бесполезный - # nonamedreturns - # nlreturn # слишком строгий и в основном код не более читабелен - # paralleltest # слишком много ложных срабатываний - # protogetter - # sloglint - # spancheck - # sqlclosecheck - # tagalign - # tenv # заменён на usetesting.os-setenv: true - # testableexamples - # testpackage - # varnamelen - # wastedassign - # wsl # слишком строгий и в основном код не более читабелен - # zerologlint + default: none enable: - asasalint - asciicheck @@ -64,7 +23,6 @@ linters: - exhaustive - exptostd - fatcontext - - gci - gocheckcompilerdirectives - gochecknoglobals - gochecknoinits @@ -75,18 +33,18 @@ linters: - gocyclo - godot - godox - - goimports - goprintffuncname - gosec - - gosimple - govet - iface - importas - inamedparam - ineffassign + - iotamixing - maintidx - makezero - - mnd # https://golangci-lint.run/usage/linters/#mnd + - mnd + - modernize - musttag - nakedret - nestif @@ -105,12 +63,10 @@ linters: - revive - rowserrcheck - staticcheck - - stylecheck - tagliatelle - testifylint - thelper - tparallel - - typecheck - unconvert - unparam - unused @@ -118,102 +74,117 @@ linters: - usetesting - whitespace - wrapcheck - -linters-settings: - cyclop: - max-complexity: 15 - skip-tests: true - depguard: - rules: - main: - list-mode: lax - deny: - - pkg: "github.com/pkg/errors" - desc: Should be replaced by standard lib errors package - - pkg: "github.com/golang/protobuf" - desc: "Use google.golang.org/protobuf instead, see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules" - errcheck: - check-type-assertions: true - errorlint: - errorf: false - exhaustive: - # Presence of "default" case in switch statements satisfies exhaustiveness, - # even if all enum members are not listed. - default-signifies-exhaustive: true - # Only run exhaustive check on switches with "//exhaustive:enforce" comment. - explicit-exhaustive-switch: true - gci: - sections: - - standard - - default - - prefix(geeksonator) - gocognit: - min-complexity: 10 - gocyclo: - min-complexity: 15 - goimports: - local-prefixes: capuchin - gosec: - excludes: - - G108 # Profiling endpoint automatically exposed on /debug/pprof - govet: - # Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers. - enable-all: true - disable: - - fieldalignment # Использовать при необходимости, ухудшается читаемость кода - - slog # На проекте используется zap - settings: - shadow: - strict: true - iface: - enable: - - identical - - unused - - opaque - nestif: - min-complexity: 4 - nolintlint: - require-explanation: true - require-specific: true - revive: - enable-all-rules: true + settings: + cyclop: + max-complexity: 15 + depguard: + rules: + main: + list-mode: lax + deny: + - pkg: github.com/pkg/errors + desc: Should be replaced by standard lib errors package + - pkg: github.com/golang/protobuf + desc: Use google.golang.org/protobuf instead, see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules + errcheck: + check-type-assertions: true + errorlint: + errorf: false + exhaustive: + default-signifies-exhaustive: true + explicit-exhaustive-switch: true + gocognit: + min-complexity: 10 + gocyclo: + min-complexity: 15 + gosec: + excludes: + - G108 + govet: + disable: + - fieldalignment + - slog + enable-all: true + settings: + shadow: + strict: true + iface: + enable: + - identical + - unused + - opaque + nestif: + min-complexity: 4 + nolintlint: + require-explanation: true + require-specific: true + revive: + enable-all-rules: true + rules: + - name: add-constant + disabled: true + - name: cognitive-complexity + disabled: true + - name: comment-spacings + disabled: true + - name: cyclomatic + disabled: true + - name: function-length + disabled: true + - name: line-length-limit + disabled: true + - name: max-public-structs + disabled: true + - name: unused-parameter + disabled: true + rowserrcheck: + packages: + - github.com/jmoiron/sqlx + tagliatelle: + case: + use-field-name: true + testifylint: + enable-all: true + disable: + - require-error + unparam: + check-exported: true + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling rules: - - name: add-constant - disabled: true - - name: cognitive-complexity - disabled: true - - name: comment-spacings - disabled: true - - name: cyclomatic - disabled: true - - name: function-length - disabled: true - - name: line-length-limit - disabled: true - - name: max-public-structs - disabled: true - - name: unused-parameter - disabled: true - rowserrcheck: - packages: - - github.com/jmoiron/sqlx - tagliatelle: - case: - use-field-name: true - testifylint: - enable-all: true - disable: - - require-error - unparam: - check-exported: true - + - linters: + - govet + text: '^shadow: declaration of "err" shadows declaration.+' + - linters: + - cyclop + path: (.+)_test\.go + paths: + - third_party$ + - builtin$ + - examples$ issues: - # Maximum count of issues with the same text. - # Set to 0 to disable. - # Default: 3 max-same-issues: 50 - - exclude-rules: - - linters: - - govet - text: '^shadow: declaration of "err" shadows declaration.+' +formatters: + enable: + - gci + - goimports + settings: + gci: + sections: + - standard + - default + - prefix(geeksonator) + goimports: + local-prefixes: + - capuchin + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/.tool-versions b/.tool-versions index aa63be9..24c4180 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -golang 1.23.6 -golangci-lint 1.64.5 +golang 1.25.8 +golangci-lint 2.11.4 diff --git a/Dockerfile b/Dockerfile index 74feef2..65d95c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ # STEP 1 build executable binary # ################################## -FROM golang:1.23.6-alpine as builder +FROM golang:1.25-alpine as builder LABEL org.opencontainers.image.source="https://github.com/phpgeeks-club/admin-bot" diff --git a/go.mod b/go.mod index 30b57a9..7fad80c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module geeksonator -go 1.23.6 +go 1.25 require ( github.com/caarlos0/env/v10 v10.0.0 diff --git a/internal/app/geeksonator/app.go b/internal/app/geeksonator/app.go index 8bd92a4..ff49730 100644 --- a/internal/app/geeksonator/app.go +++ b/internal/app/geeksonator/app.go @@ -95,10 +95,7 @@ func Start() error { var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - + wg.Go(func() { err = observerManager.Run(ctx) if err != nil { logger.Error("Observer manager Run error", @@ -108,7 +105,7 @@ func Start() error { return } logger.Info("Observer manager gracefully stopped") - }() + }) wg.Wait()