-
Notifications
You must be signed in to change notification settings - Fork 7
fix(BREV-1623): minor fixes for makefile targets #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,8 +23,13 @@ GOMOD=$(GOCMD) mod | |
| GOLINT=golangci-lint | ||
| GOVET=$(GOCMD) vet | ||
| GOFMT=gofumpt | ||
| GOINSTALL=$(GOCMD) install | ||
| GOSEC=gosec | ||
|
|
||
| # Third party tools | ||
| ARTIFACT_GOLINT=github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8 | ||
| ARTIFACT_GOSEC=github.com/securego/gosec/v2/cmd/gosec@v2.22.8 | ||
|
|
||
| # Build flags | ||
| LDFLAGS=-ldflags "-X main.Version=$(shell git describe --tags --always --dirty) -X main.BuildTime=$(shell date -u '+%Y-%m-%d_%H:%M:%S')" | ||
|
|
||
|
|
@@ -104,13 +109,10 @@ bench: | |
| .PHONY: lint | ||
| lint: | ||
| @echo "Running linter..." | ||
| @if command -v $(GOLINT) > /dev/null; then \ | ||
| $(GOLINT) run ./...; \ | ||
| else \ | ||
| echo "golangci-lint not found. Installing..."; \ | ||
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \ | ||
| $(GOLINT) run ./...; \ | ||
|
Comment on lines
-107
to
-112
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplifies the logic down to one GOLINT call |
||
| @if ! command -v $(GOLINT) > /dev/null 2>&1; then \ | ||
| $(GOINSTALL) $(ARTIFACT_GOLINT); \ | ||
| fi | ||
| $(GOLINT) run ./... | ||
|
|
||
| # Run go vet | ||
| .PHONY: vet | ||
|
|
@@ -128,9 +130,11 @@ fmt: | |
| .PHONY: fmt-check | ||
| fmt-check: | ||
| @echo "Checking code formatting..." | ||
| @if [ "$$($(GOFMT) -l . | wc -l)" -gt 0 ]; then \ | ||
| @files=$$($(GOFMT) -l .); \ | ||
| if [ -n "$$files" ]; then \ | ||
| echo "Code is not formatted. Run 'make fmt' to format."; \ | ||
| $(GOFMT) -l .; \ | ||
| echo "$$files"; \ | ||
| exit 1; \ | ||
| else \ | ||
| echo "Code is properly formatted."; \ | ||
|
|
@@ -140,13 +144,11 @@ fmt-check: | |
| .PHONY: security | ||
| security: | ||
| @echo "Running security scan..." | ||
| @if command -v $(GOSEC) > /dev/null; then \ | ||
| $(GOSEC) ./...; \ | ||
| else \ | ||
|
Comment on lines
-143
to
-145
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplifies the logic down to one GOSEC call |
||
| @if ! command -v $(GOSEC) > /dev/null 2>&1; then \ | ||
| echo "gosec not found. Installing..."; \ | ||
| go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest; \ | ||
| $(GOSEC) ./...; \ | ||
| $(GOINSTALL) $(ARTIFACT_GOSEC); \ | ||
| fi | ||
| $(GOSEC) ./... | ||
|
|
||
| # Clean build artifacts | ||
| .PHONY: clean | ||
|
|
@@ -167,7 +169,7 @@ deps: | |
| .PHONY: deps-update | ||
| deps-update: | ||
| @echo "Updating dependencies..." | ||
| $(GOMOD) get -u ./... | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| $(GOCMD) get -u ./... | ||
| $(GOMOD) tidy | ||
|
|
||
| # Verify dependencies | ||
|
|
@@ -190,8 +192,8 @@ check: lint vet fmt-check test | |
| .PHONY: install-tools | ||
| install-tools: | ||
| @echo "Installing development tools..." | ||
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
| go install github.com/securecodewarrior/gosec/v2/cmd/gosec@latest | ||
| $(GOINSTALL) $(ARTIFACT_GOLINT) | ||
| $(GOINSTALL) $(ARTIFACT_GOSEC) | ||
|
Comment on lines
+195
to
+196
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reference the tooling as variables |
||
|
|
||
| # Show help | ||
| .PHONY: help | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinning these to make the associated targets run much faster -- though we should consider upgrading golangci-lint to v2.