-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
69 lines (64 loc) · 2.15 KB
/
Taskfile.yaml
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
version: 3
dotenv: ["./resources/.env"]
env:
MIGRATIONS_DIR: ./src/infrastructure/db/migrations
POSTGRESQL_URL: "{{.BLUELIGHT_DB_DSN}}"
tasks:
## API
watch: 'wgo -file=.go -file=.templ -xfile=_templ.go templ generate :: go run ./src/api/cmd {{.CLI_ARGS}}'
build: GOOS=linux GOARCH=amd64 go build -ldflags='-s -w' -o=./bin/linux_amd64/api ./src/api/cmd
run: go run ./src/api/cmd -db-dsn=$BLUELIGHT_DB_DSN {{.CLI_ARGS}}
audit:
deps: [vendor]
cmds:
- go fmt ./...
- go vet ./...
- staticcheck ./...
- go test -race -vet=off ./...
vendor:
cmds:
- go mod tidy
- go mod verify
- go mod vendor
lint:
cmds:
- golangci-lint run
test:
desc: Run all tests
cmds:
- go test ./...
local-ci:
desc: run as a proxy for ci pipeline
cmds:
- task: lint
- task: test
psql: psql $POSTGRESQL_URL
## DATABASE MIGRATIONS
migrate-install: go install -tags "postgres,mysql,sqlite" github.com/golang-migrate/migrate/v4/cmd/migrate@latest
migrate-new:
desc: task migrate -- [migration_pair_name]
cmds:
- migrate create -seq -ext=.sql -dir=$MIGRATIONS_DIR {{.CLI_ARGS}}
migrate-up:
desc: execute migrations
cmds:
- migrate -path=$MIGRATIONS_DIR -database=$POSTGRESQL_URL up
migrate-down:
desc: down all migrations
cmds:
- migrate -path=$MIGRATIONS_DIR -database=$POSTGRESQL_URL down
migrate-goto:
desc: migrate to a specific version
cmds:
- migrate -path=$MIGRATIONS_DIR -database=$POSTGRESQL_URL goto {{.CLI_ARGS}}
migrate-force:
desc: used after manually fixing errors in SQL migrations (manual rolling back)
cmds:
- migrate -path=$MIGRATIONS_DIR -database=$POSTGRESQL_URL force {{.CLI_ARGS}}
migrate-schema-version:
desc: used for see which migration version database is currently on
cmds:
- migrate -path=$MIGRATIONS_DIR -database=$POSTGRESQL_URL version
templ-install: go install github.com/a-h/templ/cmd/templ@latest
staticcheck-install: go install honnef.co/go/tools/cmd/staticcheck@latest
instal-golangci-lint: go install github.com/golangci/golangci-lint/cmd/[email protected]