Skip to content

Commit

Permalink
chore: Add makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyno-zeta committed Sep 6, 2020
1 parent 9db75ce commit 31e40d0
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
PROJECT_NAME := gomock-extra-matcher
PKG := github.com/oxyno-zeta/$(PROJECT_NAME)

# go option
GO ?= go
# Uncomment to enable vendor
GO_VENDOR := # -mod=vendor

# Required for globs to work correctly
SHELL=/usr/bin/env bash

# Version

HAS_GORELEASER := $(shell command -v goreleaser;)
HAS_GIT := $(shell command -v git;)
HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;)
HAS_CURL:=$(shell command -v curl;)

.DEFAULT_GOAL := code/lint

#############
# Build #
#############

.PHONY: code/lint
code/lint: setup/dep/install
golangci-lint run ./...

#############
# Tests #
#############

.PHONY: test/unit
test/unit: setup/dep/install
$(GO) test $(GO_VENDOR) -v -coverpkg=./pkg/... -coverprofile=c.out.tmp ./pkg/...

.PHONY: test/coverage
test/coverage:
cat c.out.tmp | grep -v "mock_" > c.out
$(GO) tool cover -html=c.out -o coverage.html
$(GO) tool cover -func c.out

#############
# Setup #
#############

.PHONY: setup/generate
setup/generate:
$(GO) $(GO_VENDOR) generate ./...

.PHONY: setup/dep/install
setup/dep/install:
ifndef HAS_GOLANGCI_LINT
@echo "=> Installing golangci-lint tool"
ifndef HAS_CURL
$(error You must install curl)
endif
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.30.0
endif
ifndef HAS_GIT
$(error You must install Git)
endif
go mod download
go mod tidy

.PHONY: setup/dep/update
setup/dep/update:
$(GO) get -u ./...

.PHONY: setup/dep/vendor
setup/dep/vendor:
$(GO) mod vendor

0 comments on commit 31e40d0

Please sign in to comment.