-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
68 lines (56 loc) · 2.62 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
.DEFAULT_GOAL:=help
#============================================================================
# Load environment variables for local development
include .env
export
#============================================================================
.PHONY: dev
dev: ## Run dev container
@docker compose ls -q | grep -q "instill-core" && true || \
(echo "Error: Run \"make latest PROFILE=exclude-model\" in model repository (https://github.com/instill-ai/instill-core) in your local machine first." && exit 1)
@docker inspect --type container ${SERVICE_NAME} >/dev/null 2>&1 && echo "A container named ${SERVICE_NAME} is already running." || \
echo "Run dev container ${SERVICE_NAME}. To stop it, run \"make stop\"."
@docker run -d --rm \
-v $(PWD):/${SERVICE_NAME} \
-v model-config:/model-config \
-p ${SERVICE_PORT}:${SERVICE_PORT} \
-p ${PRIVATE_SERVICE_PORT}:${PRIVATE_SERVICE_PORT} \
--network instill-network \
--name ${SERVICE_NAME} \
instill/${SERVICE_NAME}:dev
.PHONY: logs
logs: ## Tail container logs with -n 10
@docker logs ${SERVICE_NAME} --follow --tail=10
.PHONY: stop
stop: ## Stop container
@docker stop -t 1 ${SERVICE_NAME}
.PHONY: top
top: ## Display all running service processes
@docker top ${SERVICE_NAME}
.PHONY: build
build: ## Build dev docker image
@docker build \
--build-arg SERVICE_NAME=${SERVICE_NAME} \
--build-arg K6_VERSION=${K6_VERSION} \
-f Dockerfile.dev -t instill/${SERVICE_NAME}:dev .
.PHONY: go-gen
go-gen: ## Generate codes
go generate ./...
.PHONY: unit-test
unit-test: ## Run unit test
@go test -v -race -coverpkg=./... -coverprofile=coverage.out ./...
@go tool cover -func=coverage.out
@go tool cover -html=coverage.out
@rm coverage.out
.PHONY: integration-test
integration-test: ## Run integration test
@TEST_FOLDER_ABS_PATH=${PWD} k6 run \
-e API_GATEWAY_PROTOCOL=${API_GATEWAY_PROTOCOL} -e API_GATEWAY_URL=${API_GATEWAY_URL} integration-test/grpc.js --no-usage-report --quiet
@TEST_FOLDER_ABS_PATH=${PWD} k6 run \
-e API_GATEWAY_PROTOCOL=${API_GATEWAY_PROTOCOL} -e API_GATEWAY_URL=${API_GATEWAY_URL} integration-test/rest.js --no-usage-report --quiet
@TEST_FOLDER_ABS_PATH=${PWD} k6 run \
-e API_GATEWAY_PROTOCOL=${API_GATEWAY_PROTOCOL} -e API_GATEWAY_URL=${API_GATEWAY_URL} integration-test/rest_with_jwt.js --no-usage-report --quiet
.PHONY: help
help: ## Show this help
@echo "\nMakefile for local development"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)