-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Taskfile.yml
260 lines (234 loc) · 8.58 KB
/
Taskfile.yml
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
version: '3'
vars:
CONFIG_DIR: ./config
BIN_DIR: ./bin
RELEASE_DIR: ./release
TAG: $(git describe --tags --abbrev=0)
COMMIT: $(git rev-parse HEAD)
DATE: $(date +%s)
EMBED_DIR: ./internal/util/embedded
APIDOCS_OUTDIR: ./docs/restapi/v1
tasks:
default:
deps: [release]
release:
desc: Build release artifacts of the backend, web frontend and tools.
cmds:
- rm -rf {{.RELEASE_DIR}}
- task: embed-fe
- task: build-fe-new
- task: build-be
vars: { RELEASE: 'true' }
- task: build-setup-tool
- mkdir {{.RELEASE_DIR}}
- cp {{.BIN_DIR}}/shinpuru{{exeExt}} {{.RELEASE_DIR}}
- mkdir {{.RELEASE_DIR}}/web
- cp -R web/dist {{.RELEASE_DIR}}/web
- cp {{.BIN_DIR}}/setup{{exeExt}} {{.RELEASE_DIR}}
embed-versions:
cmds:
- printf "{{.TAG}}" | tee {{.EMBED_DIR}}/AppVersion.txt > /dev/null 2>&1
- printf "{{.COMMIT}}" | tee {{.EMBED_DIR}}/AppCommit.txt > /dev/null 2>&1
- printf "{{.DATE}}" | tee {{.EMBED_DIR}}/AppDate.txt > /dev/null 2>&1
- printf "{{default "false" .RELEASE}}" | tee {{.EMBED_DIR}}/Release.txt > /dev/null 2>&1
cleanup-embeds:
cmds:
- git checkout
{{.EMBED_DIR}}/AppVersion.txt
{{.EMBED_DIR}}/AppCommit.txt
{{.EMBED_DIR}}/AppDate.txt
{{.EMBED_DIR}}/Release.txt
build-be:
desc: Builds the backend binary.
cmds:
- task: embed-versions
vars: { RELEASE: '{{.RELEASE}}' }
- defer: { task: cleanup-embeds }
- go build
-v
-o {{.BIN_DIR}}/shinpuru{{exeExt}}
cmd/shinpuru/main.go
embed-fe:
deps:
- build-fe
cmds:
- cp -R web/dist/web/* {{.EMBED_DIR}}/webdist
deps-fe:
dir: web
sources:
- package.json
- yarn.lock
cmds:
- yarn
build-fe:
desc: Builds the frontend artifacts of the new React web app.
dir: web
deps:
- deps-fe
sources:
- public/**
- src/**
- index.html
- '*.png'
cmds:
- yarn run build --base=/
init-dev:
desc: Creates a new development config from {{.CONFIG_DIR}}/my.private.config.yml.
preconditions:
- sh: ls {{.CONFIG_DIR}}/private.config.yml && exit 1 || exit 0
msg: '{{.CONFIG_DIR}}/private.config.yml already exists'
cmds:
- cp {{.CONFIG_DIR}}/my.private.config.yml {{.CONFIG_DIR}}/private.config.yml
- cmd: echo Please go to {{.CONFIG_DIR}}/private.config.yml and enter your credentials!
silent: true
run:
desc: Builds the backend binaries and runs them with the development configuration.
deps:
- build-be
preconditions:
- sh: ls config/private.config.yml
msg:
config/private.config.yml does not exist. Please run 'task init-dev' and
enter your credentials into the generated config file.
cmds:
- '{{.BIN_DIR}}/shinpuru
-c {{.CONFIG_DIR}}/private.config.yml
{{.CLI_ARGS}}'
run-fe:
desc: Runs the Angular development server for the web app.
deps:
- deps-fe
dir: web
cmds:
- yarn start
run-fe-new:
desc: Runs the vite development server for the new React web app.
deps:
- deps-fe-new
dir: web
cmds:
- yarn start --base=/
test:
desc: Executes backend unit tests.
cmds:
- go test -race -v -cover ./...
apidocs:
desc: Generates API documentation from the controller descriptions.
preconditions:
- sh: which swag
msg:
swag is not installed. Please install it using the following command.
$ go install github.com/swaggo/swag/cmd/swag@latest
- sh: which swagger-markdown
msg:
swagger-markdown is not installed. Please install it using the following command.
$ npm install -g swagger-markdown
cmds:
- swag init
-g ./internal/services/webserver/v1/router.go
-o {{.APIDOCS_OUTDIR}}
--parseDependency --parseDepth 2
- rm {{.APIDOCS_OUTDIR}}/docs.go
- swagger-markdown
-i {{.APIDOCS_OUTDIR}}/swagger.json
-o {{.APIDOCS_OUTDIR}}/restapi.md
build-setup-tool:
desc: Builds the binary for the setup tool.
sources:
- cmd/**
- pkg/**
- internal/**
cmds:
- go build
-v
-o {{.BIN_DIR}}/setup{{exeExt}}
cmd/setup/main.go
build-cmdman-tool:
desc: Builds the binary for the command manual (cmdman) tool.
sources:
- cmd/**
- pkg/**
- internal/**
cmds:
- go build
-v
-o {{.BIN_DIR}}/cmdman{{exeExt}}
cmd/cmdman/main.go
refresh-interfaces:
desc: Refreshes the interfaces for libraries like Discordgo.
preconditions:
- sh: which schnittstelle
msg:
schnittstelle is not installed. Please install it using the following command.
$ go install github.com/zekrotja/schnittstelle/cmd/schnittstelle@latest
vars:
DISCORDGO_VERSION:
sh: cat go.mod | grep github.com/bwmarrin/discordgo | awk '{print $2}'
DISCORDGO_PATH:
sh: echo $(go env GOPATH)/pkg/mod/github.com/bwmarrin/discordgo@{{.DISCORDGO_VERSION}}
cmds:
- schnittstelle
--root {{.DISCORDGO_PATH}}
--struct Session
--interface ISession
--package discordutil
--import 'image'
--import 'io'
--import 'time'
--import '. "github.com/bwmarrin/discordgo"'
--out pkg/discordutil/isession.go
--format
lint-fe:
desc: Runs the vite development server for the new React web app.
deps:
- deps-fe
dir: web
cmds:
- yarn lint
lint-be:
desc: Run backend staticcheck linter.
preconditions:
- sh: which staticcheck
msg: staticcheck is not installed!
cmds:
- staticcheck -checks all,-ST1000,-ST1022,-ST1003,-ST1001,-SA1016 ./...
refresh-mocks:
desc: Refreshes the mock implementations in ./mock.
deps:
- refresh-interfaces
preconditions:
- sh: which mockery
msg:
mockery is not installed. Please install it using the following command.
$ go install github.com/vektra/mockery/v2@latest
vars:
DGRS_VERSION:
sh: cat go.mod | grep github.com/zekrotja/dgrs | awk '{print $2}'
DGRS_PATH:
sh: echo $(go env GOPATH)/pkg/mod/github.com/zekrotja/dgrs@{{.DGRS_VERSION}}
KEN_VERSION:
sh: cat go.mod | grep github.com/zekrotja/ken | awk '{print $2}'
KEN_PATH:
sh: echo $(go env GOPATH)/pkg/mod/github.com/zekrotja/ken@{{.KEN_VERSION}}
cmds:
- mockery -r --dir pkg/discordutil --name ISession --structname ISession --filename ISession.go
- mockery -r --dir internal/services/config --name Provider --structname ConfigProvider --filename ConfigProvider.go
- mockery -r --dir internal/services/database --name Database --structname Database --filename Database.go
- mockery -r --dir {{.DGRS_PATH}} --name IState --structname IState --filename IState.go
- mockery -r --dir internal/services/karma --name Provider --structname KarmaProvider --filename KarmaProvider.go
- mockery -r --dir {{.KEN_PATH}} --name IKen --structname IKen --filename IKen.go
- mockery -r --dir {{.KEN_PATH}} --name Context --structname KenContext --filename KenContext.go
- mockery -r --dir {{.KEN_PATH}} --name State --structname KenState --filename KenState.go
- mockery -r --dir internal/services/guildlog --name Logger --structname Logger --filename Logger.go
- mockery -r --dir internal/services/permissions --name Provider --structname PermissionsProvider --filename PermissionsProvider.go
- mockery -r --dir internal/services/report --name Provider --structname ReportProvider --filename ReportProvider.go
- mockery -r --dir internal/services/storage --name Storage --structname Storage --filename Storage.go
- mockery -r --dir internal/services/timeprovider --name Provider --structname TimeProvider --filename TimeProvider.go
- mockery -r --dir internal/services/verification --name Provider --structname VerificationProvider --filename VerificationProvider.go
help:
cmds:
- cmd: |
echo 'Use "task --list" to get a list of all available tasks with a short desciption of what they do.'
echo 'There are some more tasks used as dependencies for other tasks.'
echo 'You can view them with "task --list-all".'
silent: true