-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
100 lines (86 loc) · 2.54 KB
/
Taskfile.yml
File metadata and controls
100 lines (86 loc) · 2.54 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
version: '3'
vars:
ENVIRONMENT: "DEVELOPMENT2"
DB_URL: "postgresql://postgres:1234@localhost:5432/postgres"
GO_BIN:
sh: go env GOPATH
GOOSE_DRIVER: postgres
GOOSE_DBSTRING: "{{.DB_URL}}"
GOOSE_MIGRATION_DIR: ./db/migrations/
BIN_NAME:
sh: |
if [ "{{.OS}}" = "Windows_NT" ]; then
echo "bin/Am.EventKit.exe"
else
echo "bin/Am.EventKit"
fi
tasks:
setup:
desc: "Install CLI tools and setup development environment"
cmds:
- go install github.com/air-verse/air@latest
- go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
- go install github.com/evilmartians/lefthook@latest
- go install github.com/pressly/goose/v3/cmd/goose@latest
- lefthook install
- echo "All CLI tools installed successfully in {{.GO_BIN}}/bin"
dev:
desc: "Run the development server with hot reload"
cmds:
- air
build:
desc: "Build the application"
cmds:
- go mod tidy
- go fmt ./...
- go build -o {{.BIN_NAME}} main.go
run:
desc: "Build and run the application"
deps: [build]
cmds:
- ./{{.BIN_NAME}}
up:
desc: "Run all database migrations"
cmds:
- goose -dir {{.GOOSE_MIGRATION_DIR}} {{.GOOSE_DRIVER}} {{.GOOSE_DBSTRING}} up
upone:
desc: "Run one database migration at a time"
cmds:
- goose -dir {{.GOOSE_MIGRATION_DIR}} {{.GOOSE_DRIVER}} {{.GOOSE_DBSTRING}} up-by-one
seed:
desc: "Seed the database with test data (DEVELOPMENT environment only)"
deps: [build]
cmds:
- |
if [ "{{.ENVIRONMENT}}" = "DEVELOPMENT" ]; then
go run seed/seed.go seed/truncate.go seed/main.go -s
else
echo "Skipping seed: not in DEVELOPMENT environment."
fi
down:
desc: "Reset all database migrations"
cmds:
- goose -dir {{.GOOSE_MIGRATION_DIR}} {{.GOOSE_DRIVER}} {{.GOOSE_DBSTRING}} reset
downto:
desc: "Migrate down to a specific version"
vars:
VERSION: "{{.v | default \"0\"}}"
cmds:
- goose -dir {{.GOOSE_MIGRATION_DIR}} {{.GOOSE_DRIVER}} {{.GOOSE_DBSTRING}} down-to {{.VERSION}}
status:
desc: "Show migration status"
cmds:
- goose -dir {{.GOOSE_MIGRATION_DIR}} {{.GOOSE_DRIVER}} {{.GOOSE_DBSTRING}} status
clean:
desc: "Clean database data"
cmds:
- go run seed/seed.go seed/truncate.go seed/main.go -c
docker:
desc: "Start server with Docker"
cmds:
- docker compose up -d
pod:
desc: "Restart services with Podman"
cmds:
- podman compose down
- podman compose up -d