Skip to content

Commit

Permalink
Updated common go files
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Oct 3, 2020
1 parent 2bd14cf commit 9a1a295
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
9 changes: 8 additions & 1 deletion .make/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ ifndef GIT_DOMAIN
override GIT_DOMAIN=github.com
endif

## Set if defined (alias variable for ease of use)
ifdef branch
override REPO_BRANCH=$(branch)
export REPO_BRANCH
endif

## Do we have git available?
HAS_GIT := $(shell command -v git 2> /dev/null)

Expand All @@ -12,7 +18,8 @@ ifdef HAS_GIT
ifdef HAS_REPO
## Automatically detect the repo owner and repo name (for local use with Git)
REPO_NAME=$(shell basename "$(shell git rev-parse --show-toplevel 2> /dev/null)")
REPO_OWNER=$(shell git config --get remote.origin.url | sed 's/git@$(GIT_DOMAIN)://g' | sed 's/\/$(REPO_NAME).git//g')
OWNER=$(shell git config --get remote.origin.url | sed 's/git@$(GIT_DOMAIN)://g' | sed 's/\/$(REPO_NAME).git//g')
REPO_OWNER=$(shell echo $(OWNER) | tr A-Z a-z)
VERSION_SHORT=$(shell git describe --tags --always --abbrev=0)
export REPO_NAME, REPO_OWNER, VERSION_SHORT
endif
Expand Down
21 changes: 13 additions & 8 deletions .make/Makefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ DARWIN=$(BINARY_NAME)-darwin
LINUX=$(BINARY_NAME)-linux
WINDOWS=$(BINARY_NAME)-windows.exe

.PHONY: test lint install
.PHONY: test lint vet install

bench: ## Run all benchmarks in the Go application
@go test -bench=. -benchmem
Expand All @@ -40,28 +40,29 @@ install: ## Install the application
install-go: ## Install the application (Using Native Go)
@go install $(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME)

lint: ## Run the Go lint application
@if [ "$(shell command -v golint)" = "" ]; then go get -u golang.org/x/lint/golint; fi
@golint
lint: ## Run the golangci-lint application (install if not found)
@if [ "$(shell command -v golangci-lint)" = "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.31.0 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi;
@echo "running golangci-lint..."
@golangci-lint run

test: ## Runs vet, lint and ALL tests
@$(MAKE) vet
@$(MAKE) lint
@echo "running tests..."
@go test ./... -v

test-short: ## Runs vet, lint and tests (excludes integration tests)
@$(MAKE) vet
@$(MAKE) lint
@echo "running tests (short)..."
@go test ./... -v -test.short

test-travis: ## Runs all tests via Travis (also exports coverage)
@$(MAKE) vet
@$(MAKE) lint
@echo "running tests..."
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic

test-travis-short: ## Runs unit tests via Travis (also exports coverage)
@$(MAKE) vet
@$(MAKE) lint
@echo "running tests (short)..."
@go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic

uninstall: ## Uninstall the application (and remove files)
Expand All @@ -76,5 +77,9 @@ uninstall: ## Uninstall the application (and remove files)
update: ## Update all project dependencies
@go get -u ./... && go mod tidy

update-linter: ## Update the golangci-lint package (macOS only)
@brew upgrade golangci-lint

vet: ## Run the Go vet application
@echo "running go vet..."
@go vet -v ./...

0 comments on commit 9a1a295

Please sign in to comment.