generated from lazybytez/general-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (74 loc) · 2.49 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
# JOJO Discord Bot - An advanced multi-purpose discord bot
# Copyright (C) 2022 Lazy Bytez (Elias Knodel, Pascal Zarrad)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Get current directory
CURRENT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# === Project Setup ===
# =====================
# Copy the example env file
.PHONY: env
env:
cp .env.example .env
# Install go dependencies
.PHONY: install
install: openapi/dependencies openapi/generate
go get
.PHONY: setup
setup: env install
# === Running Project ===
# =======================
# Runs the code for development and test usage
.PHONY: run
run: openapi/generate
go run .
# Builds an executable for production usage
# Build will be tagged as edge and include commit SHA
.PHONY: build
build: openapi/generate
go build -ldflags "-X github.com/lazybytez/jojo-discord-bot/build.Version=edge -X github.com/lazybytez/jojo-discord-bot/build.CommitSHA=`git rev-parse --short HEAD`" .
# === Database services ===
# =====================
# Start database and redis development instances
.PHONY: services/start
services/start:
docker-compose up -d
# Stop database and redis development instances
.PHONY: services/stop
services/stop:
docker-compose stop
# Destroy database and redis development instances
.PHONY: services/destroy
services/destroy:
docker-compose down -v
# === Quality Assurance ===
# =========================
# Runs tests with specified arguments
.PHONY: test
test:
go test -race -covermode=atomic -coverpkg=all ./...
# Lints the code
.PHONY: lint
lint:
docker run --rm -v $(CURRENT_DIR):/app -w /app golangci/golangci-lint:v1.57.2 golangci-lint run -v
# === OpenAPI ===
# =========================
# Install CLI for documentation generation
.PHONY: openapi/dependencies
openapi/dependencies:
go install github.com/swaggo/swag/cmd/swag@latest
# Generate OpenAPI documentation
.PHONY: openapi/generate
openapi/generate:
swag init