-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (56 loc) · 1.76 KB
/
Copy pathMakefile
File metadata and controls
85 lines (56 loc) · 1.76 KB
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
.PHONY: build run generate test test-cover lint vet fmt fmt-check prettier prettier-check tidy docker-build docker-up docker-down docker-logs migrate-up migrate-down migrate-status clean hooks
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE ?= $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
# Build
generate:
go tool templ generate
build: generate
CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o bin/huntarr2 ./cmd/huntarr2
run: build
./bin/huntarr2
# Quality
test:
go test -race ./...
test-cover:
go test -race -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
lint:
go tool golangci-lint run ./...
vet:
go vet ./...
fmt:
gofmt -w .
fmt-check:
test -z "$$(gofmt -l .)"
prettier:
npx --yes prettier@3 --write 'web/static/js/**/*.js' '**/*.json' '**/*.yml'
prettier-check:
npx --yes prettier@3 --check 'web/static/js/**/*.js' '**/*.json' '**/*.yml'
# Dependencies
tidy:
go mod tidy
# Docker
docker-build:
docker compose build --build-arg VERSION=$(VERSION) --build-arg COMMIT=$(COMMIT) --build-arg DATE=$(DATE)
docker-up:
docker compose up -d
docker-down:
docker compose down
docker-logs:
docker compose logs -f huntarr2
# Database
migrate-up:
goose -dir internal/database/migrations sqlite3 "$(DATABASE_PATH)" up
migrate-down:
goose -dir internal/database/migrations sqlite3 "$(DATABASE_PATH)" down
migrate-status:
goose -dir internal/database/migrations sqlite3 "$(DATABASE_PATH)" status
# Setup
hooks:
@ln -sf ../../.githooks/pre-commit .git/hooks/pre-commit
@echo "pre-commit hook installed"
# Clean
clean:
rm -rf bin/ coverage.out