/
Makefile
119 lines (95 loc) · 3.14 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
# runner
# General purpose Makefile for macos/Linux/WSL2 users
# macOS: `make` should be installed if you have xcode developer tools, if not: xcode-select --install
# Debian/Ubuntu including WSL2: sudo apt-get install build-essential
# Windows (non-WSL2): choco install make or http://gnuwin32.sourceforge.net/install.html
VERSION=v1
MOCK_SERVER_NAME=mock-server
SERVER_NAME=runner-server
DEV_NAME=runner-dev
all:
@echo "runner Makefile targets"
@echo ""
@echo " gen-mocks: create/recreate mocks for unit testing"
@echo ""
@echo " run-api: run the API server"
@echo ""
@echo " run-api-bg: run the API server in the background"
@echo ""
@echo " run-mock: run the mock API server"
@echo ""
@echo " run-mock-bg: run the mock API server in the background"
@echo ""
@echo " kill-api: kill the API server"
@echo ""
@echo " test: run all unit tests in the repo"
@echo ""
@echo " cover: run all tests in repo with coverage"
@echo ""
@echo " fmt: run go fmt on the repository"
@echo ""
@echo " lint: run Docker golang-lint-ci for the repository"
@echo ""
@echo " install-hooks: install git-hooks in the cloned repo .git directory"
@echo ""
@echo " dkr-mock: build and run mock server using Docker"
@echo ""
@echo " dkr-server: build and run server using Docker"
@echo ""
@echo " dkr-dev: build and run runtime processor using Docker"
@echo ""
@echo " dkr-stop-mock: stop and remove mock container"
@echo ""
@echo " dkr-stop-server: stop and remove server container"
@echo ""
@echo " dkr-stop-dev: stop and remove dev container"
@echo ""
dkr-build-mock:
docker build -t ${MOCK_SERVER_NAME}:${VERSION} -f docker/mock-server/Dockerfile .
dkr-mock: dkr-build-mock
docker run -d -p 8080:8080 --name ${MOCK_SERVER_NAME} ${MOCK_SERVER_NAME}:${VERSION}
dkr-build-server:
docker build -t ${SERVER_NAME}:${VERSION} -f docker/server/Dockerfile .
dkr-build-dev:
docker build -t ${DEV_NAME}:${VERSION} -f .devcontainer/Dockerfile .
dkr-server: dkr-build-server
docker run -d -p 8080:8080 -e DEBUG=1 --name ${SERVER_NAME} ${SERVER_NAME}:${VERSION}
dkr-dev: dkr-build-dev
docker run -it -p 8080:8080 --rm -v ${PWD}:/runner --name ${DEV_NAME} ${DEV_NAME}:${VERSION}
dkr-stop-mock:
docker stop ${MOCK_SERVER_NAME}
docker rm ${MOCK_SERVER_NAME}
dkr-stop-server:
docker stop ${SERVER_NAME}
docker rm ${SERVER_NAME}
dkr-stop-dev:
docker stop ${DEV_NAME}
gen-mocks:
mockgen -source ./engine/runtime/types.go -package=mocks -destination ./engine/runtime/mocks/Runtime.go Runtime
run-api:
go run server/main.go
run-api-bg:
go run server/main.go &
run-mock:
go run server/mock-server/main.go
run-mock-bg:
go run server/mock-server/main.go &
kill-api:
./hack/kill_server.sh
build:
mkdir -p build
go build -v -o build/runner-server ./server/
go build -v -o build/process ./engine/process/
test: build
PATH=${PATH}:${PWD}/build go test ./...
cover: build
PATH=${PATH}:${PWD}/build go test -covermode=atomic ./...
fmt:
go fmt ./...
lint:
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.44.0 golangci-lint run ./... -v
install-hooks:
@echo "installing git hooks"
cp ./hack/hooks/* .git/hooks/
@echo "done"
.PHONY: build lint test