-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (73 loc) · 2.58 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright 2022 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
SHELL = /bin/bash
default: build
# #### GO Binary Management ####
.PHONY: deps-go-binary deps-counterfeiter deps-ginkgo deps-golangci-lint
GO_VERSION := $(shell go version)
GO_VERSION_REQUIRED = go1.18
GO_VERSION_MATCHED := $(shell go version | grep $(GO_VERSION_REQUIRED))
deps-go-binary:
ifndef GO_VERSION
$(error Go not installed)
endif
ifndef GO_VERSION_MATCHED
$(error Required Go version is $(GO_VERSION_REQUIRED), but was $(GO_VERSION))
endif
@:
HAS_COUNTERFEITER := $(shell command -v counterfeiter;)
HAS_GINKGO := $(shell command -v ginkgo;)
HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;)
PLATFORM := $(shell uname -s)
deps-counterfeiter: deps-go-binary
ifndef HAS_COUNTERFEITER
go install github.com/maxbrunsfeld/counterfeiter/v6@latest
endif
deps-ginkgo: deps-go-binary
ifndef HAS_GINKGO
go install github.com/onsi/ginkgo/ginkgo@latest
endif
deps-golangci-lint: deps-go-binary
ifndef HAS_GOLANGCI_LINT
ifeq ($(PLATFORM), Darwin)
brew install golangci-lint
endif
ifeq ($(PLATFORM), Linux)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
endif
endif
# #### CLEAN ####
.PHONY: clean
clean: deps-go-binary
rm -rf build/*
go clean --modcache
# #### DEPS ####
.PHONY: deps deps-counterfeiter deps-ginkgo deps-modules
deps-modules: deps-go-binary
go mod download
deps: deps-modules deps-counterfeiter deps-ginkgo
# #### BUILD ####
.PHONY: build
SRC = $(shell find . -name "*.go" | grep -v "_test\." )
VERSION := $(or $(VERSION), dev)
LDFLAGS="-X github.com/vmware-labs/marketplace-cli/v2/cmd.version=$(VERSION)"
build/check: $(SRC)
go build -o build/check -ldflags "-X vmware-samples/concourse-resource-for-marketplace/m/v2/cmd.cmdToExecute=check" ./main.go
build/in: $(SRC)
go build -o build/in -ldflags "-X vmware-samples/concourse-resource-for-marketplace/m/v2/cmd.cmdToExecute=in" ./main.go
build/out: $(SRC)
go build -o build/out -ldflags "-X vmware-samples/concourse-resource-for-marketplace/m/v2/cmd.cmdToExecute=out" ./main.go
build: deps build/check build/in build/out
build-image: Dockerfile
docker build . --tag harbor-repo.vmware.com/tanzu_isv_engineering/mkpcli_concourse_resource:$(VERSION)
# #### TESTS ####
.PHONY: lint test test-features test-units
test-units: deps
ginkgo -r .
test: deps lint test-units
lint: deps-golangci-lint
golangci-lint run
# #### DEVOPS ####
.PHONY: set-pipeline
set-pipeline: ci/pipeline.yaml
fly -t tie set-pipeline --config ci/pipeline.yaml --pipeline marketplace-concourse-resource