diff --git a/.github/workflows/CI/go_build.yml b/.github/workflows/CI/go_build.yml index e69de29..1500ec4 100644 --- a/.github/workflows/CI/go_build.yml +++ b/.github/workflows/CI/go_build.yml @@ -0,0 +1,27 @@ +on: + workflow_call: + inputs: + working-directory: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go 1.22.x' + uses: actions/setup-go@v5 + with: + go-version: '1.22.x' + + - name: Display Go version + run: go version + + - name: Install dependencies + run: | + go get ${{ inputs.working-directory }} + + - name: Build + run: | + go build ${{ inputs.working-directory }} \ No newline at end of file diff --git a/.github/workflows/CI/go_lint.yml b/.github/workflows/CI/go_lint.yml index e69de29..287601b 100644 --- a/.github/workflows/CI/go_lint.yml +++ b/.github/workflows/CI/go_lint.yml @@ -0,0 +1,22 @@ +on: + workflow_call: + inputs: + working-directory: + required: true + type: string + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v4 + with: + version: latest + working-directory: ${{ inputs.working-directory }} \ No newline at end of file diff --git a/.github/workflows/CI/go_test.yml b/.github/workflows/CI/go_test.yml index e69de29..7d13c38 100644 --- a/.github/workflows/CI/go_test.yml +++ b/.github/workflows/CI/go_test.yml @@ -0,0 +1,23 @@ +on: + workflow_call: + inputs: + working-directory: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go 1.22.x' + uses: actions/setup-go@v5 + with: + go-version: '1.22.x' + + - name: Display Go version + run: go version + + - name: Install dependencies + run: | + go test ${{ inputs.working-directory }} \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..8e911f9 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,132 @@ +linters-settings: + depguard: + rules: + logger: + deny: + # logging is allowed only by logutils.Log, + # logrus is allowed to use only in logutils package. + - pkg: "github.com/sirupsen/logrus" + desc: logging is allowed only by logutils.Log. + - pkg: "github.com/pkg/errors" + desc: Should be replaced by standard lib errors package. + - pkg: "github.com/instana/testify" + desc: It's a fork of github.com/stretchr/testify. + dupl: + threshold: 100 + funlen: + lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner. + statements: 50 + goconst: + min-len: 2 + min-occurrences: 3 + gocritic: + enabled-tags: + - diagnostic + - experimental + - opinionated + - performance + - style + disabled-checks: + - dupImport # https://github.com/go-critic/go-critic/issues/845 + - ifElseChain + - octalLiteral + - whyNoLint + gocyclo: + min-complexity: 15 + gofmt: + rewrite-rules: + - pattern: 'interface{}' + replacement: 'any' + gomnd: + # don't include the "operation" and "assign" + checks: + - argument + - case + - condition + - return + ignored-numbers: + - '0' + - '1' + - '2' + - '3' + ignored-functions: + - strings.SplitN + govet: + settings: + printf: + funcs: + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf + enable: + - nilness + - shadow + errorlint: + asserts: false + lll: + line-length: 140 + misspell: + locale: US + nolintlint: + allow-unused: false # report any unused nolint directives + require-explanation: false # don't require an explanation for nolint directives + require-specific: false # don't require nolint directives to be specific about which linter is being skipped + revive: + rules: + - name: unexported-return + disabled: true + - name: unused-parameter + +linters: + disable-all: true + enable: + - bodyclose + - depguard + - dogsled + - dupl + - errcheck + - errorlint + - exportloopref + - funlen + - gocheckcompilerdirectives + - gochecknoinits + - goconst + - gocritic + - gocyclo + - gofmt + - goimports + - gomnd + - goprintffuncname + - gosec + - gosimple + - govet + - ineffassign + - lll + - misspell + - nakedret + - noctx + - nolintlint + - revive + - staticcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - whitespace + + # don't enable: + # - asciicheck + # - gochecknoglobals + # - gocognit + # - godot + # - godox + # - goerr113 + # - nestif + # - prealloc + # - testpackage + # - wsl + +run: + timeout: 5m