@@ -19,28 +19,32 @@ ifdef GO_BUILD_TAGS
19
19
override TAGS=-tags $(GO_BUILD_TAGS)
20
20
endif
21
21
22
- .PHONY : test lint vet install generate
23
-
22
+ .PHONY : bench
24
23
bench : # # Run all benchmarks in the Go application
25
24
@echo " running benchmarks..."
26
25
@go test -bench=. -benchmem $(TAGS )
27
26
27
+ .PHONY : build-go
28
28
build-go : # # Build the Go application (locally)
29
29
@echo " building go app..."
30
30
@go build -o bin/$(BINARY_NAME ) $(TAGS )
31
31
32
+ .PHONY : clean-mods
32
33
clean-mods : # # Remove all the Go mod cache
33
34
@echo " cleaning mods..."
34
35
@go clean -modcache
35
36
37
+ .PHONY : coverage
36
38
coverage : # # Shows the test coverage
37
39
@echo " creating coverage report..."
38
40
@go test -coverprofile=coverage.out ./... $(TAGS ) && go tool cover -func=coverage.out $(TAGS )
39
41
42
+ .PHONY : generate
40
43
generate : # # Runs the go generate command in the base of the repo
41
44
@echo " generating files..."
42
45
@go generate -v $(TAGS )
43
46
47
+ .PHONY : godocs
44
48
godocs : # # Sync the latest tag with GoDocs
45
49
@echo " syndicating to GoDocs..."
46
50
@test $(GIT_DOMAIN )
@@ -49,62 +53,73 @@ godocs: ## Sync the latest tag with GoDocs
49
53
@test $(VERSION_SHORT )
50
54
@curl https://proxy.golang.org/$(GIT_DOMAIN ) /$(REPO_OWNER ) /$(REPO_NAME ) /@v/$(VERSION_SHORT ) .info
51
55
56
+ .PHONY : install
52
57
install : # # Install the application
53
58
@echo " installing binary..."
54
59
@go build -o $$ GOPATH/bin/$(BINARY_NAME ) $(TAGS )
55
60
61
+ .PHONY : install-go
56
62
install-go : # # Install the application (Using Native Go)
57
63
@echo " installing package..."
58
64
@go install $(GIT_DOMAIN ) /$(REPO_OWNER ) /$(REPO_NAME ) $(TAGS )
59
65
66
+ .PHONY : lint
60
67
lint : # # Run the golangci-lint application (install if not found)
61
68
@echo " installing golangci-lint..."
62
69
@# 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 ;
64
71
@# 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 ;
68
75
@# Brew - MacOS
69
76
@if [ " $( shell command -v golangci-lint) " = " " ] && [ " $( shell command -v brew) " != " " ]; then brew install golangci-lint; fi ;
70
77
@# 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 ;
72
79
@echo " running golangci-lint..."
73
80
@golangci-lint run --verbose
74
81
82
+ .PHONY : test
75
83
test : # # Runs lint and ALL tests
76
84
@$(MAKE ) lint
77
85
@echo " running tests..."
78
86
@go test ./... -v $(TAGS )
79
87
88
+ .PHONY : test-unit
80
89
test-unit : # # Runs tests and outputs coverage
81
90
@echo " running unit tests..."
82
91
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic $(TAGS )
83
92
93
+ .PHONY : test-short
84
94
test-short : # # Runs vet, lint and tests (excludes integration tests)
85
95
@$(MAKE ) lint
86
96
@echo " running tests (short)..."
87
97
@go test ./... -v -test.short $(TAGS )
88
98
99
+ .PHONY : test-ci
89
100
test-ci : # # Runs all tests via CI (exports coverage)
90
101
@$(MAKE ) lint
91
102
@echo " running tests (CI)..."
92
103
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic $(TAGS )
93
104
105
+ .PHONY : test-ci-no-race
94
106
test-ci-no-race : # # Runs all tests via CI (no race) (exports coverage)
95
107
@$(MAKE ) lint
96
108
@echo " running tests (CI - no race)..."
97
109
@go test ./... -coverprofile=coverage.txt -covermode=atomic $(TAGS )
98
110
111
+ .PHONY : test-ci-short
99
112
test-ci-short : # # Runs unit tests via CI (exports coverage)
100
113
@$(MAKE ) lint
101
114
@echo " running tests (CI - unit tests only)..."
102
115
@go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic $(TAGS )
103
116
117
+ .PHONY : test-no-lint
104
118
test-no-lint : # # Runs just tests
105
119
@echo " running tests..."
106
120
@go test ./... -v $(TAGS )
107
121
122
+ .PHONY : uninstall
108
123
uninstall : # # Uninstall the application (and remove files)
109
124
@echo " uninstalling go application..."
110
125
@test $(BINARY_NAME )
@@ -115,14 +130,17 @@ uninstall: ## Uninstall the application (and remove files)
115
130
@rm -rf $$ GOPATH/src/$(GIT_DOMAIN ) /$(REPO_OWNER ) /$(REPO_NAME )
116
131
@rm -rf $$ GOPATH/bin/$(BINARY_NAME )
117
132
133
+ .PHONY : update
118
134
update : # # Update all project dependencies
119
135
@echo " updating dependencies..."
120
136
@go get -u ./... && go mod tidy
121
137
138
+ .PHONY : update-linter
122
139
update-linter : # # Update the golangci-lint package (macOS only)
123
140
@echo " upgrading golangci-lint..."
124
141
@brew upgrade golangci-lint
125
142
143
+ .PHONY : vet
126
144
vet : # # Run the Go vet application
127
145
@echo " running go vet..."
128
146
@go vet -v ./... $(TAGS )
0 commit comments