-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
56 lines (46 loc) · 1.85 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
PLATFORM := $(shell uname)
NAME := $(shell basename $(CURDIR))
GOFMT_FILES ?= $$(find ./ -name '*.go' | grep -v vendor | grep -v externalmodels)
GOTEST_DIRECTORIES ?= $$(find ./internal/ -type f -iname "*_test.go" -exec dirname {} \; | uniq)
PACT_VERSION ?= "1.88.90"
export GOPRIVATE=github.com/form3tech-oss
export GOFLAGS=-mod=vendor
DOCKER_IMG ?= form3tech/pact-proxy
ifeq (${PLATFORM},Darwin)
PACT_FILE := "pact-${PACT_VERSION}-osx.tar.gz"
else
PACT_FILE := "pact-${PACT_VERSION}-linux-x86_64.tar.gz"
endif
.PHONY: build
build:
@echo "==> Building..."
@go install ./...
.PHONY: test
test: install-pact
@echo "==> Executing tests..."
@echo ${GOTEST_DIRECTORIES} | xargs -n1 go test --timeout 30m -v -count 1
.PHONY: goimports
goimports: install-goimports
goimports -w $(GOFMT_FILES)
.PHONY: install-goimports
install-goimports:
@type goimports >/dev/null 2>&1 || (cd /tmp && go get golang.org/x/tools/cmd/goimports && cd -)
.PHONY: vendor
vendor:
@go mod tidy && go mod vendor && go mod verify
.PHONY: install-pact
install-pact:
@if [ ! -d ./pact ]; then \
echo "pact not installed, installing..."; \
curl -sSLf https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v${PACT_VERSION}/${PACT_FILE} -o /tmp/pactserver.tar.gz && tar -xzf /tmp/pactserver.tar.gz 2>/dev/null -C .; \
fi
.PHONY: publish
publish:
@echo "==> Building docker image..."
docker build --build-arg APPNAME=pact-proxy -f build/package/pact-proxy/Dockerfile -t $(DOCKER_IMG):$(DOCKER_TAG) .
@echo "==> Logging in to the docker registry..."
echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
@echo "==> Pushing built image..."
docker push $(DOCKER_IMG):$(DOCKER_TAG)
docker tag $(DOCKER_IMG):$(DOCKER_TAG) $(DOCKER_IMG):latest
docker push $(DOCKER_IMG):latest