forked from jenkins-x/prow-pipeline-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (54 loc) · 1.82 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
SHELL := /bin/bash
OS := $(shell uname | tr '[:upper:]' '[:lower:]')
GO_VARS := GO111MODULE=on GO15VENDOREXPERIMENT=1 CGO_ENABLED=0
BUILDFLAGS := ''
APP_NAME := pipeline
MAIN := cmd/pipeline/main.go
BUILD_DIR=build
PACKAGE_DIRS := $(shell go list ./...)
PKGS := $(subst :,_,$(PACKAGE_DIRS))
PLATFORMS := windows linux darwin
os = $(word 1, $@)
IMAGE_NAME ?= jenkinsxio/prow-pipeline-controller
VERSION ?= $(shell cat VERSION)
GOMMIT_START_SHA ?= bd117413980c6f62ef9fa3361d532a164da8ac2a
FGT := $(GOPATH)/bin/fgt
GOLINT := $(GOPATH)/bin/golint
GOMMIT := $(GOPATH)/bin/gommit
.PHONY : all
all: linux test check ## Compiles, test and verifies source
.PHONY: $(PLATFORMS)
$(PLATFORMS):
$(GO_VARS) GOOS=$(os) GOARCH=amd64 go build -ldflags $(BUILDFLAGS) -o $(BUILD_DIR)/$(APP_NAME) $(MAIN)
.PHONY : test
test: ## Runs unit tests
$(GO_VARS) go test -v ./...
.PHONY : fmt
fmt: ## Re-formates Go source files according to standard
@$(GO_VARS) go fmt ./...
.PHONY : clean
clean: ## Deletes the build directory with all generated artefacts
rm -rf $(BUILD_DIR)
check: $(GOLINT) $(FGT) $(GOMMIT)
@echo "LINTING"
@$(FGT) $(GOLINT) ./...
@echo "VETTING"
@$(GO_VARS) $(FGT) go vet ./...
@echo "CONVENTIONAL COMMIT CHECK"
@$(GOMMIT) check range $(GOMMIT_START_SHA) $$(git log --pretty=format:'%H' -n 1)
.PHONY : run
run: $(OS) ## Runs the app locally
$(BUILD_DIR)/$(APP_NAME)
.PHONY: docker
docker: linux ## Runs local Docker build of image
docker build -t $(IMAGE_NAME):$(VERSION) .
.PHONY: help
help: ## Prints this help
@grep -E '^[^.]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}'
# Targets to get some Go tools
$(FGT):
@$(GO_VARS) go get github.com/GeertJohan/fgt
$(GOLINT):
@$(GO_VARS) go get golang.org/x/lint/golint
$(GOMMIT):
@$(GO_VARS) go get github.com/antham/gommit