feat: add golangci workflow with some linters (#2957)

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 <hey@mike.ee>
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
Mike 2023-10-21 06:47:02 +01:00 committed by GitHub
commit b42a18be6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 197 additions and 1 deletions

View file

@ -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 }}

162
v2/.golangci.yml Normal file
View file

@ -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

View file

@ -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 -- <version>`
dir: tools/release

View file

@ -21,8 +21,9 @@ 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)
- Added new community template wails-htmx-templ-chi-tailwind. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2984)
- Added CPU/GPU/Memory detection for `wails doctor`
- Added CPU/GPU/Memory detection for `wails doctor`. Added by @leaanthony in #d51268b8d0680430f3a614775b13e6cd2b906d1c
### Changed