forked from redpanda-data/console
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Add task for linting & formatting Go code
- Loading branch information
Showing
4 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 3 | ||
|
||
vars: | ||
BUILD_ROOT: "{{ .ROOT_DIR }}/build" | ||
BACKEND_ROOT: "{{ .ROOT_DIR }}/backend" | ||
FRONTEND_ROOT: "{{ .ROOT_DIR }}/frontend" | ||
BRANCH_SLUG: | ||
sh: git rev-parse --abbrev-ref HEAD | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z | ||
|
||
includes: | ||
backend: taskfiles/backend.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
version: 3 | ||
tasks: | ||
install-golangci-lint: | ||
desc: install golangci linter | ||
vars: | ||
GO_LINT_VERSION: 1.50.1 | ||
cmds: | ||
- mkdir -p {{ .BUILD_ROOT}}/bin | ||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "{{ .BUILD_ROOT }}"/bin/go v{{ .GO_LINT_VERSION }} | ||
status: | ||
- '[ -f ''{{ .BUILD_ROOT }}/bin/go'' ] || command -v {{ .BUILD_ROOT }}/bin/go/golangci-lint >/dev/null 2>&1' | ||
- '[[ $({{ .BUILD_ROOT }}/bin/go/golangci-lint --version) == *"version {{ .GO_LINT_VERSION }} built"* ]]' | ||
|
||
install-gofumpt: | ||
vars: | ||
GOFUMPT_VERSION: 0.4.0 | ||
desc: install gofumpt go formater | ||
cmds: | ||
- | | ||
GOBIN={{ .BUILD_ROOT }}/bin/go go install mvdan.cc/gofumpt@v{{ .GOFUMPT_VERSION }} | ||
status: | ||
- '[ -f ''{{ .BUILD_ROOT }}/bin/go'' ] || command -v {{ .BUILD_ROOT }}/bin/go/gofumpt >/dev/null 2>&1' | ||
- '[[ $({{ .BUILD_ROOT }}/bin/go/gofumpt --version) == v{{.GOFUMPT_VERSION}} ]]' | ||
|
||
install-gci: | ||
vars: | ||
GCI_VERSION: 0.9.0 | ||
desc: install gci | ||
cmds: | ||
- GOBIN={{ .BUILD_ROOT }}/bin/go go install github.com/daixiang0/gci@v{{.GCI_VERSION}} | ||
status: | ||
- '[ -f ''{{ .BUILD_ROOT }}/bin/go'' ] || command -v {{ .BUILD_ROOT }}/bin/go/gci >/dev/null 2>&1' | ||
|
||
fmt: | ||
desc: Format Go code | ||
deps: | ||
- install-gci | ||
- install-gofumpt | ||
dir: "{{.BACKEND_ROOT}}" | ||
cmds: | ||
- '{{ .BUILD_ROOT }}/bin/go/gofumpt -l -w .' | ||
- '{{ .BUILD_ROOT }}/bin/go/gci write --NoPrefixComments -s standard -s default -s ''Prefix(github.com/redpanda-data/console/backend)'' .' | ||
|
||
lint: | ||
desc: Run Go linters for backend code | ||
deps: | ||
- install-golangci-lint | ||
dir: "{{.BACKEND_ROOT}}" | ||
cmds: | ||
- '{{ .BUILD_ROOT }}/bin/go/golangci-lint run --timeout 10m ./...' |