Skip to content

Commit c67be17

Browse files
committed
Updated makefile, updated linter
1 parent 82a044d commit c67be17

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

.make/go.mk

+25-7
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,32 @@ ifdef GO_BUILD_TAGS
1919
override TAGS=-tags $(GO_BUILD_TAGS)
2020
endif
2121

22-
.PHONY: test lint vet install generate
23-
22+
.PHONY: bench
2423
bench: ## Run all benchmarks in the Go application
2524
@echo "running benchmarks..."
2625
@go test -bench=. -benchmem $(TAGS)
2726

27+
.PHONY: build-go
2828
build-go: ## Build the Go application (locally)
2929
@echo "building go app..."
3030
@go build -o bin/$(BINARY_NAME) $(TAGS)
3131

32+
.PHONY: clean-mods
3233
clean-mods: ## Remove all the Go mod cache
3334
@echo "cleaning mods..."
3435
@go clean -modcache
3536

37+
.PHONY: coverage
3638
coverage: ## Shows the test coverage
3739
@echo "creating coverage report..."
3840
@go test -coverprofile=coverage.out ./... $(TAGS) && go tool cover -func=coverage.out $(TAGS)
3941

42+
.PHONY: generate
4043
generate: ## Runs the go generate command in the base of the repo
4144
@echo "generating files..."
4245
@go generate -v $(TAGS)
4346

47+
.PHONY: godocs
4448
godocs: ## Sync the latest tag with GoDocs
4549
@echo "syndicating to GoDocs..."
4650
@test $(GIT_DOMAIN)
@@ -49,62 +53,73 @@ godocs: ## Sync the latest tag with GoDocs
4953
@test $(VERSION_SHORT)
5054
@curl https://proxy.golang.org/$(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME)/@v/$(VERSION_SHORT).info
5155

56+
.PHONY: install
5257
install: ## Install the application
5358
@echo "installing binary..."
5459
@go build -o $$GOPATH/bin/$(BINARY_NAME) $(TAGS)
5560

61+
.PHONY: install-go
5662
install-go: ## Install the application (Using Native Go)
5763
@echo "installing package..."
5864
@go install $(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME) $(TAGS)
5965

66+
.PHONY: lint
6067
lint: ## Run the golangci-lint application (install if not found)
6168
@echo "installing golangci-lint..."
6269
@#Travis (has sudo)
63-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.46.2 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi;
70+
@if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.48.0 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi;
6471
@#AWS CodePipeline
65-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2; fi;
66-
@#Github Actions
67-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(GITHUB_WORKFLOW)" != "" ]; then curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.46.2; fi;
72+
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.48.0; fi;
73+
@#GitHub Actions
74+
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(GITHUB_WORKFLOW)" != "" ]; then curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.48.0; fi;
6875
@#Brew - MacOS
6976
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then brew install golangci-lint; fi;
7077
@#MacOS Vanilla
71-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.46.2; fi;
78+
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.48.0; fi;
7279
@echo "running golangci-lint..."
7380
@golangci-lint run --verbose
7481

82+
.PHONY: test
7583
test: ## Runs lint and ALL tests
7684
@$(MAKE) lint
7785
@echo "running tests..."
7886
@go test ./... -v $(TAGS)
7987

88+
.PHONY: test-unit
8089
test-unit: ## Runs tests and outputs coverage
8190
@echo "running unit tests..."
8291
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic $(TAGS)
8392

93+
.PHONY: test-short
8494
test-short: ## Runs vet, lint and tests (excludes integration tests)
8595
@$(MAKE) lint
8696
@echo "running tests (short)..."
8797
@go test ./... -v -test.short $(TAGS)
8898

99+
.PHONY: test-ci
89100
test-ci: ## Runs all tests via CI (exports coverage)
90101
@$(MAKE) lint
91102
@echo "running tests (CI)..."
92103
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic $(TAGS)
93104

105+
.PHONY: test-ci-no-race
94106
test-ci-no-race: ## Runs all tests via CI (no race) (exports coverage)
95107
@$(MAKE) lint
96108
@echo "running tests (CI - no race)..."
97109
@go test ./... -coverprofile=coverage.txt -covermode=atomic $(TAGS)
98110

111+
.PHONY: test-ci-short
99112
test-ci-short: ## Runs unit tests via CI (exports coverage)
100113
@$(MAKE) lint
101114
@echo "running tests (CI - unit tests only)..."
102115
@go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic $(TAGS)
103116

117+
.PHONY: test-no-lint
104118
test-no-lint: ## Runs just tests
105119
@echo "running tests..."
106120
@go test ./... -v $(TAGS)
107121

122+
.PHONY: uninstall
108123
uninstall: ## Uninstall the application (and remove files)
109124
@echo "uninstalling go application..."
110125
@test $(BINARY_NAME)
@@ -115,14 +130,17 @@ uninstall: ## Uninstall the application (and remove files)
115130
@rm -rf $$GOPATH/src/$(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME)
116131
@rm -rf $$GOPATH/bin/$(BINARY_NAME)
117132

133+
.PHONY: update
118134
update: ## Update all project dependencies
119135
@echo "updating dependencies..."
120136
@go get -u ./... && go mod tidy
121137

138+
.PHONY: update-linter
122139
update-linter: ## Update the golangci-lint package (macOS only)
123140
@echo "upgrading golangci-lint..."
124141
@brew upgrade golangci-lint
125142

143+
.PHONY: vet
126144
vet: ## Run the Go vet application
127145
@echo "running go vet..."
128146
@go vet -v ./... $(TAGS)

0 commit comments

Comments
 (0)