-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
160 lines (117 loc) · 5.1 KB
/
Makefile
File metadata and controls
160 lines (117 loc) · 5.1 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
.PHONY: server-dev server-build server-docker-build server-lint server-test server-test-ci server-test-integration server-coverage server-fmt-check server-sqlc server-smoke db-wipe \
mobile-run mobile-build apk apk-arm64 mobile-analyze mobile-get mobile-pub-add mobile-gen mobile-icons mobile-fmt mobile-fmt-check mobile-test \
fmt-check \
web-dev web-build \
docker-up docker-down \
db-create db-migrate db-migrate-status db-migrate-new sqlc-generate setup clean \
version version-sync version-bump-patch version-bump-minor version-bump-major \
changelog
FLUTTER ?= flutter
DART ?= $(shell if command -v dart >/dev/null 2>&1; then echo dart; else FLUTTER_PATH="$$(command -v $(FLUTTER) 2>/dev/null || echo $(FLUTTER))"; echo "$$(dirname "$$FLUTTER_PATH")/dart"; fi)
MOBILE_RUN_ARGS ?=
API_BASE_URL ?= https://api.clearbreath.life
GOOGLE_WEB_CLIENT_ID ?=
GOOGLE_IOS_CLIENT_ID ?=
MOBILE_DART_DEFINES ?= --dart-define=API_BASE_URL=$(API_BASE_URL) --dart-define=GOOGLE_WEB_CLIENT_ID=$(GOOGLE_WEB_CLIENT_ID) --dart-define=GOOGLE_IOS_CLIENT_ID=$(GOOGLE_IOS_CLIENT_ID)
GOLANGCI_LINT ?= $(shell command -v golangci-lint 2>/dev/null || echo $(HOME)/go/bin/golangci-lint)
SQLC ?= $(shell command -v sqlc 2>/dev/null || echo $(HOME)/go/bin/sqlc)
GOOSE ?= $(shell command -v goose 2>/dev/null || echo $(HOME)/go/bin/goose)
PSQL ?= $(shell command -v psql 2>/dev/null || echo /opt/homebrew/opt/postgresql@17/bin/psql)
VERSION := $(shell cat VERSION 2>/dev/null || echo 0.0.0)
BUILD := $(shell git rev-list --count HEAD 2>/dev/null || echo 1)
server-dev:
cd server && go run ./cmd/api
server-build:
cd server && go build -ldflags="-X main.version=$(VERSION)" -o bin/api ./cmd/api
server-docker-build:
DOCKER_BUILDKIT=0 docker build -t clearbreath-api:local --build-arg VERSION=$(VERSION)+$(BUILD) -f server/Dockerfile server
server-lint:
cd server && $(GOLANGCI_LINT) run
server-test:
cd server && go test ./...
server-test-ci:
cd server && go test -race -count=1 ./...
server-test-integration:
cd server && CLEARBREATH_INTEGRATION=1 go test ./...
server-coverage:
cd server && CLEARBREATH_INTEGRATION=1 go test -count=1 -coverpkg=./... -coverprofile=coverage.out ./...
cd server && go tool cover -func=coverage.out | tail -n 1
server-fmt-check:
cd server && test -z "$$(gofmt -l .)"
server-sqlc:
cd server && $(SQLC) generate -f sqlc/sqlc.yaml
server-smoke:
bash scripts/backend_api_smoke.sh
mobile-run:
cd apps/mobile && $(FLUTTER) run $(MOBILE_RUN_ARGS) $(MOBILE_DART_DEFINES)
mobile-build:
cd apps/mobile && $(FLUTTER) build apk --release $(MOBILE_DART_DEFINES)
apk:
cd apps/mobile && $(FLUTTER) build apk --release --split-per-abi $(MOBILE_DART_DEFINES)
apk-arm64:
cd apps/mobile && $(FLUTTER) build apk --release --split-per-abi --target-platform android-arm64 $(MOBILE_DART_DEFINES)
mobile-analyze:
cd apps/mobile && $(FLUTTER) analyze
mobile-get:
cd apps/mobile && $(FLUTTER) pub get
mobile-pub-add:
if [ -z "$(PKG)" ]; then echo "PKG is required"; exit 1; fi
cd apps/mobile && $(FLUTTER) pub add $(PKG)
mobile-gen:
cd apps/mobile && $(FLUTTER) pub run build_runner build --delete-conflicting-outputs
mobile-icons:
cd apps/mobile && $(DART) run flutter_launcher_icons
mobile-fmt:
cd apps/mobile && $(DART) format lib/ test/
mobile-fmt-check:
cd apps/mobile && $(DART) format --set-exit-if-changed --output=none lib/
mobile-test:
cd apps/mobile && $(FLUTTER) test
fmt-check: server-fmt-check mobile-fmt-check
web-dev:
cd apps/web && bun run dev
web-build:
cd apps/web && bun run build
docker-up:
docker compose -f docker-compose.dev.yml up -d
docker-down:
docker compose -f docker-compose.dev.yml down
db-create:
$(PSQL) -c "CREATE DATABASE clearbreath;" 2>/dev/null || true
db-migrate:
if [ -z "$$DATABASE_URL" ]; then echo "DATABASE_URL is required"; exit 1; fi
$(GOOSE) -dir server/migrations postgres "$$DATABASE_URL" up
db-migrate-status:
if [ -z "$$DATABASE_URL" ]; then echo "DATABASE_URL is required"; exit 1; fi
$(GOOSE) -dir server/migrations postgres "$$DATABASE_URL" status
db-migrate-new:
if [ -z "$$NAME" ]; then echo "NAME is required"; exit 1; fi
$(GOOSE) -dir server/migrations create "$$NAME" sql
db-wipe:
@echo "Wiping all data (development only)..."
PGPASSWORD=clearbreath $(PSQL) -h localhost -p 5433 -U clearbreath -d clearbreath \
-c "TRUNCATE users, auth_identities, refresh_tokens, sessions, stats_snapshots, safety_acknowledgements, xp_events, user_progress, request_logs, event_logs CASCADE;"
@echo "Done."
sqlc-generate: server-sqlc
setup:
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
go install github.com/pressly/goose/v3/cmd/goose@latest
cd server && go mod download
cd apps/mobile && $(FLUTTER) pub get
cd apps/web && bun install
clean:
rm -rf server/bin
cd apps/web && rm -rf dist .astro
version:
@echo $(VERSION)+$(BUILD)
version-sync:
@bash scripts/version-sync.sh
version-bump-patch:
@bash scripts/version-bump.sh patch
version-bump-minor:
@bash scripts/version-bump.sh minor
version-bump-major:
@bash scripts/version-bump.sh major
changelog:
git-cliff -o CHANGELOG.md