From 5a63d0cade78ae3839ba8b64d7d502b8effb21ce Mon Sep 17 00:00:00 2001 From: mikeee Date: Sun, 8 Oct 2023 14:26:00 +0100 Subject: [PATCH] feat: add golangci workflow with some linters This implements the golangci-lint workflow to new PRs. It includes a limited number of enabled linters including: - errcheck - errname - gofmt - gofumpt - gosimple - misspell Signed-off-by: mikeee --- .github/workflows/pr.yml | 23 +++++ v2/.golangci.yml | 162 ++++++++++++++++++++++++++++++++ v2/Taskfile.yaml | 10 ++ website/src/pages/changelog.mdx | 1 + 4 files changed, 196 insertions(+) create mode 100644 v2/.golangci.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6db750b73ef..46acb8ee434 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -26,6 +26,29 @@ jobs: run: | echo "::warning::Feature branch does not contain any changes to the website." + lint_go: + name: Run Go Linters + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + + - name: Update go modules + working-directory: ./v2 + run: go mod tidy + + - name: Run Linter + uses: golangci/golangci-lint-action@v3 + with: + version: v1.54 + working-directory: ./v2 + args: --timeout=10m0s --config ./.golangci.yml + test_go: name: Run Go Tests runs-on: ${{ matrix.os }} diff --git a/v2/.golangci.yml b/v2/.golangci.yml new file mode 100644 index 00000000000..66b77ba7ff6 --- /dev/null +++ b/v2/.golangci.yml @@ -0,0 +1,162 @@ +# Options for analysis runner. +run: + # Custom concurrency value + concurrency: 4 + + # Execution timeout + timeout: 10m + + # Exit code when an issue is found. + issues-exit-code: 1 + + # Inclusion of test files + tests: false + + modules-download-mode: readonly + + allow-parallel-runners: false + + go: '1.21' + + +output: + # Runner output format + format: tab + + # Print line of issue code + print-issued-lines: false + + # Append linter to the output + print-linter-name: true + + # Separate issues by line + uniq-by-line: true + + # Output path prefixing + path-prefix: "" + + # Sort results + sort-results: true + + +# Specific linter configs +linters-settings: + errcheck: + check-type-assertions: false + check-blank: false + ignore: fmt:.* + disable-default-exclusions: false + + gofmt: + simplify: true + + gofumpt: + extra-rules: false + +linters: + fast: false + # Enable all available linters. + enable-all: true + # Disable specific linters + disable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - containedctx + - contextcheck + - cyclop + - deadcode + - decorder + - depguard + - dogsled + - dupl + - dupword + - durationcheck + - errchkjson + - errorlint + - execinquery + - exhaustive + - exhaustivestruct + - exhaustruct + - exportloopref + - forbidigo + - forcetypeassert + - funlen + - gci + - ginkgolinter + - gocheckcompilerdirectives + - gochecknoglobals + - gochecknoinits + - gocognit + - goconst + - gocritic + - gocyclo + - godot + - godox + - goerr113 + - goheader + - goimports + - golint + - gomnd + - gomoddirectives + - gomodguard + - goprintffuncname + - gosec + - gosmopolitan + - govet + - grouper + - ifshort + - importas + - ineffassign + - interfacebloat + - interfacer + - ireturn + - lll + - loggercheck + - maintidx + - makezero + - maligned + - mirror + - musttag + - nakedret + - nestif + - nilerr + - nilnil + - nlreturn + - noctx + - nolintlint + - nonamedreturns + - nosnakecase + - nosprintfhostport + - paralleltest + - prealloc + - predeclared + - promlinter + - reassign + - revive + - rowserrcheck + - scopelint + - sqlclosecheck + - staticcheck + - structcheck + - stylecheck + - tagalign + - tagliatelle + - tenv + - testableexamples + - testpackage + - thelper + - tparallel + - typecheck + - unconvert + - unparam + - unused + - usestdlibvars + - varcheck + - varnamelen + - wastedassign + - whitespace + - wrapcheck + - wsl + - zerologlint \ No newline at end of file diff --git a/v2/Taskfile.yaml b/v2/Taskfile.yaml index 526dd097d04..d1893732b44 100644 --- a/v2/Taskfile.yaml +++ b/v2/Taskfile.yaml @@ -3,6 +3,16 @@ version: "3" tasks: + download: + summary: Run go mod tidy + cmds: + - go mod tidy + + lint: + summary: Run golangci-lint + cmds: + - golangci-lint run ./... --timeout=3m -v + release: summary: Release a new version of Task. Call with `task v2:release -- ` dir: tools/release diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index 4923de6866f..348df993928 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added support for setting some of the Webview preferences, `textInteractionEnabled` and `tabFocusesLinks` on Mac. Added by @fkhadra in [PR](https://github.com/wailsapp/wails/pull/2937) - Added support for enabling/disabling fullscreen of the Webview on Mac. Added by @fkhadra in [PR](https://github.com/wailsapp/wails/pull/2953) - Added French README.fr.md page. Added by @nejos97 in [PR](https://github.com/wailsapp/wails/pull/2943) +- New task created for linting v2 `task v2:lint`. Workflow updated to run the task. Added by @mikeee in [PR](https://github.com/wailsapp/wails/pull/2957) ### Changed