diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..3559a9a --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,44 @@ +name: golangci-lint + +on: + push: + branches: [master, main] + pull_request: + branches: [master, main] + schedule: + - cron: "23 6 * * 1" + +permissions: + contents: read + pull-requests: read + +jobs: + lint: + name: lint + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + path: api + # Sibling checkouts (proto/common) for repos with replace directives. + # No-op for repos that do not need them. + - uses: actions/checkout@v4 + if: ${{ hashFiles('api/go.mod') != '' }} + with: + repository: InstaNode-dev/common + path: common + continue-on-error: true + - uses: actions/checkout@v4 + with: + repository: InstaNode-dev/proto + path: proto + continue-on-error: true + - uses: actions/setup-go@v5 + with: + go-version-file: api/go.mod + - uses: golangci/golangci-lint-action@v8 + with: + version: latest + working-directory: api + args: --timeout=5m diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..1f598a4 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,31 @@ +# golangci-lint v2 config — start conservative, expand once baseline is clean +version: "2" + +run: + timeout: 5m + tests: true + +linters: + # Default linter set is govet+errcheck+ineffassign+staticcheck+unused. + # We explicitly add misspell + gocyclo on top. gosimple folded into staticcheck in v2. + enable: + - errcheck # checks unchecked errors + - govet # standard vet + - ineffassign # ineffective assignments + - staticcheck # bug detection (subsumes gosimple in v2) + - unused # unused code + - misspell # spelling + - gocyclo # cyclomatic complexity + settings: + gocyclo: + min-complexity: 20 + exclusions: + rules: + - path: _test\.go + linters: + - errcheck + - gocyclo + +issues: + max-issues-per-linter: 0 + max-same-issues: 0