-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
90 lines (72 loc) · 2.73 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
SHELL := /bin/bash
ROOT := $(shell git rev-parse --show-toplevel)
GO_FILES := $(shell find . -name "*.go" -not -path "./build/*" -not -path "**/vendor/*")
ifeq ($(TAG),)
VERSION ?= $(shell git describe --dirty="-dev")
else
VERSION = $(TAG)
endif
.DEFAULT_GOAL := error
.PHONY: error
error:
@echo "Please check 'README.md' for instructions on how to build and deploy 'github-team-approver'."
@exit 2
SKAFFOLD_VERSION ?= v1.6.0
platform := $(shell uname)
pact_version := 1.64.0
ifeq (${platform},Darwin)
pact_filename := "pact-${pact_version}-osx.tar.gz"
skaffold_url := https://storage.googleapis.com/skaffold/releases/$(SKAFFOLD_VERSION)/skaffold-darwin-amd64
else
pact_filename := "pact-${pact_version}-linux-x86_64.tar.gz"
skaffold_url := https://storage.googleapis.com/skaffold/releases/$(SKAFFOLD_VERSION)/skaffold-linux-amd64
endif
.PHONY: install-goimports
install-goimports:
go install golang.org/x/tools/cmd/goimports@latest
.PHONY: install-skaffold
install-skaffold:
@curl -Lo skaffold-bin ${skaffold_url}
@chmod +x skaffold-bin
@sudo mv skaffold-bin /usr/local/bin/skaffold
pact:
curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v${pact_version}/${pact_filename}
tar xzf ${pact_filename}
rm ${pact_filename}
.PHONY: dep
dep:
cd github-team-approver && dep ensure -v
.PHONY: goimports
goimports: install-goimports
goimports -w $(GO_FILES)
goimports-check: install-goimports
./hack/goimports-check.sh
.PHONY: secret
secret: GITHUB_APP_PRIVATE_KEY_PATH ?= $(ROOT)/github-app-private-key
secret: GITHUB_APP_WEBHOOK_SECRET_TOKEN_PATH ?= $(ROOT)/github-app-webhook-secret-token
secret: NAMESPACE ?= github-team-approver
secret:
@kubectl -n $(NAMESPACE) create secret generic github-team-approver \
--from-file github-app-private-key=$(GITHUB_APP_PRIVATE_KEY_PATH) \
--from-file github-app-webhook-secret-token=$(GITHUB_APP_WEBHOOK_SECRET_TOKEN_PATH) \
--dry-run \
-o yaml | kubectl apply -n $(NAMESPACE) -f-
.PHONY: docker.login
docker.login:
@echo $(DOCKER_HUB_PASSWORD) | docker login --username $(DOCKER_HUB_USERNAME) --password-stdin
.PHONY: skaffold.dev
skaffold.dev: GITHUB_APP_ID ?=
skaffold.dev: GITHUB_APP_INSTALLATION_ID ?=
skaffold.dev: NAMESPACE ?= github-team-approver
skaffold.dev:
@GITHUB_APP_ID=$(GITHUB_APP_ID) GITHUB_APP_INSTALLATION_ID=$(GITHUB_APP_INSTALLATION_ID) NAMESPACE=$(NAMESPACE) $(ROOT)/hack/helm-pre-skaffold-template.sh
@skaffold dev
.PHONY: test
test: EXAMPLES_DIR := $(ROOT)/examples/github
test: pact
EXAMPLES_DIR=$(EXAMPLES_DIR) \
GITHUB_APP_WEBHOOK_SECRET_TOKEN_PATH=$(EXAMPLES_DIR)/token.txt \
GITHUB_STATUS_NAME=github-team-approver \
SLACK_WEBHOOK_SECRET=$(EXAMPLES_DIR)/slack_webhook.txt \
RUN_PACT_TESTS=1 \
go test ./internal/... -count 1 -cover -v