-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (63 loc) · 2.12 KB
/
Makefile
File metadata and controls
84 lines (63 loc) · 2.12 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
.PHONY: bootstrap bs dev run build test fmt lint lint-fix tidy clean swagger migrate-up migrate-down migrate-reset migrate-reset-seed seed token cleanup cleanup-run
DATABASE_URL ?= postgres://postgres:postgres@localhost:5433/anycast?sslmode=disable
# 開発ツールをインストール
bootstrap:
./scripts/bootstrap.sh
bs: bootstrap
# 開発サーバーを起動(ホットリロード)
dev:
mise exec -- air
# サーバーを起動
run:
go run main.go
# バイナリをビルド
build:
go build -o bin/server main.go
# テストを実行
test:
go test ./...
# コードをフォーマット
fmt:
gofmt -w .
# 静的解析を実行
lint:
mise exec -- golangci-lint run ./...
# 静的解析を実行(自動修正あり)
lint-fix:
mise exec -- golangci-lint run --fix ./...
# 依存関係を整理
tidy:
go mod tidy
# ビルド成果物を削除
clean:
rm -rf bin/ tmp/
# Swagger ドキュメント生成
swagger:
mise exec -- swag init -g main.go -o swagger --outputTypes go,json
# マイグレーション実行
migrate-up:
mise exec -- migrate -path migrations -database "$(DATABASE_URL)" up
# マイグレーションロールバック
migrate-down:
mise exec -- migrate -path migrations -database "$(DATABASE_URL)" down
# マイグレーションリセット(テーブル全削除 → 再マイグレーション)
migrate-reset:
docker exec -i anycast-db psql -U postgres -d anycast -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
mise exec -- migrate -path migrations -database "$(DATABASE_URL)" up
# マイグレーションリセット + シード投入
migrate-reset-seed: migrate-reset seed
# シードデータを投入(開発環境用)
seed:
@for file in seeds/*.sql; do \
echo "Running $$file..."; \
docker exec -i anycast-db psql -U postgres -d anycast < "$$file"; \
done
# 開発用 JWT トークンを生成
token:
@go run ./scripts/gentoken
# 孤児メディアファイルをクリーンアップ(dry-run)
cleanup:
@go run ./scripts/cleanup --dry-run=true
# 孤児メディアファイルをクリーンアップ(実行)
cleanup-run:
@go run ./scripts/cleanup --dry-run=false