-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
240 lines (213 loc) · 8.27 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
# 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, requiring running this to have a good dev loop — 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's are currently separate; e.g. check out `test-all`.
# Some of the file may be somewhat over-engineered!
version: "3"
vars:
# Keeps 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
tasks:
# main installer is "setup-dev" which calls other tasks
setup-dev:
desc: Install tools for PRQL development.
cmds:
- task: install-cargo-tools
- task: install-maturin
- task: install-pre-commit
- task: install-brew-dependencies
- task: install-npm-dependencies
# We only suggest, rather than install;
# we don't want to intrude (maybe we're being too conservative?).
- task: suggest-vscode-extensions
- pre-commit install-hooks
- cmd: |
echo "
🟢 Setup complete! ✅🚀"
silent: true
install-cargo-tools:
# factored this out because it takes a long time to build
desc: Install cargo tools for PRQL development.
cmds:
# `--locked` installs from the underlying lock files (which is not the
# default?!)
- cargo install --locked cargo-audit cargo-insta cargo-release
default-target mdbook mdbook-admonish mdbook-toc wasm-bindgen-cli
wasm-pack
- cmd: |
[ "$(which default-target)" ] || echo "Can't find a binary that cargo installed. Is the cargo bin path (generally at ~/.cargo/bin) on the $PATH?"
silent: true
install-maturin:
desc: Install maturin
cmds:
- python3 -m pip install -U maturin
suggest-vscode-extensions:
desc: Check and suggest VSCode 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 VSCode is installed but doesn't have all recommended extensions installed:
{{ .missing_extensions }}
Install them with:
task install-vscode-extensions
"
install-vscode-extensions:
desc: Install recommended VSCode extensions.
cmds:
- |
{{ range ( .vscode_extensions | trim | splitLines ) -}}
code --install-extension {{.}}
{{ end -}}
install-pre-commit:
# Someone might have this installed with `brew`,
# so only install if it can't be found.
status:
- which pre-commit
cmds:
- python3 -m pip install -U pre-commit
install-brew-dependencies:
status:
- which hugo
- which npm
preconditions:
- sh: which brew
msg: |
🔴 Can't find `brew`, which we use to install Hugo & npm. Either install brew and re-run this, or install them directly based on:
- https://gohugo.io/getting-started/installing/
- https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
cmds:
- brew install hugo npm
install-npm-dependencies:
cmds:
- npm install --location=global prettier prettier-plugin-go-template
- cmd:
echo "In order to get nice auto-formatting of web code in VSCode,
VSCode 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. Running this isn't required when developing; it's for
caching or as a reference.
vars:
default_target:
sh: default-target
targets: |
{{ .default_target }}
wasm32-unknown-unknown
cmds:
- |
{{ range ( .targets | trim | splitLines ) -}}
cargo build --all-targets --target={{.}}
{{ end -}}
- task: build-web
test-all:
desc:
Test everything, resetting snapshots. Running this isn't required when
developing; it's for caching or as a reference.
cmds:
- task: test-rust
- task: build-all
- pre-commit run -a
test-rust:
desc: Test all rust code, resetting snapshots.
vars:
default_target:
sh: default-target
cmds:
# We run this `run_examples` first for the reasons given in
# `parser::test_parse_pipeline_parse_tree`. Ideally we would a) retain
# examples in the documentation (inc. tested), b) not rely on falliable
# tests to extract them, which include compiling prql-compiler, c) not
# fail other compilation steps if they can't be extracted.
- cargo insta test --accept -p mdbook-prql -- run_examples
# Only delete unreferenced snapshots on the default target — lots are excluded under wasm.
- cargo insta test --accept --target={{.default_target}}
--delete-unreferenced-snapshots
- cargo insta test --accept --target=wasm32-unknown-unknown
build-web:
desc: Build the website
cmds:
- cd website && hugo --minify
- cd book && mdbook build
- mkdir -p website/public
# Copy the book into the website path, using rsync so it only copies new files
- rsync -ai --checksum --delete book/book/ website/public/book/
# Must set `install-links=false` for the playground `npm install` to install prql-js
# as the regular dependencie instead of creating a symlink.
# Refer to https://github.com/PRQL/prql/pull/1296.
- cd playground && npm install --install-links=false
- cd playground && npm run build
- rsync -ai --checksum --delete playground/build/
website/public/playground/
test-prql-js:
# These are mostly copied from the tasks in `test-all.yaml`
dir: prql-js
cmds:
- npm run build
- npm cit
run-book:
dir: book
cmds:
- mdbook serve --port=3000
run-playground:
dir: playground
cmds:
# Must set `install-links=false` for the playground `npm install` to install prql-js
# as the regular dependencie instead of creating a symlink.
# Refer to https://github.com/PRQL/prql/pull/1296.
- npm install --install-links=false
- npm start
# The next three 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.yml
# They remain in the Taskfile.yml as a hint if they should ever be needed
# install-brew:
# # Initially added for building Docker container
# status:
# - which brew
# cmds:
# # https://stackoverflow.com/questions/58292862/how-to-install-homebrew-on-ubuntu-inside-docker-container
# - useradd -m -s /bin/zsh linuxbrew
# - usermod -aG sudo linuxbrew
# - mkdir -p /home/linuxbrew/.linuxbrew
# - chown -R linuxbrew /home/linuxbrew/.linuxbrew
# - export HOMEBREW_INSTALL_FROM_API=1
# - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# - chown -R $CONTAINER_USER: /home/linuxbrew/.linuxbrew
# 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