Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
82 lines (82 loc) · 2.62 KB
/
Copy pathTaskfile.yml
File metadata and controls
82 lines (82 loc) · 2.62 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
version: "3"
dotenv: ['.env']
vars:
TEMPL_PROXYBIND: '{{.TEMPL_PROXYBIND | default "127.0.0.1"}}'
TEMPL_PROXYPORT: '{{.TEMPL_PROXYPORT | default "7331"}}'
TEMPL_PROXY: '{{.TEMPL_PROXY | default "http://127.0.0.1:9000"}}'
tasks:
# Development Tools
templ:
desc: Run templ with integrated server and hot reload
cmds:
- go tool templ generate --watch --cmd="go run ./cmd/server/main.go" --proxybind="{{.TEMPL_PROXYBIND}}" --proxyport="{{.TEMPL_PROXYPORT}}" --proxy="{{.TEMPL_PROXY}}" --open-browser=false
tailwind-clean:
desc: Clean tailwind output
cmds:
- tailwindcss -i ./assets/css/input.css -o ./assets/css/output.css --clean
tailwind-watch:
desc: Run tailwindcss in watch mode
cmds:
- tailwindcss -i ./assets/css/input.css -o ./assets/css/output.css --watch
# Start development server
dev:
desc: Start development server with hot reload
deps:
- tailwind-clean
cmds:
- echo "Starting app..."
- task --parallel tailwind-watch templ
# Testing — TestMain in each db-touching package auto-spins an ephemeral
# postgres:17-alpine container; honors BUDGIT_TEST_POSTGRES_URL when set
# (CI uses that path to point at a long-lived service).
test:
desc: Run tests (auto-starts an ephemeral PostgreSQL 17 container if needed)
cmds:
- set -o pipefail && go test ./... -json | tparse -all
# Production build
build:
desc: Build production binary
vars:
VERSION:
sh: git describe --tags --always
cmds:
- tailwindcss -i ./assets/css/input.css -o ./assets/css/output.css --minify
- go tool templ generate
- mkdir -p ./dist
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version={{.VERSION}}" -o ./dist/budgit ./cmd/server/main.go
setup:
desc: Sets up the local development environment
cmds:
- cp .env.include.example .env
- task generate-secrets
- task migrate-up
migrate-status:
desc: Check migration status
cmds:
- goose status
migrate-up:
desc: Apply migrations
cmds:
- goose up
migrate-down:
desc: Rollback one migration
cmds:
- goose down
migrate-down-all:
desc: Rollback all migrations
cmds:
- goose down-to 0
make-migration:
desc: Create a new migration
cmds:
- goose create {{.CLI_ARGS}} sql -s
generate-secrets:
desc: Generates a random GOSHOP_APP_KEY and sets it in .env
cmds:
- |
KEY=$(openssl rand -hex 32)
sed -i "s/^JWT_SECRET=.*/JWT_SECRET=${KEY}/" .env
echo "JWT_SECRET set in .env"
silent: true
preconditions:
- test -f .env