-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (64 loc) · 1.8 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
.PHONY: build install help lint
.DEFAULT_GOAL := help
GO := go
GOPATH := $(shell go env GOPATH)
GOPATH_BIN := $(GOPATH)/bin
AIR := $(GOPATH_BIN)/air
GOLANGCI_LINT := ./bin/golangci-lint
GO_PACKAGES := $(shell go list ./... | grep -v vendor)
MIGRATE_PATH=./pkg/config/migrations
BUILD_OUTPUT := shelflove
BUILD_INPUT := cmd/main.go
TEST_FOLDER:=./pkg/tests
help:
@echo "Available targets:"
@echo " all - Install ,erase all data, migrate,run "
@echo " install - Install dependencies and create vendor folder"
@echo " migrate - Create tables and pushes some dummy book data"
@echo " cleandb - Clean the data in the tables"
@echo " build - Build the project"
@echo " dev - Start development server"
@echo " lint - Run code linters "
@echo " test - Run unit tests "
@echo " host - Host on Apache Server "
all: install cleandb migrate dev
migrate:
@$(GO) build -o ${MIGRATE_PATH}/migration ${MIGRATE_PATH}/migration.go
@chmod +x ${MIGRATE_PATH}/migration
@./${MIGRATE_PATH}/migration
cleandb:
@$(GO) build -o ${MIGRATE_PATH}/migration ${MIGRATE_PATH}/migration.go
@chmod +x ${MIGRATE_PATH}/migration
@CLEANDB=true ./${MIGRATE_PATH}/migration
lint:
@echo "Linting ..."
@$(GOLANGCI_LINT) run --fix
test:
@echo "Testing"
@go test ${TEST_FOLDER} -v
host:
@echo "Hosting on apache server"
@chmod +x ./host.sh
@make build
@bash host.sh --sudo
install:
@echo "Installing dependencies..."
@$(GO) mod download
vendor:
@echo "Tidy up go.mod..."
@$(GO) mod tidy
@echo "Vendoring..."
@$(GO) mod vendor
@echo "Done!"
build:
@echo "Building..."
@test -d target || mkdir target
@$(GO) build -o $(BUILD_OUTPUT) $(BUILD_INPUT)
@echo "Built as $(BUILD_OUTPUT)"
setup:
@echo "Setting up..."
@chmod +x ./setup.sh
@bash setup.sh
dev:
@echo "Starting development server..."
@$(AIR)