Skip to content

Commit 68c03a4

Browse files
committed
Updated makefile
1 parent 4d4983b commit 68c03a4

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

.make/go.mk

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,33 @@ DARWIN=$(BINARY_NAME)-darwin
1313
LINUX=$(BINARY_NAME)-linux
1414
WINDOWS=$(BINARY_NAME)-windows.exe
1515

16+
## Define the binary name
17+
TAGS=
18+
ifdef GO_BUILD_TAGS
19+
override TAGS=-tags $(GO_BUILD_TAGS)
20+
endif
21+
1622
.PHONY: test lint vet install generate
1723

1824
bench: ## Run all benchmarks in the Go application
1925
@echo "running benchmarks..."
20-
@go test -bench=. -benchmem
26+
@go test -bench=. -benchmem $(TAGS)
2127

2228
build-go: ## Build the Go application (locally)
2329
@echo "building go app..."
24-
@go build -o bin/$(BINARY_NAME)
30+
@go build -o bin/$(BINARY_NAME) $(TAGS)
2531

2632
clean-mods: ## Remove all the Go mod cache
2733
@echo "cleaning mods..."
2834
@go clean -modcache
2935

3036
coverage: ## Shows the test coverage
3137
@echo "creating coverage report..."
32-
@go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out
38+
@go test -coverprofile=coverage.out ./... $(TAGS) && go tool cover -func=coverage.out $(TAGS)
3339

3440
generate: ## Runs the go generate command in the base of the repo
3541
@echo "generating files..."
36-
@go generate -v
42+
@go generate -v $(TAGS)
3743

3844
godocs: ## Sync the latest tag with GoDocs
3945
@echo "syndicating to GoDocs..."
@@ -45,59 +51,59 @@ godocs: ## Sync the latest tag with GoDocs
4551

4652
install: ## Install the application
4753
@echo "installing binary..."
48-
@go build -o $$GOPATH/bin/$(BINARY_NAME)
54+
@go build -o $$GOPATH/bin/$(BINARY_NAME) $(TAGS)
4955

5056
install-go: ## Install the application (Using Native Go)
5157
@echo "installing package..."
52-
@go install $(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME)
58+
@go install $(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME) $(TAGS)
5359

5460
lint: ## Run the golangci-lint application (install if not found)
5561
@echo "installing golangci-lint..."
5662
@#Travis (has sudo)
57-
@if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.42.1 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi;
63+
@if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.44.0 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi;
5864
@#AWS CodePipeline
59-
@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.42.1; fi;
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.44.0; fi;
6066
@#Github Actions
61-
@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.42.1; fi;
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.44.0; fi;
6268
@#Brew - MacOS
6369
@if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then brew install golangci-lint; fi;
6470
@#MacOS Vanilla
65-
@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.42.1; fi;
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.44.0; fi;
6672
@echo "running golangci-lint..."
6773
@golangci-lint run --verbose
6874

6975
test: ## Runs lint and ALL tests
7076
@$(MAKE) lint
7177
@echo "running tests..."
72-
@go test ./... -v
78+
@go test ./... -v $(TAGS)
7379

7480
test-unit: ## Runs tests and outputs coverage
7581
@echo "running unit tests..."
76-
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic
82+
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic $(TAGS)
7783

7884
test-short: ## Runs vet, lint and tests (excludes integration tests)
7985
@$(MAKE) lint
8086
@echo "running tests (short)..."
81-
@go test ./... -v -test.short
87+
@go test ./... -v -test.short $(TAGS)
8288

8389
test-ci: ## Runs all tests via CI (exports coverage)
8490
@$(MAKE) lint
8591
@echo "running tests (CI)..."
86-
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic
92+
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic $(TAGS)
8793

8894
test-ci-no-race: ## Runs all tests via CI (no race) (exports coverage)
8995
@$(MAKE) lint
9096
@echo "running tests (CI - no race)..."
91-
@go test ./... -coverprofile=coverage.txt -covermode=atomic
97+
@go test ./... -coverprofile=coverage.txt -covermode=atomic $(TAGS)
9298

9399
test-ci-short: ## Runs unit tests via CI (exports coverage)
94100
@$(MAKE) lint
95101
@echo "running tests (CI - unit tests only)..."
96-
@go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic
102+
@go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic $(TAGS)
97103

98104
test-no-lint: ## Runs just tests
99105
@echo "running tests..."
100-
@go test ./... -v
106+
@go test ./... -v $(TAGS)
101107

102108
uninstall: ## Uninstall the application (and remove files)
103109
@echo "uninstalling go application..."
@@ -119,4 +125,4 @@ update-linter: ## Update the golangci-lint package (macOS only)
119125

120126
vet: ## Run the Go vet application
121127
@echo "running go vet..."
122-
@go vet -v ./...
128+
@go vet -v ./... $(TAGS)

0 commit comments

Comments
 (0)