-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
126 lines (105 loc) · 3.58 KB
/
Taskfile.yml
File metadata and controls
126 lines (105 loc) · 3.58 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
# https://taskfile.dev
version: '3'
dotenv: ['.env']
vars:
SERVICE: goalkeepr
tasks:
default:
desc: Display available tasks
cmds:
- task --list
silent: true
# ==================================================================================== #
# DEVELOPMENT
# ==================================================================================== #
run:
desc: Run the application with Reflex for auto-reload
aliases: [dev]
cmds:
- echo 'Starting app with Reflex auto-reload...'
- reflex -s -r '\.(go|html|css|js)$' -- go run ./cmd/app -env=dev -database-driver=sqlite -database-dsn={{.DB_DSN}}
sqlc:
desc: Generate source code from SQL
aliases: [generate]
cmds:
- sqlc generate
tw:
desc: Run Tailwind CSS in watch mode
cmds:
- tailwindcss -i ./ui/static/css/index.css -o ./ui/static/dist/index.css --watch
sec:
desc: gosec analyzes Go source code to look for common programming mistakes that can lead to security problems.
aliases: [scan]
cmds:
- gosec -exclude-dir=internal/database/gen ./...
- govulncheck ./...
dev:
cmds:
- task --parallel tw run
# ==================================================================================== #
# QUALITY CONTROL
# ==================================================================================== #
audit:
desc: Format, vet and test all code
cmds:
- echo 'Formatting code...'
- go fmt ./...
- echo 'Vetting code...'
- go vet ./...
- echo 'Running tests...'
- go test -race -vet=off ./...
vendor:
desc: Tidy and vendor dependencies
cmds:
- echo 'Tidying and verifying module dependencies...'
- go mod tidy
- go mod verify
- echo 'Vendoring dependencies...'
- GOWORK=off go mod vendor
cover:
desc: Run test coverage
cmds:
- echo 'Test coverage...'
- go test -covermode=count -coverprofile=/tmp/profile.out ./...
analyze:
desc: Analyze the test coverage in your browser
deps: [cover]
cmds:
- echo 'Analyze test coverage...'
- go tool cover -html=/tmp/profile.out
# ==================================================================================== #
# BUILD
# ==================================================================================== #
build:
desc: Build the service for Linux AMD64
aliases: [build/linux_amd64]
deps: [audit]
cmds:
- echo 'Building cmd/{{.SERVICE}}...'
- go build -ldflags='-s' -o=./bin/{{.SERVICE}} ./cmd/app
- task: build:linux
build:linux:
internal: true
cmds:
- |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build --tags extended -ldflags='-s' \
-o=./bin/linux_amd64/{{.SERVICE}} ./cmd/app
# ==================================================================================== #
# PRODUCTION
# ==================================================================================== #
prod:connect:
desc: Connect to the production server
cmds:
- ssh setup@{{.PRODUCTION_HOST_IP}}
prod:deploy:
desc: Deploy goalkeepr to production
vars:
REMOTE_USER: setup
cmds:
- rsync -P ./bin/linux_amd64/{{.SERVICE}} {{.REMOTE_USER}}@{{.PRODUCTION_HOST_IP}}:~
- rsync -P ./remote/production/{{.SERVICE}}.service {{.REMOTE_USER}}@{{.PRODUCTION_HOST_IP}}:~
- |
ssh -t {{.REMOTE_USER}}@{{.PRODUCTION_HOST_IP}} \
'sudo mv ~/{{.SERVICE}}.service /etc/systemd/system/ && \
sudo systemctl enable {{.SERVICE}} && \
sudo systemctl restart {{.SERVICE}}'