-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
188 lines (163 loc) · 5.06 KB
/
Taskfile.yml
File metadata and controls
188 lines (163 loc) · 5.06 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# Database Gateway provides access to servers with ACL for safe and restricted database interactions.
# Copyright (C) 2024 Kirill Zhuravlev
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
version: "3"
vars:
PROJECT_NAME: database-gateway
DEPS_COMPOSE_FILE: ./.cicd/local/docker-compose.yaml
DOCKER_IMAGE_NAME: database-gateway
GO_ENTRYPOINT: ./cmd/gateway
FRONTEND_DIR: ./frontend
FRONTEND_DIST: ./frontend/dist
FRONTEND_EMBED_DIST: ./internal/facade/ui/dist
HELM_CHART_DIR: ./charts/database-gateway
HELM_DIST_DIR: ./dist/helm
TOOLSET: "go run github.com/kazhuravlev/toolset/cmd/toolset@v0.40.0"
GIT_TAG:
sh: "gt t l -f tag"
tasks:
run:
cmds:
- task: "frontend:build"
- go run {{ .GO_ENTRYPOINT }} run
deps:run:
desc: Run all deps
cmds:
- docker compose -p {{ .PROJECT_NAME }} -f {{ .DEPS_COMPOSE_FILE }} up -d
deps:logs:
desc: Show all deps logs
cmds:
- docker compose -p {{ .PROJECT_NAME }} -f {{ .DEPS_COMPOSE_FILE }} logs -f
deps:stop:
desc: Stop all deps
cmds:
- docker compose -p {{ .PROJECT_NAME }} -f {{ .DEPS_COMPOSE_FILE }} stop
deps:drop:
desc: Stop all deps, remove volumes and other resources
cmds:
- docker compose -p {{ .PROJECT_NAME }} -f {{ .DEPS_COMPOSE_FILE }} down -v -t 0
- docker volume list | grep {{ .PROJECT_NAME }} | awk '{print $2}' | xargs docker volume rm $1
tools:install:
cmds:
- echo '>>> Run install tools'
- "{{ .TOOLSET }} sync"
lint:
desc: Run static analysis
cmds:
- echo '>>> Run lint'
- "{{ .TOOLSET }} run golangci-lint run --fix"
fmt:
desc: Safe formatting codebase
cmds:
- echo ">>> Run Code Formatter"
- go fmt $(go list ./...)
- "{{ .TOOLSET }} run gofumpt -l -w ."
- "{{ .TOOLSET }} run goimports -d -w $(find . -type f -name '*.go' -not -path './.cicd/*')"
migrations:new:
desc: Create new migration
cmds:
- go run {{ .GO_ENTRYPOINT }} migrate-new
migrations:up:
desc: Up all migrations
cmds:
- go run {{ .GO_ENTRYPOINT }} migrate-up
ci:lint:
desc: Run linter in CI tool
cmds:
- task: tools:install
- echo ">>> Run lint"
- "{{ .TOOLSET }} run golangci-lint run"
helm:lint:
desc: Lint Helm chart
cmds:
- echo ">>> Helm lint"
- helm lint {{ .HELM_CHART_DIR }}
helm:build:
desc: Package Helm chart
cmds:
- echo ">>> Helm build"
- mkdir -p {{ .HELM_DIST_DIR }}
- helm package {{ .HELM_CHART_DIR }} --destination {{ .HELM_DIST_DIR }}
generate:
desc: Generate code
cmds:
- task: "generate:go"
- task: "generate:jet"
- task: "generate:license"
- task: "fmt"
generate:jet:
desc: Generate jet models
cmds:
- echo ">>> Jet generate"
- go run {{ .GO_ENTRYPOINT }} jet-generate
- rm -rf ./internal/storage/jetgen/{table,model}
- mv ./internal/storage/jetgen/local__dbgw/public/* ./internal/storage/jetgen/
- rm -rf ./internal/storage/jetgen/local__dbgw
generate:license:
cmds:
- "{{ .TOOLSET }} run addlicense -f LICENSE_gplv3_header.txt ."
frontend:deps:
desc: Install frontend dependencies
dir: '{{ .FRONTEND_DIR }}'
cmds:
- npm install
frontend:dev:
desc: Run frontend in dev mode with autoreload
dir: '{{ .FRONTEND_DIR }}'
env:
VITE_BASE_PATH: /
cmds:
- npm run dev
frontend:build:
desc: Build frontend for /ui and sync dist to Go embed directory
env:
VITE_BASE_PATH: /ui/
cmds:
- task: "frontend:deps"
- echo ">>> Build frontend"
- cd {{ .FRONTEND_DIR }} && npm run build
- echo ">>> Sync frontend dist into embed directory"
- rm -rf {{ .FRONTEND_EMBED_DIST }}
- mkdir -p {{ .FRONTEND_EMBED_DIST }}
- cp -R {{ .FRONTEND_DIST }}/. {{ .FRONTEND_EMBED_DIST }}/
generate:go:
desc: Generate go
cmds:
- echo ">>> Go generate ./..."
- go generate ./...
check:
desc: Run all project checks
cmds:
- task: "tools:install"
- task: "deps:run"
- task: "migrations:up"
- task: "frontend:build"
- task: "generate"
- task: "fmt"
- task: "lint"
- task: "helm:lint"
- task: "helm:build"
- task: "test"
test:
cmds:
- go test ./...
docker:build:
cmds:
- echo ">>> Docker build"
- |
docker buildx build \
--build-arg VERSION=local \
-t {{ .DOCKER_IMAGE_NAME }}:{{.GIT_TAG}} \
-f Dockerfile .