diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml index c1727901..7ee97884 100644 --- a/.github/workflows/go-ci.yml +++ b/.github/workflows/go-ci.yml @@ -5,10 +5,45 @@ on: - v* branches: - main + - chore/ramin/field-alignment pull_request: + jobs: + setup: + runs-on: ubuntu-latest + outputs: + go-version: ${{ steps.go-version.outputs.version }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Read .go-version file + id: go-version + run: echo "version=$(cat .go-version)" >> $GITHUB_ENV + + lint: + needs: [setup] + name: Lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v4 + with: + go-version: ${{ needs.setup.outputs.go-version }} + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.7.0 + with: + args: --timeout 10m + version: v1.55 + skip-pkg-cache: true + skip-build-cache: true build: + needs: [lint] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -16,7 +51,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21 + go-version: ${{ needs.setup.outputs.go-version }} - name: Build run: go build -v ./... diff --git a/.go-version b/.go-version new file mode 100644 index 00000000..d2ab029d --- /dev/null +++ b/.go-version @@ -0,0 +1 @@ +1.21 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..02c51acb --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,72 @@ +run: + timeout: 5m + +linters: + enable: + - bodyclose + # - depguard as of v1.54.2, the default config throws errors on our repo + - dogsled + - dupl + - errcheck + # - funlen + # - gochecknoglobals + # - gochecknoinits + - goconst + - gocritic + # - gocyclo + # - godox + - gofmt + - goimports + # - golint - deprecated since v1.41. revive will be used instead + - revive + - gosec + - gosimple + - govet + - ineffassign + # - interfacer + - lll + - misspell + # - maligned + - nakedret + - prealloc + # - scopelint - deprecated since v1.39. exportloopref will be used instead + - exportloopref + - staticcheck + - stylecheck + - typecheck + - unconvert + # - unparam + - unused + # - whitespace + # - wsl + # - gocognit + - nolintlint + - asciicheck + +issues: + exclude-rules: + - path: _test\.go + linters: + - gosec + - govet + - linters: + - lll + source: "https://" + max-same-issues: 50 + +linters-settings: + dogsled: + max-blank-identifiers: 3 + golint: + min-confidence: 0 + maligned: + suggest-new: true + misspell: + locale: US + goimports: + local-prefixes: github.com/celestiaorg/celestia-node + dupl: + threshold: 200 + govet: + enable: + - fieldalignment