diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8512489d..caf469e2 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -31,7 +31,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript' ] + language: [ 'javascript','go' ] steps: - name: Checkout repository diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml new file mode 100644 index 00000000..d07372ee --- /dev/null +++ b/.github/workflows/golangci.yml @@ -0,0 +1,41 @@ +name: golangci-lint +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +permissions: read-all + +jobs: + lint: + name: Run golangci lint + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest ] + steps: + - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 #v2.4.0 + # https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds + - uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed #v2.1.7 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + %LocalAppData%\go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4 #v2.1.5 + with: + go-version: '1.17.x' + - uses: golangci/golangci-lint-action@5c56cd6c9dc07901af25baab6f2b0d9f3b7c3018 + with: + version: v1.44.0 + only-new-issues: true diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index b18c70fc..f9d2f6c3 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,10 +14,9 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] - steps: - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 #v2.4.0 - # https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds + # https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds - uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed #v2.1.7 with: # In order: @@ -37,6 +36,4 @@ jobs: with: go-version: '1.17.x' - name: Run Go tests - run: go test ./... - - name: Run Go tests w/ `-race` run: go test -race ./... diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..c960945b --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,150 @@ +--- +run: + concurrency: 6 + deadline: 5m +issues: + new-from-rev: "" + include: + # revive `package-comments` and `exported` rules. + - EXC0012 + - EXC0013 + - EXC0014 + - EXC0015 +linters: + disable-all: true + enable: + - asciicheck + - bodyclose + - deadcode + - depguard + - dogsled + - errcheck + - errorlint + - exhaustive + - exportloopref + - gci + - gochecknoinits + - gocognit + - goconst + - gocritic + - gocyclo + - godot + - godox + - goerr113 + - gofmt + - gofumpt + - goheader + - goimports + - gomodguard + - goprintffuncname + - gosec + - gosimple + - govet + - ineffassign + - lll + - makezero + - misspell + - nakedret + - nestif + - noctx + - nolintlint + - paralleltest + - predeclared + - revive + - rowserrcheck + - sqlclosecheck + - staticcheck + - structcheck + - stylecheck + - thelper + - tparallel + - typecheck + - unconvert + - unparam + - unused + - varcheck + - whitespace + - wrapcheck +linters-settings: + errcheck: + check-type-assertions: true + check-blank: true + govet: + enable: + - fieldalignment + godox: + keywords: + - BUG + - FIXME + - HACK + gci: + local-prefixes: github.com/ossf/scorecard-action + gocritic: + enabled-checks: + # Diagnostic + - appendAssign + - argOrder + - badCond + - caseOrder + - codegenComment + - commentedOutCode + - deprecatedComment + - dupArg + - dupBranchBody + - dupCase + - dupSubExpr + - exitAfterDefer + - flagDeref + - flagName + - nilValReturn + - offBy1 + - sloppyReassign + - weakCond + - octalLiteral + + # Performance + - appendCombine + - equalFold + - hugeParam + - indexAlloc + - rangeExprCopy + - rangeValCopy + + # Style + - assignOp + - boolExprSimplify + - captLocal + - commentFormatting + - commentedOutImport + - defaultCaseOrder + - docStub + - elseif + - emptyFallthrough + - emptyStringTest + - hexLiteral + - ifElseChain + - methodExprCall + - regexpMust + - singleCaseSwitch + - sloppyLen + - stringXbytes + - switchTrue + - typeAssertChain + - typeSwitchVar + - underef + - unlabelStmt + - unlambda + - unslice + - valSwap + - wrapperFunc + - yodaStyleExpr + + # Opinionated + - builtinShadow + - importShadow + - initClause + - nestingReduce + - paramTypeCombine + - ptrToRefParam + - typeUnparen + - unnecessaryBlock