This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Taskfile.yml
376 lines (341 loc) · 12.5 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
version: "3"
tasks:
default:
desc: Run development server, watching code files for changes.
cmds:
- task --parallel fmt-lint backend frontend --watch
cloud:
desc: Run development server, watching code files for changes.
cmds:
- task --parallel fmt-lint backend-cloud frontend --watch
fmt-lint:
desc: "Run formatters and linters"
cmds:
- task: fmt
- task: lint
backend:
desc: Run "doctree serve" backend
cmds:
- .bin/doctree serve
env:
ELM_DEBUG_SERVER: "http://localhost:8000/"
deps:
- build-go-debug
backend-cloud:
desc: Run "doctree serve -cloud" backend
cmds:
- .bin/doctree serve -cloud
env:
ELM_DEBUG_SERVER: "http://localhost:8000/"
deps:
- build-go-debug
frontend:
desc: Run Elm frontend dev server
dir: frontend
cmds:
- npx elm-live --dir public --pushstate true src/Main.elm -- --output=public/dist/elm.js
build:
desc: Build Go + Elm code in release mode
cmds:
- task: build-go-release
deps:
- task: build-elm-release
build-elm-debug:
desc: Build Elm frontend code (debug mode)
dir: frontend
cmds:
- mkdir -p public/dist/
- npx elm make --debug src/Main.elm --output ./public/dist/elm.js
sources:
- ./frontend/src/**/*.elm
generates:
- ./frontend/public/dist/elm.js
build-elm-release:
desc: Build Elm frontend code (release mode, minified, etc.)
dir: frontend
cmds:
- mkdir -p public/dist/
- npx elm make src/Main.elm --optimize --output ./public/dist/elm.js
sources:
- ./frontend/src/**/*.elm
generates:
- ./frontend/public/dist/elm.js
build-go-debug:
desc: Build .bin/doctree (debug)
cmds:
- mkdir -p .bin
- go build -ldflags "-w" -o .bin/doctree ./cmd/doctree
sources:
- ./**/*.go
- libs/sinter/**/*.zig
generates:
- .bin/doctree
deps:
- task: build-zig-debug
build-go-release:
desc: Build .bin/doctree (release)
cmds:
- mkdir -p .bin
- go build -o .bin/doctree ./cmd/doctree
sources:
- ./**/*.go
- ./frontend/public/**
- libs/sinter/**/*.zig
generates:
- .bin/doctree
deps:
- task: build-zig-release
build-zig-debug:
desc: Build Zig code in debug mode
cmds:
- rm -f libs/sinter/bindings/sinter-go/go.mod
- cd libs/sinter && zig build
sources:
- libs/sinter/**/*.zig
build-zig-release:
desc: Build Zig code in release mode
cmds:
- rm -f libs/sinter/bindings/sinter-go/go.mod
- cd libs/sinter && zig build -Drelease-fast=true
sources:
- libs/sinter/**/*.zig
test:
desc: Run all tests
cmds:
- go test ./...
deps:
- task: build-zig-debug
test-race:
desc: Run all tests (checking for race conditions, slow)
cmds:
- go test -race ./...
deps:
- task: build-zig-debug
generate:
desc: Produce generated code
cmds:
- go generate ./...
sources:
- ./**/*.go
lint:
desc: Lint code
cmds:
# Using --go=1.17 for now because of https://github.com/golangci/golangci-lint/issues/2649
- .bin/golangci-lint run --go=1.17 ./...
sources:
- ./**/*.go
deps:
- build-tools
fmt:
desc: Format code
cmds:
- .bin/gofumpt -l -w .
sources:
- ./**/*.go
deps:
- build-tools
setup:
desc: Install dependencies, pull submodules
cmds:
- git submodule update --init --recursive
- cd frontend && npm install
build-tools:
desc: Build tool dependencies (golangci-lint, etc.)
cmds:
- GOBIN="$(pwd)/.bin" go install github.com/golangci/golangci-lint/cmd/[email protected]
- GOBIN="$(pwd)/.bin" go install mvdan.cc/gofumpt@latest
status:
- test -f .bin/golangci-lint
- test -f .bin/gofumpt
build-image:
desc: Build sourcegraph/doctree:dev Docker image
cmds:
- docker build --no-cache -t sourcegraph/doctree:dev .
deps:
- task: cc-x86_64-linux
- task: build-elm-release
run-image:
desc: Run sourcegraph/doctree:dev Docker image
cmds:
- docker run -it sourcegraph/doctree:dev
cross-compile:
desc: "Cross compile binaries using Zig (requires Go 1.18+, Zig 0.10+, macOS Monterey 12+ host machine)"
cmds:
- task: cc-x86_64-linux
- task: cc-x86_64-macos
- task: cc-aarch64-macos
- task: cc-x86_64-windows
cc-x86_64-linux:
desc: "Cross compile to x86_64-linux using Zig"
cmds:
- rm -f libs/sinter/bindings/sinter-go/go.mod
- cd libs/sinter && zig build -Drelease-fast=true -Dtarget=x86_64-linux-musl
- go build -o out/doctree-x86_64-linux ./cmd/doctree/
env:
CGO_ENABLED: "1"
GOOS: "linux"
GOARCH: "amd64"
CC: "zig cc -target x86_64-linux-musl"
CXX: "zig c++ -target x86_64-linux-musl"
sources:
- ./**/*.go
- ./frontend/public/**
generates:
- out/doctree-x86_64-macos
deps:
- task: build-elm-release
cc-x86_64-macos:
desc: "Cross compile to x86_64-macos using Zig (REQUIRES XCODE, ONLY WORKS ON MACOS)"
cmds:
- rm -f libs/sinter/bindings/sinter-go/go.mod
- cd libs/sinter && zig build -Drelease-fast=true -Dtarget=x86_64-macos
- go build -o out/doctree-x86_64-macos -buildmode=pie -ldflags "-s -w -linkmode external" ./cmd/doctree/
env:
CGO_ENABLED: "1"
GOOS: "darwin"
GOARCH: "amd64"
CC: "zig cc -target x86_64-macos -F /System/Library/Frameworks --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
CXX: "zig c++ -target x86_64-macos -F /System/Library/Frameworks --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
sources:
- ./**/*.go
- ./frontend/public/**
generates:
- out/doctree-x86_64-macos
deps:
- task: build-elm-release
cc-aarch64-macos:
desc: "Cross compile to aarch64-macos using Zig (REQUIRES XCODE, ONLY WORKS ON MACOS 12+)"
cmds:
- rm -f libs/sinter/bindings/sinter-go/go.mod
- cd libs/sinter && zig build -Drelease-fast=true -Dtarget=aarch64-macos
- go build -o out/doctree-aarch64-macos -buildmode=pie -ldflags "-s -w -linkmode external" ./cmd/doctree/
env:
CGO_ENABLED: "1"
GOOS: "darwin"
GOARCH: "arm64"
CC: "zig cc -target aarch64-macos -F /System/Library/Frameworks --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
CXX: "zig c++ -target aarch64-macos -F /System/Library/Frameworks --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
sources:
- ./**/*.go
- ./frontend/public/**
generates:
- out/doctree-aarch64-macos
deps:
- task: build-elm-release
cc-x86_64-windows:
desc: "Cross compile to x86_64-windows using Zig"
cmds:
- rm -f libs/sinter/bindings/sinter-go/go.mod
- cd libs/sinter && zig build -Drelease-fast=true -Dtarget=x86_64-windows-gnu
- go build -o out/doctree-x86_64-windows.exe ./cmd/doctree/
env:
CGO_ENABLED: "1"
GOOS: "windows"
GOARCH: "amd64"
CC: "zig cc -Wno-dll-attribute-on-redeclaration -target x86_64-windows-gnu"
CXX: "zig c++ -target x86_64-windows-gnu"
sources:
- ./**/*.go
- ./frontend/public/**
generates:
- out/doctree-x86_64-windows.exe
deps:
- task: build-elm-release
ops-ssh:
desc: "SSH doctree.org"
cmds:
- ssh [email protected]
ops-add-repo:
desc: "Add a repo to doctree.org (requires operations access)"
cmds:
- ssh $HOST -t 'rm -rf repo/'
- ssh $HOST -t 'git clone --depth 1 {{.CLI_ARGS}} repo'
- ssh $HOST -t 'chown 10000:10001 -R repo'
- ssh $HOST -t 'cd repo/ && docker run -i --volume $(pwd):/index --volume /.doctree:/home/nonroot/.doctree --entrypoint=sh sourcegraph/doctree:latest -c "cd /index && doctree index ."'
# TODO why is this necessary? Docker volume becomes not in sync with host, how come?
- ssh $HOST -t 'docker restart doctree'
env:
HOST: [email protected]
ops-add-repo-zigstd:
desc: "Add a ziglang/zig stdlib to doctree.org (requires operations access)"
cmds:
# TODO: Right now, we must cd into lib/std because otherwise indexing ziglang/zig fails!
- ssh $HOST -t 'rm -rf repo/'
- ssh $HOST -t 'git clone --depth 1 {{.CLI_ARGS}} repo'
- ssh $HOST -t 'chown 10000:10001 -R repo'
- ssh $HOST -t 'cd repo/lib/std && docker run -i --volume $(pwd):/index --volume /.doctree:/home/nonroot/.doctree --entrypoint=sh sourcegraph/doctree:latest -c "cd /index && doctree index -project=github.com/ziglang/zig ."'
# TODO why is this necessary? Docker volume becomes not in sync with host, how come?
- ssh $HOST -t 'docker restart doctree'
env:
HOST: [email protected]
ops-remove-all:
desc: "Remove all data from doctree.org (requires operations access)"
cmds:
- ssh $HOST -t 'rm -rf /.doctree'
- ssh $HOST -t 'mkdir /.doctree'
- ssh $HOST -t 'chown 10000:10001 -R /.doctree'
env:
HOST: [email protected]
ops-add-sample-repos:
desc: "Add sample repos to doctree.org (requires operations access)"
cmds:
- task ops-add-repo -- github.com/Sobeston/ziglearn
- task ops-add-repo -- github.com/alanhamlett/pip-update-requirements
- task ops-add-repo -- github.com/caddyserver/caddy
- task ops-add-repo -- github.com/cozy/cozy-stack
- task ops-add-repo -- github.com/django/django
- task ops-add-repo -- github.com/elastic/elasticsearch
- task ops-add-repo -- github.com/facebook/react
- task ops-add-repo -- github.com/gogs/gogs
- task ops-add-repo -- github.com/golang/go
- task ops-add-repo -- github.com/gorilla/mux
- task ops-add-repo -- github.com/hexops/mach
- task ops-add-repo -- github.com/jertel/elastalert2
- task ops-add-repo -- github.com/kevinwojo/mvs
- task ops-add-repo -- github.com/kooparse/zalgebra
- task ops-add-repo -- github.com/kooparse/zgltf
- task ops-add-repo -- github.com/paulshen/css-editor
- task ops-add-repo -- github.com/pytest-dev/pytest
- task ops-add-repo -- github.com/rasahq/rasa
- task ops-add-repo -- github.com/renode/renode
- task ops-add-repo -- github.com/saltbo/zpan
- task ops-add-repo -- github.com/smallstep/certificates
- task ops-add-repo -- github.com/sourcegraph/sourcegraph
- task ops-add-repo -- github.com/wakatime/wakatime-cli
- task ops-add-repo -- github.com/zephyrproject-rtos/zephyr
- task ops-add-repo -- github.com/ziglang/zig
env:
HOST: [email protected]
ops-deploy:
desc: "Deploy latest version to doctree.org (requires operations access)"
cmds:
- ssh $HOST -t 'docker pull sourcegraph/doctree:latest'
- ssh $HOST -t 'docker rm -f doctree || true'
- ssh $HOST -t 'docker run -d --restart=always --name doctree -p 80:3333 --volume /.doctree:/home/nonroot/.doctree sourcegraph/doctree:latest serve -cloud'
- ssh $HOST -t 'docker ps'
env:
HOST: [email protected]
dev-clone-sample-repos:
desc: "Clone sample repos for dev environment"
cmds:
- rm -rf ../doctree-samples/ && mkdir ../doctree-samples/
- cd ../doctree-samples/ && git clone --depth 1 https://github.com/golang/go
- cd ../doctree-samples/ && git clone --depth 1 https://github.com/gorilla/mux
- cd ../doctree-samples/ && git clone --depth 1 https://github.com/django/django
- cd ../doctree-samples/ && git clone --depth 1 https://github.com/Sobeston/ziglearn
- cd ../doctree-samples/ && git clone --depth 1 https://github.com/ziglang/zig
- cd ../doctree-samples/ && git clone --depth 1 https://github.com/tailwindlabs/tailwindcss
dev-index-sample-repos:
desc: "Index sample repos for dev environment"
cmds:
# Go
- cd ../doctree-samples/go && ../../doctree/.bin/doctree index .
- cd ../doctree-samples/mux && ../../doctree/.bin/doctree index .
# Python
- cd ../doctree-samples/django && ../../doctree/.bin/doctree index .
# Markdown
- cd ../doctree-samples/ziglearn && ../../doctree/.bin/doctree index .
# Zig
- cd ../doctree-samples/ziglang/lib/std && ../../doctree/.bin/doctree index -project=github.com/ziglang/zig .
# JavaScript
- cd ../doctree-samples/tailwindcss && ../../doctree/.bin/doctree index .