Add go fmt and go fix checks to lint
Adds go-fmt and go-fix Makefile targets that fail when gofmt or go fix suggest changes. Both are wired into the lint target and used in CI. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
2
.github/workflows/make.yaml
vendored
2
.github/workflows/make.yaml
vendored
@@ -153,6 +153,8 @@ jobs:
|
|||||||
name: "build-artifacts"
|
name: "build-artifacts"
|
||||||
- run: "chmod +x bin/probod"
|
- run: "chmod +x bin/probod"
|
||||||
- run: "make generate"
|
- run: "make generate"
|
||||||
|
- run: "make go-fmt"
|
||||||
|
- run: "make go-fix"
|
||||||
- name: "Run go vet"
|
- name: "Run go vet"
|
||||||
run: "go vet ./..."
|
run: "go vet ./..."
|
||||||
- name: "Run golangci-lint"
|
- name: "Run golangci-lint"
|
||||||
|
|||||||
20
GNUmakefile
20
GNUmakefile
@@ -59,7 +59,7 @@ endif
|
|||||||
all: build
|
all: build
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: vet go-lint npm-lint
|
lint: vet go-fmt go-fix go-lint npm-lint
|
||||||
|
|
||||||
.PHONY: vet
|
.PHONY: vet
|
||||||
vet: generate apps/console/dist/index.html apps/trust/dist/index.html @probo/emails
|
vet: generate apps/console/dist/index.html apps/trust/dist/index.html @probo/emails
|
||||||
@@ -69,6 +69,24 @@ vet: generate apps/console/dist/index.html apps/trust/dist/index.html @probo/ema
|
|||||||
npm-lint:
|
npm-lint:
|
||||||
$(NPM) run lint
|
$(NPM) run lint
|
||||||
|
|
||||||
|
.PHONY: go-fmt
|
||||||
|
go-fmt: generate
|
||||||
|
@output="$$(gofmt -l cmd pkg e2e)"; \
|
||||||
|
if [ -n "$$output" ]; then \
|
||||||
|
echo "error: 'gofmt' found unformatted files:"; \
|
||||||
|
echo "$$output"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
.PHONY: go-fix
|
||||||
|
go-fix: generate
|
||||||
|
@output="$$($(GO_BASE) fix -diff ./cmd/... ./pkg/... ./e2e/...)"; \
|
||||||
|
if [ -n "$$output" ]; then \
|
||||||
|
echo "error: 'go fix' suggests changes; please apply them"; \
|
||||||
|
echo "$$output"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
.PHONY: go-lint
|
.PHONY: go-lint
|
||||||
go-lint: generate
|
go-lint: generate
|
||||||
$(GOLINTCMD) run ./...
|
$(GOLINTCMD) run ./...
|
||||||
|
|||||||
Reference in New Issue
Block a user