-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (91 loc) · 2.6 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
BUILD_DIR ?= build
SRC_FILES := $(shell find . -name "*.go")
POSTGRESQL_FILES = internal/repository/postgresql/migrations
all: lint race cover build docs
.PHONY: all
build: $(BUILD_DIR)/sparklemuffin
$(BUILD_DIR)/%: $(SRC_FILES)
go build -trimpath -o $@ ./cmd/$*
lint:
golangci-lint run ./...
.PHONY: lint
format: copywrite format-sql
.PHONY: format
cover:
go test -coverprofile=coverage.out ./...
.PHONY: cover
coverhtml: cover
go tool cover -html=coverage.out
.PHONY: coverhtml
race:
go test -race ./...
.PHONY: race
test:
go test ./...
.PHONY: test
format-sql:
sqlfluff format $(POSTGRESQL_FILES)
.PHONY: format-sql
lint-sql:
sqlfluff lint --disable-progress-bar $(POSTGRESQL_FILES)
.PHONY: lint-sql
# Install development tools
dev-install-tools:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.0
go install github.com/hashicorp/copywrite@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
.PHONY: dev-install-tools
dev-install-sqlfluff:
pip install 'sqlfluff==3.2.5'
.PHONY: dev-install-sqlfluff
# Licence headers
copywrite:
copywrite headers
.PHONY: copywrite
# Vulnerability check
vulncheck:
govulncheck -C . ./...
.PHONY: vulncheck
# Live development server
live:
@echo "== Starting database"
docker compose -f docker-compose.dev.yml up --remove-orphans -d
@echo "== Watching for changes... (hit Ctrl+C when done)"
@watchexec --restart --exts css,go,gohtml -- go run ./cmd/sparklemuffin/ run
.PHONY: live
# Live development server (with race detection enabled)
live-race:
@echo "== Starting database"
docker compose -f docker-compose.dev.yml up --remove-orphans -d
@echo "== Watching for changes... (hit Ctrl+C when done)"
@watchexec --restart --exts css,go,gohtml -- go run -race ./cmd/sparklemuffin/ run
.PHONY: live-race
# Live development server - PostgreSQL console
psql:
docker compose exec postgres psql -U sparklemuffin
.PHONY: psql
# Live development server - Database migrations
dev-migrate:
go run ./cmd/sparklemuffin migrate
.PHONY: dev-migrate
# Live development server - Synchronize feeds
dev-sync-feeds:
go run ./cmd/sparklemuffin sync-feeds
.PHONY: dev-sync-feeds
# Live development server - Create administrator user
dev-admin:
go run ./cmd/sparklemuffin createadmin \
--displayname Admin \
--email [email protected] \
--nickname admin
.PHONY: dev-admin
# Documentation
DOCS_DIR := docs
DOCS_FILES := $(shell find docs -name "*.md" -or -name "*.toml")
docs: docs/book/html
.PHONY: docs
docs/book/html: $(DOCS_FILES)
mdbook build $(DOCS_DIR)
live-docs:
mdbook serve $(DOCS_DIR)
.PHONY: live-docs