Add linter and a little bit more tests
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
Signed-off-by: Nikolai Rodionov <iam@allanger.xyz>
This commit is contained in:
62
Taskfile.yml
62
Taskfile.yml
@@ -6,6 +6,10 @@ vars:
|
||||
LOCALBIN:
|
||||
sh: echo "$(pwd)/bin"
|
||||
MIGRATE: "{{.LOCALBIN}}/migrate"
|
||||
GOFUMPT: "{{.LOCALBIN}}/gofumpt"
|
||||
GOLANGCI_LINT: "{{.LOCALBIN}}/golangci-lint"
|
||||
# Tool versions
|
||||
GOLANGCI_LINT_VERSION: v2.8.0
|
||||
|
||||
tasks:
|
||||
build:
|
||||
@@ -23,6 +27,34 @@ tasks:
|
||||
- run-migrations-dev
|
||||
silent: true
|
||||
|
||||
fmt:
|
||||
desc: Run gofumt fmt against code.
|
||||
deps:
|
||||
- gofumt
|
||||
cmd: '"{{.GOFUMPT}}" -l -w .'
|
||||
|
||||
vet:
|
||||
desc: Run go vet against code.
|
||||
cmd: go vet ./...
|
||||
|
||||
lint:
|
||||
desc: Run golangci-lint linter
|
||||
deps:
|
||||
- golangci-lint
|
||||
cmd: '"{{.GOLANGCI_LINT}}" run'
|
||||
|
||||
lint-fix:
|
||||
desc: Run golangci-lint linter and perform fixes
|
||||
deps:
|
||||
- golangci-lint
|
||||
cmd: '"{{.GOLANGCI_LINT}}" run --fix'
|
||||
|
||||
lint-config:
|
||||
desc: Verify golangci-lint linter configuration
|
||||
deps:
|
||||
- golangci-lint
|
||||
cmd: '"{{.GOLANGCI_LINT}}" config verify'
|
||||
|
||||
run-migrations-dev:
|
||||
desc: Execute database migrations
|
||||
env:
|
||||
@@ -122,3 +154,33 @@ tasks:
|
||||
|
||||
mv "{{.LOCALBIN}}/$(basename "$TARGET")" "$VERSIONED"
|
||||
ln -sf "$(realpath "$VERSIONED")" "$TARGET"
|
||||
|
||||
gofumt:
|
||||
desc: Download latest gofumt
|
||||
silent: true
|
||||
deps:
|
||||
- localbin
|
||||
cmds:
|
||||
- task: go-install-tool
|
||||
vars:
|
||||
TARGET: "{{.GOFUMPT}}"
|
||||
PACKAGE: mvdan.cc/gofumpt
|
||||
VERSION: "latest"
|
||||
|
||||
golangci-lint:
|
||||
desc: Install golangci-lint (with optional custom build)
|
||||
silent: true
|
||||
deps:
|
||||
- localbin
|
||||
cmds:
|
||||
- task: go-install-tool
|
||||
vars:
|
||||
TARGET: "{{.GOLANGCI_LINT}}"
|
||||
PACKAGE: github.com/golangci/golangci-lint/v2/cmd/golangci-lint
|
||||
VERSION: "{{.GOLANGCI_LINT_VERSION}}"
|
||||
- |
|
||||
if [ -f .custom-gcl.yml ]; then
|
||||
echo "Building custom golangci-lint with plugins..."
|
||||
"{{.GOLANGCI_LINT}}" custom --destination "{{.LOCALBIN}}" --name golangci-lint-custom
|
||||
mv -f "{{.LOCALBIN}}/golangci-lint-custom" "{{.GOLANGCI_LINT}}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user