-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
97 lines (68 loc) · 2.53 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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NAME=smarty-pants
BINARY_UNIX=$(BINARY_NAME)_unix
# Version
VERSION=$(shell git describe --tags --always --dirty)
# Directories
BACKEND_DIR=backend
FRONTEND_DIR=frontend/smarty-pants
# Frontend parameters
NPM=npm
.PHONY: all backend-build backend-build-prod backend-test backend-clean backend-run backend-deps backend-build-linux backend-docker-build backend-migrate-up backend-migrate-down frontend-install frontend-dev frontend-build frontend-start frontend-lint frontend-test dev build clean test
all: backend-test backend-build frontend-install frontend-build
# Backend commands
backend-build:
cd $(BACKEND_DIR) && $(GOBUILD) -o $(BINARY_NAME) -v
backend-build-prod:
cd $(BACKEND_DIR) && $(GOBUILD) -o $(BINARY_NAME) -v -ldflags "-X main.Version=$(VERSION)"
backend-test:
cd $(BACKEND_DIR) && $(GOTEST) -tags 'unit' -v ./... -coverprofile=coverage_unit.out
backend-test-integration:
cd $(BACKEND_DIR) && $(GOTEST) -tags=integration -v ./... -coverprofile=coverage_integration.out
backend-clean:
cd $(BACKEND_DIR) && $(GOCLEAN)
cd $(BACKEND_DIR) && rm -f $(BINARY_NAME)
cd $(BACKEND_DIR) && rm -f $(BINARY_UNIX)
backend-run:
cd $(BACKEND_DIR) && $(GOBUILD) -o $(BINARY_NAME) -v ./...
cd $(BACKEND_DIR) && ./$(BINARY_NAME)
backend-deps:
cd $(BACKEND_DIR) && $(GOGET) -v -d ./...
backend-build-linux:
cd $(BACKEND_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v
backend-docker-build:
cd $(BACKEND_DIR) && docker build -t $(BINARY_NAME):latest .
backend-migrate-up:
cd $(BACKEND_DIR) && go run main.go migrate up
backend-migrate-down:
cd $(BACKEND_DIR) && go run main.go migrate down
backend-lint:
cd $(BACKEND_DIR) && golangci-lint run
# Frontend commands
frontend-install:
cd $(FRONTEND_DIR) && $(NPM) install
frontend-install-ci:
cd $(FRONTEND_DIR) && $(NPM) ci --ignore-scripts
frontend-dev: frontend-install
cd $(FRONTEND_DIR) && $(NPM) run dev
frontend-build: frontend-install
cd $(FRONTEND_DIR) && $(NPM) run build
frontend-start: frontend-install
cd $(FRONTEND_DIR) && $(NPM) run start
frontend-lint: frontend-install
cd $(FRONTEND_DIR) && $(NPM) run lint
frontend-test: frontend-install
cd $(FRONTEND_DIR) && $(NPM) run test
frontend-test-ci: frontend-install-ci
cd $(FRONTEND_DIR) && $(NPM) run test
# Combined commands
dev: backend-run frontend-dev
build: backend-build frontend-build
clean: backend-clean
cd $(FRONTEND_DIR) && $(NPM) run clean
test: backend-test frontend-test