-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
426 lines (366 loc) · 13.5 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
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# yaml-language-server: $schema=https://json.schemastore.org/taskfile.json
# This file gives new contributors an easy way to get everything they need,
# assuming `cargo` and [Task](https://taskfile.dev) are installed.
# Beyond installing requirements, we generally shouldn't be using this as a
# Makefile — in other words, we shouldn't require running this as part of normal
# development. Rust tools are independently good, and adding an intermediate
# layer means we're reimplementing things or getting in the way. Instead, this
# can be used to aggregate commands that are currently separate; e.g. check out
# `test-all`.
# Some of the file may be somewhat over-engineered!
version: "3"
includes:
prqlc:
taskfile: ./prqlc
dir: ./prqlc
zig:
taskfile: ./prqlc/bindings/prqlc-c/examples/minimal-zig
dir: ./prqlc/bindings/prqlc-c/examples/minimal-zig
lutra:
taskfile: ./lutra
dir: ./lutra
web:
taskfile: ./web
dir: ./web
python:
taskfile: ./prqlc/bindings/prqlc-python
dir: ./prqlc/bindings/prqlc-python
vars:
# Keep in sync with .vscode/extensions.json
vscode_extensions: |
budparr.language-hugo-vscode
esbenp.prettier-vscode
mitsuhiko.insta
prql-lang.prql-vscode
rust-lang.rust-analyzer
cargo_crates: >
bacon cbindgen cargo-audit cargo-insta cargo-llvm-cov cargo-release
cargo-nextest default-target mdbook mdbook-admonish mdbook-footnote
mdbook-toc wasm-bindgen-cli wasm-opt
# wasm-pack waiting on https://github.com/rustwasm/wasm-pack/issues/1426
#
# Excluding `elixir` atm given it's not enabled on Mac and currently unsupported
brew_dependencies: |
hugo
jq
npm
pipx
pre-commit
python3
tasks:
# main installer is "setup-dev" which calls other tasks
setup-dev:
preconditions:
- sh: which clang
msg: |
🔴 Can't find `clang`, which is required to install a full development environment (we use `duckdb` in our tests, which requires it).
Please install it. On macOS, that's
xcode-select --install
On Debian Linux, that's
apt-get update && apt-get install clang
desc: Install tools for PRQL development.
cmds:
- task: install-cargo-tools
# We only suggest, rather than install; we don't want to intrude (maybe
# we're being too conservative?).
- cmd: task check-vscode-extensions
ignore_error: true
- cmd: task check-brew-dependencies
ignore_error: true
- task: install-maturin
- task: install-npm-dependencies
- pre-commit install-hooks
- rustup component add llvm-tools-preview
- cmd: |
echo "
🟢 Setup complete! ✅🚀"
silent: true
install-cargo-tools:
desc: Install cargo tools for PRQL development.
cmds:
# In CI we use `binstall`, because it's faster, and without it we can't
# even get the arm64 docker image to build within the GHA timeout. But it
# produces lots of confusing warning messages about 429 errors, I think
# because it's querying GitHub for so many packages; so we only use it for
# CI atm. If the warnings were less alarming, we could use for all
# installs.
#
- |
{{ if .CI }}
task install-cargo-tools-binstall
{{ else }}
task install-cargo-tools-source
{{ end }}
- cmd: |
[ "$(which cargo-insta)" ] || echo "🔴 Can't find a binary that cargo just installed. Is the cargo bin path (generally at `~/.cargo/bin`) on the \$PATH?"
silent: true
install-maturin:
desc: Install maturin.
# Someone might have this installed with another approach, so only install
# if it can't be found.
status:
- which maturin
cmds:
- pipx install maturin
- pipx upgrade maturin
install-cargo-tools-source:
cmds:
# `--locked` installs from the underlying lock files (which is not the
# default...)
- "cargo install --locked {{.cargo_crates}}"
- cargo install wasm-pack
install-cargo-tools-binstall:
cmds:
- cmd: cargo install --locked cargo-binstall
platforms: [linux, darwin]
- "cargo binstall -y --locked {{.cargo_crates}}"
- cargo binstall -y wasm-pack
check-vscode-extensions:
desc: Check and suggest VS Code extensions.
vars:
extensions:
# List extensions, or just return true if we can't find `code`.
sh: which code && code --list-extensions || true
missing_extensions: |
{{ range ( .vscode_extensions | trim | splitLines ) -}}
{{ if not (contains . $.extensions) }}❌ {{.}} {{else}}✅ {{.}} {{ end }}
{{ end -}}
status:
# If vscode isn't installed, or there are no missing extensions,
# return 0 and exit early.
- '[ ! -x "$(which code)" ] || {{ not (contains "❌" .missing_extensions)
}}'
silent: true
cmds:
- |
echo "
🟡 It looks like VS Code is installed but doesn't have all recommended extensions installed:
{{ .missing_extensions }}
Install them with:
task install-vscode-extensions
"
- exit 1
install-vscode-extensions:
desc: Install recommended VS Code extensions.
cmds:
- |
{{ range ( .vscode_extensions | trim | splitLines ) -}}
code --install-extension {{.}}
{{ end -}}
check-brew-dependencies:
status:
- |
{{ range (.brew_dependencies | trim | splitLines) -}}
[ -n "$(which {{ . }})" ]
{{ end -}}
- |
[ "$(npm -v | awk -F. '{print ($1 > 9 || ($1 == 9 && $2 > 4)) ? 0 : 1}')" -eq 0 ]
silent: true
cmds:
- cmd: |
echo "
🟡 It looks like at least one brew dependency is missing from:
{{ .brew_dependencies }}
...or alternatively that npm < 9.4
These aren't required for initial PRQL development, but they are required for some of the extras.
Install them with:
task install-brew-dependencies
"
- exit 1
install-brew-dependencies:
preconditions:
- sh: which brew
msg: |
🔴 Can't find `brew`, which we use to install {{ .brew_dependencies | trim | splitLines | join " & " }}.
Either install brew & re-run this, or install the dependencies with a different approach, or use PRQL without them.
Brew installation instructions at:
https://brew.sh/
status:
- task check-brew-dependencies
cmds:
- brew install {{.brew_dependencies | trim | splitLines | join " " }}
install-npm-dependencies:
cmds:
- npm install --global prettier prettier-plugin-go-template
- cmd:
echo "In order to get nice auto-formatting of web code in VS Code, VS
Code requires configuration to use the system-wide install of
prettier. See
https://github.com/NiklasPor/prettier-plugin-go-template/issues/58#issuecomment-1085060511
for more info."
silent: true
build-all:
desc: Build everything.
summary: |
Build everything.
Running this isn't required when developing; it's for caching or as a reference.
cmds:
- cargo build --all-targets --all-features
- cargo build --all-targets --all-features --target=wasm32-unknown-unknown
# Build without features, as the dependencies have slightly different
# features themselves and so require recompiling. This is only useful for
# caching.
- cargo build --all-targets
- cargo build --all-targets --features=default,test-dbs
- cargo doc
- task: build-each-crate
- task: web:build
- task: python:build
build-each-crate:
summary: |
Builds each crates individually. This is helpful for caching, since often
we'll want to run `cargo build -p prqlc`, and the dependencies can have
different features for that relative to `cargo build`.
vars:
PACKAGES:
sh:
cargo metadata --format-version=1 | jq -r '.workspace_members[] |
split(" ")[0]'
preconditions:
- sh: command -v jq
msg: "jq is not available. Please install it to continue."
cmds:
- |
{{ range ( .PACKAGES | splitLines ) -}}
cargo build --all-targets -p {{ . }}
{{ end -}}
test-rust-api:
summary: |
Run tests, excluding some internal crates
vars:
PACKAGES:
sh:
cargo metadata --format-version=1 | jq -r '.workspace_members[] |
split(" ")[0]'
cmds:
- |
cargo test {{ range without (splitLines .PACKAGES) "prqlc-parser" }} -p={{ . }} {{ end }}
test-all:
desc: Test everything, accepting snapshots.
summary: |
Test everything, accepting snapshots.
Running this isn't required when developing; it's for caching or as a reference.
cmds:
# TODO:
# - We could add `prqlc-c` here.
# - We deliberately don't test some other bindings, such as `prql-php`,
# given they require more dependencies and aren't yet Supported. They
# run in CI.
- task: test-lint
- task: test-rust
- task: test-js
# No nextest here as doesn't work with wasm
- cargo insta test --accept --target=wasm32-unknown-unknown
- task: python:test
- task: build-all
test-rust:
desc: Test all rust code, accepting snapshots.
# Commenting out the ability to watch, since Task doesn't handle watching
# big directories well: https://github.com/go-task/task/issues/985
#
# sources:
# - "**/*.rs"
# - "**/*.md"
# - "**/*.toml"
# - "**/*.lock"
# - "**/*.snap"
cmds:
- cargo insta test --accept --features=default,test-dbs
--test-runner=nextest --unreferenced=auto
- cargo clippy --fix --allow-dirty --allow-staged
test-rust-fast:
desc: Test prqlc's unit tests.
summary: |
Test only unit tests, including accepting snapshots.
This can be useful as an inner loop when developing, by running this on any file change.
Use `-w` to get that behavior:
task -w test-rust-fast
New or changed snapshots are accepted, and expected to be reviewed with git.
env:
RUST_BACKTRACE: 1
sources:
# I don't think we can specify this is a single glob, which would be nice.
- "prqlc/**/*.rs"
- "prqlc/**/*.snap"
cmds:
- cargo insta test --accept --lib --test-runner=nextest
test-rust-coverage:
desc: Run tests with instrumentation for code coverage.
summary:
Run tests with instrumentation for code coverage. This works with VS
Code's [Coverage
Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters)
extension.
# We previously had a different target dir, but the default seems to use `target/llvm-cov` as its target already, so we can remove this assuming it works OK
# env:
# CARGO_TARGET_DIR: "./target-cov"
cmds:
- cargo llvm-cov --lcov --output-path lcov.info
--features=default,test-dbs
test-rust-external-dbs:
desc: Run tests which require external databases, with docker
cmds:
- cmd:
echo "🔵 Starting docker containers. In some circumstances the tests
will start before images are ready. After one initial failure, try
re-running."
silent: true
- cd prqlc/prqlc/tests/integration/dbs && docker compose up --wait
# This _only_ runs the external dbs tests, but we could make it run
# everything?
- cargo test --features=test-dbs-external --test=integration --
--nocapture queries::results
# We could run this ourselves, but makes iteration times much longer
- cmd: |
echo "🔵 To remove containers and remove local built images, run
cd prqlc/prqlc/tests/integration/dbs && docker compose down --rmi local"
silent: true
test-js:
dir: prqlc/bindings/js
cmds:
- npm cit
# Currently disabled; see prql-elixir/README.md for details
test-elixir:
dir: prqlc/bindings/elixir
cmds:
# We could move this line into an `install` task
- mix local.hex --force
- mix deps.get --force
- mix compile
- mix test
test-lint:
desc: Run pre-commit
cmds:
- pre-commit run -a
build-php:
- cargo build --package prqlc-c --release
- mkdir -p prqlc/bindings/php/lib/
- cp target/release/libprqlc_c.* prqlc/bindings/prqlc-c/prqlc.h
prqlc/bindings/php/lib/
- cd prqlc/bindings/php && composer install
build-prqlc-c-header:
desc: Build the C header for the C bindings.
dir: prqlc/bindings/prqlc-c
cmds:
- cbindgen --crate prqlc-c --output prqlc.h
- cbindgen --crate prqlc-c --lang C++ --output prqlc.hpp
test-php:
dir: prqlc/bindings/php
cmds:
- vendor/bin/phpunit tests
# The next two tasks are not used for either:
# - the Dockerfile (installing brew takes forever)
# so the Dockerfile simply installs hugo & nodejs directly
# - the "desktop setup" - it uses other tasks in the Taskfile.yaml
# They remain in the Taskfile.yaml as a hint if they should ever be needed
# install-hugo:
# cmds:
# # - /home/linuxbrew/.linuxbrew/bin/brew install hugo
# - curl -L https://github.com/gohugoio/hugo/releases/download/v0.91.2/hugo_0.91.2_Linux-64bit.deb -o hugo.deb
# - apt install ./hugo.deb
# install-nodejs:
# cmds:
# # - /home/linuxbrew/.linuxbrew/bin/brew install nodejs
# - curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
# - apt install -y nodejs
# - cd /app/playground/ ; npm install