diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 28e984afb..8dc69059a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -20,8 +20,8 @@ jobs: fail-fast: true matrix: language: [ 'go' ] - os: [ 'ubuntu-22.04' ] - go-version: [1.22.x] + os: [ 'ubuntu-24.04' ] + go-version: [1.24.x] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/dockerfiles.yml b/.github/workflows/dockerfiles.yml index 1eba52099..d56b79509 100644 --- a/.github/workflows/dockerfiles.yml +++ b/.github/workflows/dockerfiles.yml @@ -24,7 +24,7 @@ jobs: [ "./build/docker/go-tools/Dockerfile", ] - runs-on: "ubuntu-22.04" + runs-on: "ubuntu-24.04" name: Lint ${{ matrix.dockerfile }} steps: - name: Checkout @@ -48,7 +48,7 @@ jobs: [ "go-tools", ] - runs-on: "ubuntu-22.04" + runs-on: "ubuntu-24.04" name: Build ${{ matrix.target }} steps: - name: Checkout diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a529903a4..f1a179df1 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -26,8 +26,8 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ "ubuntu-22.04" ] - go-version: [1.22.x] + os: [ "ubuntu-24.04" ] + go-version: [1.24.x] runs-on: ${{ matrix.os }} name: Build steps: @@ -86,8 +86,8 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ "ubuntu-22.04" ] - go-version: [1.22.x] + os: [ "ubuntu-24.04" ] + go-version: [1.24.x] runs-on: ${{ matrix.os }} name: Run Tests steps: @@ -141,8 +141,8 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ "ubuntu-22.04" ] - go-version: [1.22.x] + os: [ "ubuntu-24.04" ] + go-version: [1.24.x] runs-on: ${{ matrix.os }} name: Run linters steps: @@ -201,8 +201,8 @@ jobs: fail-fast: true max-parallel: 1 matrix: - os: [ "ubuntu-22.04" ] - go-version: [1.22.x] + os: [ "ubuntu-24.04" ] + go-version: [1.24.x] runs-on: ${{ matrix.os }} name: Quality reports steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eaf9b3578..deca16994 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,8 +13,8 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.22.x] + os: [ 'ubuntu-24.04' ] + go-version: [1.24.x] runs-on: ${{ matrix.os }} name: Build steps: @@ -67,8 +67,8 @@ jobs: fail-fast: false max-parallel: 2 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.22.x] + os: [ 'ubuntu-24.04' ] + go-version: [1.24.x] runs-on: ${{ matrix.os }} name: Regression tests steps: @@ -124,8 +124,8 @@ jobs: fail-fast: false max-parallel: 1 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.22.x] + os: [ 'ubuntu-24.04' ] + go-version: [1.24.x] runs-on: ${{ matrix.os }} name: Lint steps: @@ -185,8 +185,8 @@ jobs: fail-fast: false max-parallel: 1 matrix: - os: [ 'ubuntu-22.04' ] - go-version: [1.22.x] + os: [ 'ubuntu-24.04' ] + go-version: [1.24.x] runs-on: ${{ matrix.os }} name: Release steps: diff --git a/.golangci.pipe.yml b/.golangci.pipe.yml index cdedbff9f..b20bd1def 100644 --- a/.golangci.pipe.yml +++ b/.golangci.pipe.yml @@ -5,6 +5,8 @@ linters: - gofmt - revive - goimports + - unused + - gosimple linters-settings: errcheck: @@ -97,16 +99,16 @@ issues: run: issues-exit-code: 1 tests: true - skip-dirs: + exclude-dirs: - vendor/ - skip-files: + exclude-files: - \.pb\.go$ # output configuration options output: # colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions # default is "colored-line-number" - format: github-actions + formats: github-actions # print lines of code with issue, default is true print-issued-lines: true @@ -122,3 +124,5 @@ output: # sorts results by: filepath, line and column sort-results: true + + diff --git a/.golangci.yml b/.golangci.yml index 38f23ca45..1547b55c9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,19 +1,41 @@ linters-settings: depguard: - list-type: blacklist - packages: - # logging is allowed only by logutils.Log, logrus - # is allowed to use only in logutils package - - github.com/sirupsen/logrus - packages-with-error-message: - - github.com/sirupsen/logrus: "logging is allowed only by github.com/obalunenko/logger" + # new configuration + rules: + logger: + deny: + - pkg: "github.com/sirupsen/logrus" + desc: logging is allowed only by github.com/obalunenko/logger dupl: threshold: 100 funlen: lines: 100 statements: 50 gci: - local-prefixes: github.com/obalunenko/instadiff-cli + # Section configuration to compare against. + # Section names are case-insensitive and may contain parameters in (). + # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`, + # If `custom-order` is `true`, it follows the order of `sections` option. + # Default: ["standard", "default"] + sections: + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. + - prefix(github.com/obalunenko) # Custom section: groups all imports with the specified Prefix. + - localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled. + + # Skip generated files. + # Default: true + skip-generated: true + + # Enable custom order of sections. + # If `true`, make the section order the same as the order of `sections`. + # Default: false + custom-order: true + + # Drops lexical ordering for custom sections. + # Default: false + no-lex-order: true + goconst: min-len: 2 min-occurrences: 2 @@ -30,18 +52,132 @@ linters-settings: - hugeParam - octalLiteral - wrapperFunc - - sloppyReassign gocyclo: min-complexity: 15 goimports: local-prefixes: github.com/obalunenko/instadiff-cli - gomnd: - settings: - mnd: - # don't include the "operation" and "assign" - checks: [ argument,case,condition,return ] + mnd: + # List of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. + # Default: ["argument", "case", "condition", "operation", "return", "assign"] + checks: + - argument + - case + - condition + - operation + - return + - assign + # List of numbers to exclude from analysis. + # The numbers should be written as string. + # Values always ignored: "1", "1.0", "0" and "0.0" + # Default: [] + ignored-numbers: [] + # List of file patterns to exclude from analysis. + # Values always ignored: `.+_test.go` + # Default: [] + ignored-files: [] + # List of function patterns to exclude from analysis. + # Following functions are always ignored: `time.Date`, + # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`, + # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`. + # Default: [] + ignored-functions: [] + govet: - check-shadowing: true + # Disable all analyzers. + # Default: false + disable-all: false + # Enable analyzers by name. + # (in addition to default: + # appends, asmdecl, assign, atomic, bools, buildtag, cgocall, composites, copylocks, defers, directive, errorsas, + # framepointer, httpresponse, ifaceassert, loopclosure, lostcancel, nilfunc, printf, shift, sigchanyzer, slog, + # stdmethods, stringintconv, structtag, testinggoroutine, tests, timeformat, unmarshal, unreachable, unsafeptr, + # unusedresult + # ). + # Run `GL_DEBUG=govet golangci-lint run --enable=govet` to see default, all available analyzers, and enabled analyzers. + # Default: [] + disable: + - fieldalignment + enable: + # Check for missing values after append. + - appends + # Report mismatches between assembly files and Go declarations. + - asmdecl + # Check for useless assignments. + - assign + # Check for common mistakes using the sync/atomic package. + - atomic + # Check for non-64-bits-aligned arguments to sync/atomic functions. + - atomicalign + # Check for common mistakes involving boolean operators. + - bools + # Check //go:build and // +build directives. + - buildtag + # Detect some violations of the cgo pointer passing rules. + - cgocall + # Check for unkeyed composite literals. + - composites + # Check for locks erroneously passed by value. + - copylocks + # Check for calls of reflect.DeepEqual on error values. + - deepequalerrors + # Report common mistakes in defer statements. + - defers + # Check Go toolchain directives such as //go:debug. + - directive + # Report passing non-pointer or non-error values to errors.As. + - errorsas + # Find calls to a particular function. + - findcall + # Report assembly that clobbers the frame pointer before saving it. + - framepointer + # Check for mistakes using HTTP responses. + - httpresponse + # Detect impossible interface-to-interface type assertions. + - ifaceassert + # Check references to loop variables from within nested functions. + - loopclosure + # Check cancel func returned by context.WithCancel is called. + - lostcancel + # Check for useless comparisons between functions and nil. + - nilfunc + # Check for redundant or impossible nil comparisons. + - nilness + # Check consistency of Printf format strings and arguments. + - printf + # Check for comparing reflect.Value values with == or reflect.DeepEqual. + - reflectvaluecompare + # Check for possible unintended shadowing of variables. + - shadow + # Check for shifts that equal or exceed the width of the integer. + - shift + # Check for unbuffered channel of os.Signal. + - sigchanyzer + # Check for invalid structured logging calls. + - slog + # Check the argument type of sort.Slice. + - sortslice + # Check signature of methods of well-known interfaces. + - stdmethods + # Check for string(int) conversions. + - stringintconv + # Check that struct field tags conform to reflect.StructTag.Get. + - structtag + # Report calls to (*testing.T).Fatal from goroutines started by a test. + - testinggoroutine + # Check for common mistaken usages of tests and examples. + - tests + # Check for calls of (time.Time).Format or time.Parse with 2006-02-01. + - timeformat + # Report passing non-pointer or non-interface values to unmarshal. + - unmarshal + # Check for unreachable code. + - unreachable + # Check for invalid conversions of uintptr to unsafe.Pointer. + - unsafeptr + # Check for unused results of calls to some functions. + - unusedresult + # Checks for unused writes. + - unusedwrite lll: line-length: 140 misspell: @@ -56,13 +192,11 @@ linters: disable-all: true enable: - bodyclose - - deadcode - depguard - dogsled - dupl - errcheck - - exportloopref - - exhaustive + - copyloopvar - funlen - gochecknoinits - goconst @@ -70,7 +204,7 @@ linters: - gocyclo - gofmt - goimports - - gomnd + - mnd - goprintffuncname - gosec - gosimple @@ -83,13 +217,11 @@ linters: - nolintlint - rowserrcheck - staticcheck - - structcheck - stylecheck - typecheck - unconvert - unparam - unused - - varcheck - whitespace - revive - wsl @@ -109,6 +241,21 @@ linters: # - testpackage issues: + # make issues output unique by line, default is true + uniq-by-line: true + # Show only new issues: if there are unstaged changes or untracked files, + # only those changes are analyzed, else only changes in HEAD~ are analyzed. + # It's a super-useful option for integration of golangci-lint into existing + # large codebase. It's not practical to fix all existing issues at the moment + # of integration: much better don't allow issues in new code. + # Default is false. + new: false + # Fix found issues (if it's supported by the linter) + fix: false + exclude-files: + - \.pb\.go$ + exclude-dirs: + - vendor/ exclude-use-default: false exclude: # for "public interface + private struct implementation" cases only! @@ -123,74 +270,78 @@ issues: - funlen - dupl - gosec - - path: internal/input/ - linters: - - gocyclo - - funlen - - godot - - godox - - dupl - - gofmt - - gci - - gofumpt - - goimports - - gosimple - - path: internal/puzzles/constants.go - linters: - - revive - - path: internal/puzzles/solutions/ - linters: - - gochecknoinits - - # Show only new issues: if there are unstaged changes or untracked files, - # only those changes are analyzed, else only changes in HEAD~ are analyzed. - # It's a super-useful option for integration of golangci-lint into existing - # large codebase. It's not practical to fix all existing issues at the moment - # of integration: much better don't allow issues in new code. - # Default is false. - new: true - - # Fix found issues (if it's supported by the linter) - fix: false - - severity: - # Default value is empty string. - # Set the default severity for issues. If severity rules are defined and the issues - # do not match or no severity is provided to the rule this will be the default - # severity applied. Severities should match the supported severity names of the - # selected out format. - # - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity - # - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity - # - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message - default-severity: error - - # The default value is false. - # If set to true severity-rules regular expressions become case sensitive. - case-sensitive: false - - # Default value is empty list. - # When a list of severity rules are provided, severity information will be added to lint - # issues. Severity rules have the same filtering capability as exclude rules except you - # are allowed to specify one matcher per severity rule. - # Only affects out formats that support setting severity information. - rules: - - linters: - - dupl - severity: warning run: issues-exit-code: 0 tests: true - skip-dirs: - - vendor/ - skip-files: - - \.pb\.go$ + +severity: + # Set the default severity for issues. + # + # If severity rules are defined and the issues do not match or no severity is provided to the rule + # this will be the default severity applied. + # Severities should match the supported severity names of the selected out format. + # - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity + # - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#SeverityLevel + # - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message + # - TeamCity: https://www.jetbrains.com/help/teamcity/service-messages.html#Inspection+Instance + # + # `@linter` can be used as severity value to keep the severity from linters (e.g. revive, gosec, ...) + # + # Default: "" + default-severity: error + + # If set to true `severity-rules` regular expressions become case-sensitive. + # Default: false + case-sensitive: true + + # When a list of severity rules are provided, severity information will be added to lint issues. + # Severity rules have the same filtering capability as exclude rules + # except you are allowed to specify one matcher per severity rule. + # + # `@linter` can be used as severity value to keep the severity from linters (e.g. revive, gosec, ...) + # + # Only affects out formats that support setting severity information. + # + # Default: [] + rules: + - linters: + - dupl + severity: info + # output configuration options output: # colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions # default is "colored-line-number" - format: checkstyle + formats: + - format: colored-line-number + path: stderr + - format: checkstyle + path: linters-report.xml + + + # Order to use when sorting results. + # Require `sort-results` to `true`. + # Possible values: `file`, `linter`, and `severity`. + # + # If the severity values are inside the following list, they are ordered in this order: + # 1. error + # 2. warning + # 3. high + # 4. medium + # 5. low + # Either they are sorted alphabetically. + # + # Default: ["file"] + sort-order: + - linter + - severity + - file # filepath, line, and column. + + # Show statistics per linter. + # Default: false + show-stats: true # print lines of code with issue, default is true print-issued-lines: true @@ -198,9 +349,6 @@ output: # print linter name in the end of issue text, default is true print-linter-name: true - # make issues output unique by line, default is true - uniq-by-line: true - # add a prefix to the output file references; default is no prefix path-prefix: "" diff --git a/.goreleaser.yml b/.goreleaser.yml index af4dfadbf..cff5442aa 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,5 @@ +version: 2 + release: github: owner: obalunenko @@ -16,32 +18,31 @@ gomod: - CGO_ENABLED=0 # Which Go binary to use. # Defaults to `go`. + mod: vendor gobinary: go -before: - hooks: - - go mod verify - builds: - id: cli binary: instadiff-cli goos: - - "linux" - - "darwin" - - "windows" + - 'linux' + - 'darwin' + - 'windows' goarch: - - "386" - - "amd64" - - "arm" - - "arm64" + - 'amd64' + - 'arm' + - 'arm64' + ignore: + - goos: darwin + goarch: 'arm' + mod_timestamp: '{{ .CommitTimestamp }}' env: - CGO_ENABLED=0 main: ./cmd/instadiff-cli flags: - -trimpath - ldflags: - - "{{ .Env.GO_BUILD_LDFLAGS }}" + universal_binaries: - # ID of the source build # @@ -65,11 +66,13 @@ archives: - id: cli builds: - cli - format: tar.gz + formats: + - tar.gz wrap_in_directory: true format_overrides: - goos: windows - format: zip + formats: + - zip name_template: "{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" files: - LICENSE @@ -78,7 +81,7 @@ checksum: name_template: "{{ .ProjectName }}-{{ .Version }}-checksums.txt" snapshot: - name_template: SNAPSHOT-{{ .Commit }} + version_template: SNAPSHOT-{{ .Commit }} changelog: sort: asc diff --git a/Makefile b/Makefile index f06775d39..9dc30ac59 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1)) APP_NAME?=instadiff-cli SHELL := env APP_NAME=$(APP_NAME) $(SHELL) -GOVERSION:=1.22 +GOVERSION:=1.24 COMPOSE_TOOLS_FILE=deployments/docker-compose/go-tools-docker-compose.yml COMPOSE_TOOLS_CMD_BASE=docker compose -f $(COMPOSE_TOOLS_FILE) diff --git a/build/docker/go-tools/Dockerfile b/build/docker/go-tools/Dockerfile index ba31959fd..fccc246ab 100644 --- a/build/docker/go-tools/Dockerfile +++ b/build/docker/go-tools/Dockerfile @@ -1,3 +1,3 @@ -FROM ghcr.io/obalunenko/go-tools:v1.4.0 AS builder +FROM ghcr.io/obalunenko/go-tools:v1.7.0 AS builder CMD ["/bin/sh", "-c", ""] diff --git a/cmd/instadiff-cli/commands.go b/cmd/instadiff-cli/commands.go index b2d0bbdb3..974581d0c 100644 --- a/cmd/instadiff-cli/commands.go +++ b/cmd/instadiff-cli/commands.go @@ -1,86 +1,84 @@ package main import ( - "context" - "github.com/urfave/cli/v2" ) -func commands(ctx context.Context) []*cli.Command { +func commands() []*cli.Command { return []*cli.Command{ { Name: "list-followers", Aliases: []string{"followers"}, Usage: "List your followers", - Action: executeCmd(ctx, cmdListFollowers), + Action: executeCmd(cmdListFollowers), Flags: []cli.Flag{addListFlag()}, }, { Name: "list-followings", Aliases: []string{"followings"}, Usage: "List your followings", - Action: executeCmd(ctx, cmdListFollowings), + Action: executeCmd(cmdListFollowings), Flags: []cli.Flag{addListFlag()}, }, { Name: "clean-followings", Aliases: []string{"clean", "unfollow-unmutual", "remove-unmutual", "rm-unmutual"}, Usage: "Un follow not mutual followings, except of whitelisted", - Action: executeCmd(ctx, cmdCleanFollowings), + Action: executeCmd(cmdCleanFollowings), }, { Name: "remove-followers", Aliases: []string{"rm", "remove"}, Usage: "Remove a list of followers, by username.", - Action: executeCmd(ctx, cmdRemoveFollowers), + Action: executeCmd(cmdRemoveFollowers), Flags: []cli.Flag{addUsersFlag()}, }, { Name: "unfollow-users", Aliases: []string{"unfollow", "remove-followings"}, Usage: "Unfollow a list of followings, by username.", - Action: executeCmd(ctx, cmdUnfollowUsers), + Action: executeCmd(cmdUnfollowUsers), Flags: []cli.Flag{addUsersFlag()}, }, { Name: "follow-users", Aliases: []string{"follow", "add-followings"}, Usage: "Follow a list of followings, by username.", - Action: executeCmd(ctx, cmdFollowUsers), + Action: executeCmd(cmdFollowUsers), Flags: []cli.Flag{addUsersFlag()}, }, { Name: "list-unmutual", Aliases: []string{"unmutual"}, Usage: "List all not mutual followings", - Action: executeCmd(ctx, cmdListNotMutual), + Action: executeCmd(cmdListNotMutual), Flags: []cli.Flag{addListFlag()}, }, { Name: "list-useless", Aliases: []string{"useless, bots"}, Usage: "List all statistic-useless accounts (bots, business accounts or mass-followers) (alpha)", - Action: executeCmd(ctx, cmdListUseless), + Action: executeCmd(cmdListUseless), Flags: []cli.Flag{addListFlag()}, }, { Name: "list-diff", Aliases: []string{"diff"}, Usage: "List diff for account (lost and new followers and followings)", - Action: executeCmd(ctx, cmdListDiff), + Action: executeCmd(cmdListDiff), Flags: []cli.Flag{addListFlag()}, }, { Name: "diff-history", Aliases: []string{"history"}, Usage: "List diff account history (lost and new followers and followings)", - Action: executeCmd(ctx, cmdListHistoryDiff), + Action: executeCmd(cmdListHistoryDiff), }, { Name: "upload", Aliases: []string{"u"}, Usage: "Upload media to profile", - Action: executeCmd(ctx, cmdUploadMedia), + Action: executeCmd(cmdUploadMedia), Flags: uploadMediaFlags(), }, } diff --git a/cmd/instadiff-cli/handlers.go b/cmd/instadiff-cli/handlers.go index 8567e988b..25589955a 100644 --- a/cmd/instadiff-cli/handlers.go +++ b/cmd/instadiff-cli/handlers.go @@ -21,21 +21,21 @@ import ( "github.com/obalunenko/instadiff-cli/internal/utils" ) -func notFound(ctx context.Context) cli.CommandNotFoundFunc { +func notFound() cli.CommandNotFoundFunc { return func(c *cli.Context, command string) { if _, err := fmt.Fprintf( c.App.Writer, "Command [%s] not supported.\nTry --help flag to see how to use it\n", command, ); err != nil { - log.WithError(ctx, err).Fatal("Failed to print not found message") + log.WithError(c.Context, err).Fatal("Failed to print not found message") } } } -func onExit(ctx context.Context) cli.AfterFunc { +func onExit() cli.AfterFunc { return func(c *cli.Context) error { - log.Info(ctx, "Exit...") + log.Info(c.Context, "Exit...") return nil } @@ -43,9 +43,9 @@ func onExit(ctx context.Context) cli.AfterFunc { type cmdFunc func(c *cli.Context, svc *service.Service) error -func executeCmd(ctx context.Context, f cmdFunc) cli.ActionFunc { +func executeCmd(f cmdFunc) cli.ActionFunc { return func(c *cli.Context) error { - ctx = log.ContextWithLogger(c.Context, log.FromContext(c.Context).WithField("cmd", c.Command.Name)) + ctx := log.ContextWithLogger(c.Context, log.FromContext(c.Context).WithField("cmd", c.Command.Name)) c.Context = ctx diff --git a/cmd/instadiff-cli/main.go b/cmd/instadiff-cli/main.go index c08f8340c..d39762210 100644 --- a/cmd/instadiff-cli/main.go +++ b/cmd/instadiff-cli/main.go @@ -39,10 +39,10 @@ func main() { }} app.Version = printVersion(ctx) app.Flags = globalFlags() - app.Commands = commands(ctx) - app.CommandNotFound = notFound(ctx) - app.After = onExit(ctx) - app.Before = printHeader(ctx) + app.Commands = commands() + app.CommandNotFound = notFound() + app.After = onExit() + app.Before = printHeader() if err := app.RunContext(ctx, os.Args); err != nil { log.WithError(ctx, err).Fatal("Failed to run") diff --git a/cmd/instadiff-cli/version.go b/cmd/instadiff-cli/version.go index 8effe36ac..ac168a198 100644 --- a/cmd/instadiff-cli/version.go +++ b/cmd/instadiff-cli/version.go @@ -37,7 +37,7 @@ func printVersion(ctx context.Context) string { version.GetBuildDate(), ) if err != nil { - log.WithError(ctx, err).Error("print version") + log.WithError(ctx, err).Fatal("print version") } if err := w.Flush(); err != nil { @@ -47,7 +47,7 @@ func printVersion(ctx context.Context) string { return buf.String() } -func printHeader(_ context.Context) cli.BeforeFunc { +func printHeader() cli.BeforeFunc { const ( padding int = 1 minWidth int = 0 diff --git a/deployments/docker-compose/go-tools-docker-compose.yml b/deployments/docker-compose/go-tools-docker-compose.yml index f54563020..f6ea34220 100755 --- a/deployments/docker-compose/go-tools-docker-compose.yml +++ b/deployments/docker-compose/go-tools-docker-compose.yml @@ -1,5 +1,3 @@ -version: '3' - services: tools: build: @@ -63,7 +61,7 @@ services: go-generate: extends: service: tools - entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/codegen/go-generate.sh' + entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/codegen/generate.sh' build: extends: diff --git a/go.mod b/go.mod index d4b847016..e9e032620 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,17 @@ module github.com/obalunenko/instadiff-cli -go 1.22 +go 1.24 -toolchain go1.22.0 +toolchain go1.24.0 require ( github.com/Davincible/goinsta/v3 v3.2.6 github.com/briandowns/spinner v1.23.2 github.com/disintegration/imaging v1.6.2 github.com/hashicorp/go-multierror v1.1.1 - github.com/obalunenko/getenv v1.13.0 - github.com/obalunenko/logger v1.1.0 - github.com/obalunenko/version v1.2.0 + github.com/obalunenko/getenv v1.14.0 + github.com/obalunenko/logger v1.2.0 + github.com/obalunenko/version v1.3.1 github.com/olegfedoseev/image-diff v0.0.0-20171116094004-897a4e73dfd6 github.com/ory/dockertest/v3 v3.11.0 github.com/schollz/progressbar/v3 v3.18.0 diff --git a/go.sum b/go.sum index 45bfafa7c..6462413c4 100644 --- a/go.sum +++ b/go.sum @@ -106,12 +106,12 @@ github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/obalunenko/getenv v1.13.0 h1:KE6Kky3OMLkvOgzfZkaOjodnnMawhEEuju4Hbs7DCt0= -github.com/obalunenko/getenv v1.13.0/go.mod h1:z/14VQJlEBeaa/JI/RNufa/EQOSDVA2RRUz56ukYOM0= -github.com/obalunenko/logger v1.1.0 h1:Q5drJuCuwz16mm96tcrl5e20uoGSOI4O+VWSauR/mQg= -github.com/obalunenko/logger v1.1.0/go.mod h1:rS66dO9P2j/lybFrDB0Sce1DEVaOi6ag6WDIzljTg8c= -github.com/obalunenko/version v1.2.0 h1:eUYme2w38fjzcvToInTGM85xAJycZHo65GvynbH8jCo= -github.com/obalunenko/version v1.2.0/go.mod h1:kXnCfV2LUe+UHRrzjwPC/5lpnPbypwmLZh7BJx7wG1A= +github.com/obalunenko/getenv v1.14.0 h1:Q8ClxnNMr5a6N0xNg7nHbdhZI4UUfhZMCjabGruq4gA= +github.com/obalunenko/getenv v1.14.0/go.mod h1:PsuPvyLaE71FF7ikdCvPGqILTAWuXq7/+dtlOhab5K4= +github.com/obalunenko/logger v1.2.0 h1:MwsqJWtaxaHFQK7Cjkqk1NnlNPHH+tR1ergdnpST7Kg= +github.com/obalunenko/logger v1.2.0/go.mod h1:XaU3GhUJWda3ow3hhRjlItpIVgQRKa2KDsEeprSzBvg= +github.com/obalunenko/version v1.3.1 h1:NN+YSOrti8mEyJSnu+7//YSvGrOhLivh60hJXhIrNTI= +github.com/obalunenko/version v1.3.1/go.mod h1:56ydLXefFem3sEJ2iyguuZ7dwJ25VoIRTev/JfxFIa4= github.com/olegfedoseev/image-diff v0.0.0-20171116094004-897a4e73dfd6 h1:a/kynVgbdXJQDq3WWTgwL0bHyg4hu4/oIK9UB+Ugvfo= github.com/olegfedoseev/image-diff v0.0.0-20171116094004-897a4e73dfd6/go.mod h1:OgMVaRcJ1TgmPHB/MF2YaHOzRxmw6vVG/DquoMhkCiY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= diff --git a/internal/config/config_internal_test.go b/internal/config/config_internal_test.go index 52466875b..92152d893 100644 --- a/internal/config/config_internal_test.go +++ b/internal/config/config_internal_test.go @@ -59,7 +59,6 @@ func TestLoad(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { got, err := Load(context.Background(), tt.args.path) if tt.wantErr { @@ -67,6 +66,7 @@ func TestLoad(t *testing.T) { return } + assert.NoError(t, err) assert.Equal(t, tt.want, got) }) diff --git a/internal/db/docker.go b/internal/db/docker.go index 146c5e92f..cebe823a7 100644 --- a/internal/db/docker.go +++ b/internal/db/docker.go @@ -130,8 +130,10 @@ func setUpDB(ctx context.Context, m *testing.M, container containerParams, p Con } } + const maxWait = 180 * time.Second + // exponential backoff-retry, because the application in the container might not be ready to accept connections yet - pool.MaxWait = 180 * time.Second + pool.MaxWait = maxWait if err = pool.Retry(retryFn(ctx)); err != nil { log.WithError(ctx, err).WithFields(log.Fields{ "container": resource.Container.Name, diff --git a/internal/db/local_internal_test.go b/internal/db/local_internal_test.go index e14a61227..d1c24da9d 100644 --- a/internal/db/local_internal_test.go +++ b/internal/db/local_internal_test.go @@ -55,7 +55,6 @@ func Test_localDB_GetLastUsersBatchByType(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { l := setUpLocalDBWithFixtures(t) @@ -65,6 +64,7 @@ func Test_localDB_GetLastUsersBatchByType(t *testing.T) { return } + require.NoError(t, err) assert.Equal(t, resetBatchTime(tt.want), resetBatchTime(got)) }) @@ -76,7 +76,9 @@ func Test_localDB_InsertUsersBatch(t *testing.T) { bType := models.UsersBatchTypeFollowers gotBatch, err := ldb.GetLastUsersBatchByType(context.TODO(), bType) + require.ErrorIs(t, err, ErrNoData) + assert.Equal(t, resetBatchTime(models.MakeUsersBatch(bType, nil, time.Now())), resetBatchTime(gotBatch)) goldenBatch := models.UsersBatch{ diff --git a/internal/models/models_test.go b/internal/models/models_test.go index 0e7cac683..2ad368355 100644 --- a/internal/models/models_test.go +++ b/internal/models/models_test.go @@ -29,8 +29,6 @@ func TestUsersBatchType_Valid(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { got := tt.i.Valid() assert.Equal(t, tt.want, got) @@ -66,8 +64,6 @@ func TestMakeUser(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { got := models.MakeUser(tt.args.id, tt.args.username, tt.args.fullname) assert.Equal(t, tt.want, got) diff --git a/internal/service/service_internal_test.go b/internal/service/service_internal_test.go index e28e48a9a..87452e2b0 100644 --- a/internal/service/service_internal_test.go +++ b/internal/service/service_internal_test.go @@ -38,7 +38,6 @@ func Test_getLostFollowers(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { got := getLost(tt.args.old, tt.args.new) assert.Equal(t, tt.want, got) @@ -76,7 +75,6 @@ func Test_getNewFollowers(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { got := getNew(tt.args.old, tt.args.new) assert.Equal(t, tt.want, got) diff --git a/linters-report.xml b/linters-report.xml new file mode 100644 index 000000000..fd4ea085a --- /dev/null +++ b/linters-report.xml @@ -0,0 +1,3 @@ + + + diff --git a/pkg/bar/bar.go b/pkg/bar/bar.go index d32978cf3..e4d8748a2 100644 --- a/pkg/bar/bar.go +++ b/pkg/bar/bar.go @@ -60,11 +60,11 @@ type Bar interface { // for i := range 100{ // pBar.Progress() <- struct{}{} // }. -func New(max int, barType BType) Bar { +func New(maxWork int, barType BType) Bar { switch barType { //nolint:exhaustive // this is expected behavior. case BTypeRendered: b := realBar{ - bar: progressbar.New(max), + bar: progressbar.New(maxWork), stop: sync.Once{}, wg: sync.WaitGroup{}, bchan: make(chan struct{}, 1), @@ -152,7 +152,9 @@ func (b *realBar) Run(ctx context.Context) { log.WithError(ctx, err).Error("Failed to finish bar") } - _, _ = fmt.Fprintln(os.Stdout) + if _, err := fmt.Fprintln(os.Stdout); err != nil { + log.WithError(ctx, err).Error("Failed to print new line") + } }() var ( diff --git a/pkg/bar/bar_internal_test.go b/pkg/bar/bar_internal_test.go index f84ca83ee..36a393c3f 100644 --- a/pkg/bar/bar_internal_test.go +++ b/pkg/bar/bar_internal_test.go @@ -34,8 +34,6 @@ func TestBType_Valid(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { got := tt.bt.Valid() assert.Equal(t, tt.want, got) @@ -90,8 +88,6 @@ func TestNew(t *testing.T) { } for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { got := New(tt.args.cap, tt.args.barType) assert.IsType(t, tt.want, got) diff --git a/scripts/build/app.sh b/scripts/build/app.sh index 9af27c845..2d00d9947 100755 --- a/scripts/build/app.sh +++ b/scripts/build/app.sh @@ -17,53 +17,13 @@ APP=${APP_NAME} echo "Building ${APP}..." -COMMIT="$(git rev-parse HEAD)" -SHORTCOMMIT="$(git rev-parse --short HEAD)" -DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" -VERSION="$(git tag | sort -V | tail -1)" -GOVERSION="$(go version | awk '{print $3;}')" - -if [ -z "${VERSION}" ] || [ "${VERSION}" = "${SHORTCOMMIT}" ]; then - VERSION="v0.0.0" -fi - -COMMIT_TAG="" - -if [[ "${VERSION}" != "v0.0.0" ]]; then - COMMIT_TAG="$(git rev-list -n 1 ${VERSION})" -fi - -## check if the version is a tag -if [[ "${COMMIT_TAG}" != "${COMMIT}" ]]; then - echo 'dev' - - VERSION="${VERSION}-dev" -fi - -## check if there are uncommitted changes -if [[ $(git diff --stat) != '' ]]; then - echo 'dirty' - - COMMIT="${COMMIT}-dirty" - SHORTCOMMIT="${SHORTCOMMIT}-dirty" - VERSION="${VERSION}-dirty" -fi - BIN_OUT="${BIN_DIR}/${APP}" -BUILDINFO_VARS_PKG=github.com/obalunenko/version -export GO_BUILD_LDFLAGS="-s -w \ --X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ --X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ --X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ --X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ --X ${BUILDINFO_VARS_PKG}.appname=${APP} \ --X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" GO_BUILD_PACKAGE="${REPO_ROOT}/cmd/${APP}" rm -rf "${BIN_OUT}" -go build -trimpath -o "${BIN_OUT}" -a -ldflags "${GO_BUILD_LDFLAGS}" "${GO_BUILD_PACKAGE}" +go build -trimpath -o "${BIN_OUT}" "${GO_BUILD_PACKAGE}" echo "Build ${BIN_OUT} success" diff --git a/scripts/build/compile.sh b/scripts/build/compile.sh deleted file mode 100755 index 7b3002246..000000000 --- a/scripts/build/compile.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -set -eu - -SCRIPT_NAME="$(basename "$0")" -SCRIPT_DIR="$(dirname "$0")" -REPO_ROOT="$(cd "${SCRIPT_DIR}" && git rev-parse --show-toplevel)" -BIN_DIR=${REPO_ROOT}/bin - -echo "${SCRIPT_NAME} is running... " - -APP=${APP_NAME} - -echo "Building ${APP}..." - -COMMIT="$(git rev-parse HEAD)" -SHORTCOMMIT="$(git rev-parse --short HEAD)" -DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" -VERSION="$(git tag | sort -V | tail -1)" -GOVERSION="$(go version | awk '{print $3;}')" - -if [ -z "${VERSION}" ] || [ "${VERSION}" = "${SHORTCOMMIT}" ] - then - VERSION="v0.0.0" -fi - -BIN_OUT="${BIN_DIR}/${APP}" - -BUILDINFO_VARS_PKG=github.com/obalunenko/version -GO_BUILD_LDFLAGS="-s -w \ --X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ --X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ --X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ --X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ --X ${BUILDINFO_VARS_PKG}.appname=${APP} \ --X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" - -GO_BUILD_PACKAGE="${REPO_ROOT}/cmd/${APP}" - -rm -rf "${BIN_OUT}" - -go build -o "${BIN_OUT}" -a -trimpath -ldflags "${GO_BUILD_LDFLAGS}" "${GO_BUILD_PACKAGE}" - -echo "Binary compiled at ${BIN_OUT}" diff --git a/scripts/linting/golangci-pipeline.sh b/scripts/linting/golangci-pipeline.sh index 7d4bdcd9c..5404b62b4 100755 --- a/scripts/linting/golangci-pipeline.sh +++ b/scripts/linting/golangci-pipeline.sh @@ -16,6 +16,6 @@ checkInstalled golangci-lint echo "Linting..." golangci-lint run --out-format=github-actions --no-config --disable-all -E govet -golangci-lint run --timeout=10m --out-format=github-actions --config .golangci.pipe.yml +golangci-lint run --config .golangci.pipe.yml echo "${SCRIPT_NAME} done." diff --git a/scripts/linting/golangci-sonar.sh b/scripts/linting/golangci-sonar.sh index 72eab45b3..e756a3ac6 100755 --- a/scripts/linting/golangci-sonar.sh +++ b/scripts/linting/golangci-sonar.sh @@ -15,6 +15,6 @@ checkInstalled golangci-lint echo "Linting..." -golangci-lint run --timeout=10m --config .golangci.yml > linters.out +golangci-lint run --config .golangci.yml >linters.out echo "${SCRIPT_NAME} done." diff --git a/scripts/release/check.sh b/scripts/release/check.sh index b3974ecf7..94b4614a3 100755 --- a/scripts/release/check.sh +++ b/scripts/release/check.sh @@ -15,34 +15,6 @@ echo "${SCRIPT_NAME} is running fo ${APP}... " checkInstalled 'goreleaser' - -# Get new tags from the remote -git fetch --tags -f - -COMMIT="$(git rev-parse HEAD)" -SHORTCOMMIT="$(git rev-parse --short HEAD)" -DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" -VERSION="$(git tag | sort -V | tail -1)" -GOVERSION="$(go version | awk '{print $3;}')" - -if [ -z "${VERSION}" ] || [ "${VERSION}" = "${SHORTCOMMIT}" ] - then - VERSION="v0.0.0" -fi - - -VERSION="${VERSION}-local" - - -BUILDINFO_VARS_PKG=github.com/obalunenko/version -export GO_BUILD_LDFLAGS="-s -w \ --X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ --X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ --X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ --X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ --X ${BUILDINFO_VARS_PKG}.appname=${APP} \ --X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" +goreleaser healthcheck goreleaser check - -goreleaser build --rm-dist --single-target --snapshot diff --git a/scripts/release/local-snapshot-release.sh b/scripts/release/local-snapshot-release.sh index d5990fa4f..7106e77b5 100755 --- a/scripts/release/local-snapshot-release.sh +++ b/scripts/release/local-snapshot-release.sh @@ -15,31 +15,6 @@ echo "${SCRIPT_NAME} is running fo ${APP}... " checkInstalled 'goreleaser' +goreleaser healthcheck -# Get new tags from the remote -git fetch --tags -f - -COMMIT="$(git rev-parse HEAD)" -SHORTCOMMIT="$(git rev-parse --short HEAD)" -DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" -VERSION="$(git tag | sort -V | tail -1)" -GOVERSION="$(go version | awk '{print $3;}')" - -if [ -z "${VERSION}" ] || [ "${VERSION}" = "${SHORTCOMMIT}" ] - then - VERSION="v0.0.0" -fi - -VERSION="${VERSION}-local" - - -BUILDINFO_VARS_PKG=github.com/obalunenko/version -export GO_BUILD_LDFLAGS="-s -w \ --X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ --X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ --X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ --X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ --X ${BUILDINFO_VARS_PKG}.appname=${APP} \ --X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" - -goreleaser --snapshot --skip-publish --rm-dist \ No newline at end of file +goreleaser --snapshot --skip=publish --clean diff --git a/scripts/release/new-version.sh b/scripts/release/new-version.sh index d0303c5f5..28f7a61df 100755 --- a/scripts/release/new-version.sh +++ b/scripts/release/new-version.sh @@ -43,8 +43,7 @@ function menu() { SHORTCOMMIT="$(git rev-parse --short HEAD)" PREV_VERSION="$(git tag | sort -V | tail -1)" - if [ -z "${PREV_VERSION}" ] || [ "${PREV_VERSION}" = "${SHORTCOMMIT}" ] - then + if [ -z "${PREV_VERSION}" ] || [ "${PREV_VERSION}" = "${SHORTCOMMIT}" ]; then PREV_VERSION="v0.0.0" fi @@ -61,7 +60,7 @@ function menu() { ;; 3) printf "Patch update.........\n" - NEW_VERSION=$(echo ${PREV_VERSION} | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, $1,$2,($3 + 1) }') + NEW_VERSION=$(echo ${PREV_VERSION} | sed 's/\(.*v\)\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2;\3;\4;\1/g' | sort -t';' -k 1,1n -k 2,2n -k 3,3n | tail -n 1 | awk -F';' '{printf "%s%d.%d.%d", $4, $1,$2,($3 + 1) }') ;; 4) printf "Exit................................\n" @@ -93,8 +92,8 @@ while true; do case $yn in [Yy]*) - git tag -a "${NEW_TAG}" -m "${NEW_TAG}" && \ - git push --tags + git tag -a "${NEW_TAG}" -m "${NEW_TAG}" && + git push --tags break ;; diff --git a/scripts/release/release.sh b/scripts/release/release.sh index c4b8b8057..a641fe47d 100755 --- a/scripts/release/release.sh +++ b/scripts/release/release.sh @@ -13,31 +13,10 @@ echo "${SCRIPT_NAME} is running... " checkInstalled 'goreleaser' +goreleaser healthcheck + APP=${APP_NAME} echo "${SCRIPT_NAME} is running fo ${APP}... " -# Get new tags from the remote -git fetch --tags -f - -COMMIT="$(git rev-parse HEAD)" -SHORTCOMMIT="$(git rev-parse --short HEAD)" -DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" -VERSION="$(git tag | sort -V | tail -1)" -GOVERSION="$(go version | awk '{print $3;}')" - -if [ -z "${VERSION}" ] || [ "${VERSION}" = "${SHORTCOMMIT}" ] - then - VERSION="v0.0.0" -fi - -BUILDINFO_VARS_PKG=github.com/obalunenko/version -export GO_BUILD_LDFLAGS="-s -w \ --X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ --X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ --X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ --X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ --X ${BUILDINFO_VARS_PKG}.appname=${APP} \ --X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" - -goreleaser release --rm-dist +goreleaser release --clean diff --git a/vendor/github.com/obalunenko/getenv/.goreleaser.yml b/vendor/github.com/obalunenko/getenv/.goreleaser.yml index b8b045810..d7a0b2f89 100644 --- a/vendor/github.com/obalunenko/getenv/.goreleaser.yml +++ b/vendor/github.com/obalunenko/getenv/.goreleaser.yml @@ -1,3 +1,5 @@ +version: 2 + release: github: owner: obalunenko @@ -10,7 +12,7 @@ checksum: name_template: "{{ .ProjectName }}-{{ .Version }}-checksums.txt" snapshot: - name_template: SNAPSHOT-{{ .Commit }} + version_template: SNAPSHOT-{{ .Commit }} changelog: sort: asc diff --git a/vendor/github.com/obalunenko/getenv/Makefile b/vendor/github.com/obalunenko/getenv/Makefile index df5c7784f..ba31b6e60 100644 --- a/vendor/github.com/obalunenko/getenv/Makefile +++ b/vendor/github.com/obalunenko/getenv/Makefile @@ -7,7 +7,6 @@ VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1)) APP_NAME?=getenv SHELL := env APP_NAME=$(APP_NAME) $(SHELL) -GOTOOLS_IMAGE_TAG?=v0.12.3 SHELL := env GOTOOLS_IMAGE_TAG=$(GOTOOLS_IMAGE_TAG) $(SHELL) COMPOSE_TOOLS_FILE=deployments/docker-compose/go-tools-docker-compose.yml @@ -15,7 +14,7 @@ COMPOSE_TOOLS_CMD_BASE=docker compose -f $(COMPOSE_TOOLS_FILE) COMPOSE_TOOLS_CMD_UP=$(COMPOSE_TOOLS_CMD_BASE) up --exit-code-from COMPOSE_TOOLS_CMD_PULL=$(COMPOSE_TOOLS_CMD_BASE) pull -GOVERSION:=1.22 +GOVERSION:=1.23 TARGET_MAX_CHAR_NUM=20 diff --git a/vendor/github.com/obalunenko/logger/.golangci.pipe.yml b/vendor/github.com/obalunenko/logger/.golangci.pipe.yml index 6aaf7e389..092629264 100644 --- a/vendor/github.com/obalunenko/logger/.golangci.pipe.yml +++ b/vendor/github.com/obalunenko/logger/.golangci.pipe.yml @@ -5,6 +5,7 @@ linters: - gofmt - revive - goimports + - govet linters-settings: errcheck: @@ -33,13 +34,13 @@ linters-settings: run: issues-exit-code: 1 tests: true - skip-dirs: - - vendor/ - skip-files: - - \.pb\.go$ issues: exclude-use-default: false + exclude-files: + - \.pb\.go$ + exclude-dirs: + - vendor exclude: # for "public interface + private struct implementation" cases only! - exported func * returns unexported type *, which can be annoying to use diff --git a/vendor/github.com/obalunenko/logger/.golangci.yml b/vendor/github.com/obalunenko/logger/.golangci.yml index 7dcfa3d21..cc737cdb8 100644 --- a/vendor/github.com/obalunenko/logger/.golangci.yml +++ b/vendor/github.com/obalunenko/logger/.golangci.yml @@ -1,8 +1,11 @@ linters: enable-all: true disable: + - gomnd - gochecknoglobals - paralleltest + - exportloopref + - execinquery linters-settings: errcheck: @@ -21,7 +24,7 @@ linters-settings: gofmt: simplify: true govet: - check-shadowing: true + shadow: true enable-all: true golint: min-confidence: 0 @@ -36,11 +39,14 @@ linters-settings: min-occurrences: 2 misspell: locale: US - gomnd: - settings: - mnd: - # the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. - checks: argument,case,condition,operation,return + mnd: + # the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. + checks: + - argument + - case + - condition + - operation + - return lll: # max line length, lines longer will be reported. Default is 120. # '\t' is counted as 1 character by default, and can be changed with the tab-width option @@ -76,52 +82,84 @@ linters-settings: whitespace: multi-if: false # Enforces newlines (or comments) after every multi-line if statement multi-func: false # Enforces newlines (or comments) after every multi-line function signature - wsl: - # If true append is only allowed to be cuddled if appending value is - # matching variables, fields or types on line above. Default is true. - strict-append: true - # Allow calls and assignments to be cuddled as long as the lines have any - # matching variables, fields or types. Default is true. - allow-assign-and-call: true - # Allow multiline assignments to be cuddled. Default is true. - allow-multiline-assign: true - # Allow declarations (var) to be cuddled. - allow-cuddle-declarations: false - # Allow trailing comments in ending of blocks - allow-trailing-comment: false - # Force newlines in end of case at this limit (0 = never). - force-case-trailing-whitespace: 0 + + wsl: + # Do strict checking when assigning from append (x = append(x, y)). + # If this is set to true - the append call must append either a variable + # assigned, called or used on the line above. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#strict-append + # Default: true + strict-append: true + # Allows assignments to be cuddled with variables used in calls on + # line above and calls to be cuddled with assignments of variables + # used in call on line above. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-assign-and-call + # Default: true + allow-assign-and-call: true + # Allows assignments to be cuddled with anything. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-assign-and-anything + # Default: false + allow-assign-and-anything: false + # Allows cuddling to assignments even if they span over multiple lines. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-multiline-assign + # Default: true + allow-multiline-assign: true + # If the number of lines in a case block is equal to or lager than this number, + # the case *must* end white a newline. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#force-case-trailing-whitespace + # Default: 0 + force-case-trailing-whitespace: 0 + # Allow blocks to end with comments. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-trailing-comment + # Default: false + allow-trailing-comment: false + # Allow multiple comments in the beginning of a block separated with newline. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-separated-leading-comment + # Default: false + allow-separated-leading-comment: false + # Allow multiple var/declaration statements to be cuddled. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-cuddle-declarations + # Default: false + allow-cuddle-declarations: false + # A list of call idents that everything can be cuddled with. + # Defaults: [ "Lock", "RLock" ] + allow-cuddle-with-calls: ["Foo", "Bar"] + # AllowCuddleWithRHS is a list of right hand side variables that is allowed + # to be cuddled with anything. + # Defaults: [ "Unlock", "RUnlock" ] + allow-cuddle-with-rhs: ["Foo", "Bar"] + # Causes an error when an If statement that checks an error variable doesn't + # cuddle with the assignment of that variable. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#force-err-cuddling + # Default: false + force-err-cuddling: false + # When force-err-cuddling is enabled this is a list of names + # used for error variables to check for in the conditional. + # Default: [ "err" ] + error-variable-names: ["err"] + # Causes an error if a short declaration (:=) cuddles with anything other than + # another short declaration. + # This logic overrides force-err-cuddling among others. + # https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#force-short-decl-cuddling + # Default: false + force-short-decl-cuddling: false gocritic: enabled-checks: - docStub - rangeValCopy - yodaStyleExpr - - appendAssign - appendCombine - - caseOrder - - badCond - commentedOutCode - - commentFormatting - commentedOutImport - - dupArg - - dupBranchBody - - elseif - emptyStringTest - indexAlloc - initClause - - captlocal - weakCond - - deprecatedComment - - flagDeref - - flagName - hugeParam - - ifElseChain - nilValReturn - rangeExprCopy - ptrToRefParam - - underef - unnecessaryBlock - - valSwap settings: # settings passed to gocritic captLocal: # must be valid enabled check name paramsOnly: true @@ -137,13 +175,13 @@ linters-settings: run: issues-exit-code: 0 tests: true - skip-dirs: - - vendor/ - skip-files: - - \.pb\.go$ issues: exclude-use-default: false + exclude-dirs: + - vendor + exclude-files: + - \.pb\.go$ exclude: # for "public interface + private struct implementation" cases only! - exported func * returns unexported type *, which can be annoying to use diff --git a/vendor/github.com/obalunenko/logger/.goreleaser.yml b/vendor/github.com/obalunenko/logger/.goreleaser.yml index 51e96ea15..9221c42b5 100644 --- a/vendor/github.com/obalunenko/logger/.goreleaser.yml +++ b/vendor/github.com/obalunenko/logger/.goreleaser.yml @@ -1,3 +1,5 @@ +version: 2 + release: github: owner: obalunenko @@ -10,7 +12,7 @@ checksum: name_template: "{{ .ProjectName }}-{{ .Version }}-checksums.txt" snapshot: - name_template: SNAPSHOT-{{ .Commit }} + version_template: SNAPSHOT-{{ .Commit }} changelog: sort: asc diff --git a/vendor/github.com/obalunenko/logger/Makefile b/vendor/github.com/obalunenko/logger/Makefile index b7dc8d04f..c4c4cb670 100644 --- a/vendor/github.com/obalunenko/logger/Makefile +++ b/vendor/github.com/obalunenko/logger/Makefile @@ -3,7 +3,7 @@ BIN_DIR=./bin SHELL := env VERSION=$(VERSION) $(SHELL) VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1)) -GOVERSION:=1.22 +GOVERSION:=1.23 APP_NAME?=logger SHELL := env APP_NAME=$(APP_NAME) $(SHELL) diff --git a/vendor/github.com/obalunenko/version/README.md b/vendor/github.com/obalunenko/version/README.md index 0c2d23fe1..7dfdeb164 100644 --- a/vendor/github.com/obalunenko/version/README.md +++ b/vendor/github.com/obalunenko/version/README.md @@ -3,32 +3,22 @@ This package contains build information generated at build time and compiled into the binary. ```go -// Package version contains build information such as the git commit, app version, build date. +// Package version provides utilities for retrieving application build information +// such as version number, build date, commit hash, application name, and the Go +// language version used during the build process. // -// This info generated at build time and compiled into the binary. +// This package leverages the `runtime/debug` package to read build metadata +// embedded in the binary during the build process with Go modules. // -// Usage: -// At your build script add following lines: -// go install -ldflags '-X github.com/obalunenko/version.version APP_VERSION -X github.com/obalunenko/version.builddate BUILD_DATE -X github.com/obalunenko/version.commit COMMIT -X github.com/obalunenko/version.shortcommit SHORTCOMMIT -X github.com/obalunenko/version.appname APP_NAME' -// and then build your binary -// go build -// Please note that all future binaries will be compiled with the embedded information unless the version package is recompiled with new values. +// Build information can be accessed via the exposed methods: // -// Alternative is use ldflags on stage of compiling: -// GOVERSION=$(go version | awk '{print $3;}') -// APP=myapp -// BIN_OUT=bin/${APP} -// BUILDINFO_VARS_PKG=github.com/obalunenko/version -// GO_BUILD_LDFLAGS="-s -w \ -//-X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ -//-X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ -//-X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ -//-X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ -//-X ${BUILDINFO_VARS_PKG}.appname=${APP}" \ -//-X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" -// GO_BUILD_PACKAGE="" - -// rm -rf ${BIN_OUT} +// - GetGoVersion: Returns the Go version used to build the app. +// - GetVersion: Returns the application's version. +// - GetBuildDate: Returns the date the application was built. +// - GetCommit: Returns the full commit hash the application was built from. +// - GetShortCommit: Returns a shortened commit hash (7 characters). +// - GetAppName: Returns the application's module path. // -// go build -o ${BIN_OUT} -a -ldflags "${GO_BUILD_LDFLAGS}" "${GO_BUILD_PACKAGE}" +// When the application is built from sources with uncommitted changes, the +// commit information will be suffixed with "+CHANGES". ``` diff --git a/vendor/github.com/obalunenko/version/version.go b/vendor/github.com/obalunenko/version/version.go index 936ce9130..c10928ce5 100644 --- a/vendor/github.com/obalunenko/version/version.go +++ b/vendor/github.com/obalunenko/version/version.go @@ -1,34 +1,27 @@ -// Package version contains build information such as the git commit, app version, build date. +// Package version provides utilities for retrieving application build information +// such as version number, build date, commit hash, application name, and the Go +// language version used during the build process. // -// This info generated at build time and compiled into the binary. +// This package leverages the `runtime/debug` package to read build metadata +// embedded in the binary during the build process with Go modules. // -// Usage: -// At your build script add following lines: -// go install -ldflags '-X github.com/obalunenko/version.version APP_VERSION -X github.com/obalunenko/version.builddate BUILD_DATE -X github.com/obalunenko/version.commit COMMIT -X github.com/obalunenko/version.shortcommit SHORTCOMMIT -X github.com/obalunenko/version.appname APP_NAME' -// and then build your binary -// go build -// Please note that all future binaries will be compiled with the embedded information unless the version package is recompiled with new values. +// Build information can be accessed via the exposed methods: // -// Alternative is use ldflags on stage of compiling: -// GOVERSION=$(go version | awk '{print $3;}') -// APP=myapp -// BIN_OUT=bin/${APP} -// BUILDINFO_VARS_PKG=github.com/obalunenko/version -// GO_BUILD_LDFLAGS="-s -w \ -//-X ${BUILDINFO_VARS_PKG}.version=${VERSION} \ -//-X ${BUILDINFO_VARS_PKG}.commit=${COMMIT} \ -//-X ${BUILDINFO_VARS_PKG}.shortcommit=${SHORTCOMMIT} \ -//-X ${BUILDINFO_VARS_PKG}.builddate=${DATE} \ -//-X ${BUILDINFO_VARS_PKG}.appname=${APP}" \ -//-X ${BUILDINFO_VARS_PKG}.goversion=${GOVERSION}" -// GO_BUILD_PACKAGE="" - -// rm -rf ${BIN_OUT} +// - GetGoVersion: Returns the Go version used to build the app. +// - GetVersion: Returns the application's version. +// - GetBuildDate: Returns the date the application was built. +// - GetCommit: Returns the full commit hash the application was built from. +// - GetShortCommit: Returns a shortened commit hash (7 characters). +// - GetAppName: Returns the application's module path. // -// go build -o ${BIN_OUT} -a -ldflags "${GO_BUILD_LDFLAGS}" "${GO_BUILD_PACKAGE}" - +// When the application is built from sources with uncommitted changes, the +// commit information will be suffixed with "+CHANGES". package version +import ( + "runtime/debug" +) + const unset = "unset" var ( // build info @@ -40,6 +33,42 @@ var ( // build info goversion = unset ) +func init() { + info, ok := debug.ReadBuildInfo() + if !ok { + return + } + + goversion = info.GoVersion + + var modified bool + + for _, setting := range info.Settings { + switch setting.Key { + case "vcs.revision": + commit = setting.Value + case "vcs.time": + builddate = setting.Value + case "vcs.modified": + modified = true + } + } + + if len(commit) < 7 { + shortcommit = commit + } else { + shortcommit = commit[:7] + } + + if modified { + commit += "+CHANGES" + shortcommit += "+CHANGES" + } + + appname = info.Path + version = info.Main.Version +} + // GetGoVersion returns the go version func GetGoVersion() string { return goversion diff --git a/vendor/modules.txt b/vendor/modules.txt index de7573180..946cc23e1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -208,16 +208,16 @@ github.com/moby/term/windows # github.com/montanaflynn/stats v0.7.1 ## explicit; go 1.13 github.com/montanaflynn/stats -# github.com/obalunenko/getenv v1.13.0 -## explicit; go 1.22 +# github.com/obalunenko/getenv v1.14.0 +## explicit; go 1.23 github.com/obalunenko/getenv github.com/obalunenko/getenv/internal github.com/obalunenko/getenv/option -# github.com/obalunenko/logger v1.1.0 -## explicit; go 1.22 +# github.com/obalunenko/logger v1.2.0 +## explicit; go 1.23 github.com/obalunenko/logger -# github.com/obalunenko/version v1.2.0 -## explicit; go 1.22 +# github.com/obalunenko/version v1.3.1 +## explicit; go 1.24 github.com/obalunenko/version # github.com/olegfedoseev/image-diff v0.0.0-20171116094004-897a4e73dfd6 ## explicit