forked from gojek/proctor
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
135 lines (104 loc) · 4.08 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
SHELL := /bin/bash
#!make
include .env.test
export $(shell sed 's/=.*//' .env.test)
.EXPORT_ALL_VARIABLES:
SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
OUT_DIR := $(SRC_DIR)/_output
BIN_DIR := $(OUT_DIR)/bin
PLUGIN_DIR := $(BIN_DIR)/plugin
FTEST_DIR := test/procs
CONFIG_DIR := test/config
GOPROXY ?= https://proxy.golang.org
GO111MODULE := on
CONFIG_LOCATION := $(SRC_DIR)
$(@info $(shell mkdir -p $(OUT_DIR) $(BIN_DIR) $(PLUGIN_DIR))
.PHONY: build
build: test-with-race server cli
.PHONY: test-with-race
test-with-race: RACE_FLAG = -race
test-with-race: test
.PHONY: test
test:
ENABLE_INTEGRATION_TEST=false \
go test -race -coverprofile=$(OUT_DIR)/coverage.out ./...
.PHONY: itest
itest: plugin.auth plugin.slack
PROCTOR_AUTH_PLUGIN_BINARY=$(PLUGIN_DIR)/auth.so \
PROCTOR_NOTIFICATION_PLUGIN_BINARY=$(PLUGIN_DIR)/slack.so \
ENABLE_INTEGRATION_TEST=true \
go test -p 1 -race -coverprofile=$(OUT_DIR)/coverage.out ./...
.PHONY: plugin.itest
plugin.itest: plugin.auth plugin.slack
PROCTOR_AUTH_PLUGIN_BINARY=$(PLUGIN_DIR)/auth.so \
PROCTOR_NOTIFICATION_PLUGIN_BINARY=$(PLUGIN_DIR)/slack.so \
ENABLE_PLUGIN_INTEGRATION_TEST=true \
go test -race -coverprofile=$(OUT_DIR)/coverage.out ./...
.PHONY: server
server:
PROCTOR_AUTH_PLUGIN_BINARY=$(PLUGIN_DIR)/auth.so \
go build -race -o $(BIN_DIR)/server ./cmd/server/main.go
.PHONY: plugin.auth
plugin.auth:
go build -race -buildmode=plugin -o $(PLUGIN_DIR)/auth.so ./plugins/gate-auth-plugin/auth.go
.PHONY: plugin.slack
plugin.slack:
go build -race -buildmode=plugin -o $(PLUGIN_DIR)/slack.so ./plugins/slack-notification-plugin/slack_notification.go
.PHONY: cli
cli:
go build -race -o $(BIN_DIR)/cli ./cmd/cli/main.go
build-all: server cli plugin.auth plugin.slack
.PHONY: start-server
start-server:
PROCTOR_AUTH_PLUGIN_BINARY=$(PLUGIN_DIR)/auth.so \
PROCTOR_NOTIFICATION_PLUGIN_BINARY=$(PLUGIN_DIR)/slack.so \
$(BIN_DIR)/server s
generate:
go get -u github.com/go-bindata/go-bindata/...
$(GOPATH)/bin/go-bindata -pkg config -o internal/app/cli/config/data.go internal/app/cli/config_template.yaml
db.setup: db.create db.migrate
db.create:
PGPASSWORD=$(PROCTOR_POSTGRES_PASSWORD) psql -h $(PROCTOR_POSTGRES_HOST) -p $(PROCTOR_POSTGRES_PORT) -c 'create database $(PROCTOR_POSTGRES_DATABASE);' -U $(PROCTOR_POSTGRES_USER)
db.migrate: server
$(BIN_DIR)/server migrate
db.rollback: server
$(BIN_DIR)/server rollback
db.teardown:
-PGPASSWORD=$(PROCTOR_POSTGRES_PASSWORD) psql -h $(PROCTOR_POSTGRES_HOST) -p $(PROCTOR_POSTGRES_PORT) -c 'drop database $(PROCTOR_POSTGRES_DATABASE);' -U $(PROCTOR_POSTGRES_USER)
redis-cli FLUSHALL
.PHONY: ftest.package.procs
ftest.package.procs:
PROCTOR_JOBS_PATH=$(FTEST_DIR) \
ruby ./test/package_procs.rb
.PHONY: ftest.update.metadata
ftest.update.metadata:
PROCTOR_JOBS_PATH=$(FTEST_DIR) \
PROCTOR_URI=http://localhost:$(PROCTOR_APP_PORT)/metadata \
ruby ./test/update_metadata.rb
.PHONY: ftest.update.secret
ftest.update.secret:
curl -X POST \
http://localhost:5000/secret \
-H 'Content-Type: application/json' \
-d '{"job_name": "say-hello-world","secrets": {"SAMPLE_SECRET_ONE": "Secret One :*","SAMPLE_SECRET_TWO": "Secret Two :V"}}'
.PHONY: ftest.proctor.list
ftest.proctor.list:
LOCAL_CONFIG_DIR=$(CONFIG_DIR) $(BIN_DIR)/cli list
.PHONY: ftest.proctor.describe
ftest.proctor.describe:
LOCAL_CONFIG_DIR=$(CONFIG_DIR) $(BIN_DIR)/cli describe say-hello-world
.PHONY: ftest.proctor.template
ftest.proctor.template:
LOCAL_CONFIG_DIR=$(CONFIG_DIR) $(BIN_DIR)/cli template say-hello-world say-hello-world.yaml
.PHONY: ftest.proctor.execute
ftest.proctor.execute:
LOCAL_CONFIG_DIR=$(CONFIG_DIR) $(BIN_DIR)/cli execute say-hello-world SAMPLE_ARG_ONE=foo SAMPLE_ARG_TWO=bar
.PHONY: ftest.proctor.execute-with-yaml
ftest.proctor.execute-with-yaml:
LOCAL_CONFIG_DIR=$(CONFIG_DIR) $(BIN_DIR)/cli execute say-hello-world -f $(FTEST_DIR)/say-hello-world/say_hello_world.yaml
.PHONY: ftest.proctor.logs
ftest.proctor.logs:
LOCAL_CONFIG_DIR=$(CONFIG_DIR) $(BIN_DIR)/cli logs $(EXECUTION_ID)
.PHONY: ftest.proctor.status
ftest.proctor.status:
LOCAL_CONFIG_DIR=$(CONFIG_DIR) $(BIN_DIR)/cli status $(EXECUTION_ID)