2023-03-23 12:58:52 -07:00
# yaml-language-server: $schema=https://json.schemastore.org/taskfile.json
2025-10-08 11:22:39 -07:00
# Root Taskfile - handles setup, orchestration, and repo-wide operations.
#
2022-04-06 08:50:42 -07:00
# This file gives new contributors an easy way to get everything they need,
2022-09-14 12:29:38 -07:00
# assuming `cargo` and [Task](https://taskfile.dev) are installed.
2025-10-08 11:22:39 -07:00
#
# Structure:
# - Root (this file): Setup, orchestration, repo-wide tasks (lint, test-all, build-all)
# - prqlc/: Core development tasks (test, test-all, pull-request)
# - web/: Web-related tasks (build, run-*)
#
2022-09-14 12:29:38 -07:00
# Beyond installing requirements, we generally shouldn't be using this as a
2023-06-20 17:15:03 -07:00
# 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`.
2022-04-06 08:50:42 -07:00
# Some of the file may be somewhat over-engineered!
2022-03-27 15:37:05 -07:00
2022-03-26 21:55:56 -07:00
version : "3"
2023-12-03 11:00:30 +01:00
includes :
prqlc :
taskfile : ./prqlc
dir : ./prqlc
2024-01-15 11:59:59 -08:00
zig :
taskfile : ./prqlc/bindings/prqlc-c/examples/minimal-zig
dir : ./prqlc/bindings/prqlc-c/examples/minimal-zig
2024-04-08 09:06:48 +02:00
web :
taskfile : ./web
dir : ./web
2024-05-11 11:38:37 -07:00
python :
taskfile : ./prqlc/bindings/prqlc-python
dir : ./prqlc/bindings/prqlc-python
2023-12-03 11:00:30 +01:00
2022-03-27 15:37:05 -07:00
vars :
2023-01-05 15:40:23 -08:00
# Keep in sync with .vscode/extensions.json
2022-03-27 15:37:05 -07:00
vscode_extensions : |
2022-06-26 14:52:34 -07:00
budparr.language-hugo-vscode
esbenp.prettier-vscode
mitsuhiko.insta
2022-11-05 23:44:32 -07:00
prql-lang.prql-vscode
2022-05-19 13:42:52 -07:00
rust-lang.rust-analyzer
2023-08-28 06:01:07 +09:00
cargo_crates : >
2024-01-13 18:15:45 -08:00
bacon cbindgen cargo-audit cargo-insta cargo-llvm-cov cargo-release
2025-12-27 13:36:10 -08:00
cargo-nextest default-target mdbook mdbook-admonish mdbook-footnote
mdbook-toc wasm-bindgen-cli wasm-opt
2024-09-23 12:57:21 -07:00
# wasm-pack waiting on https://github.com/rustwasm/wasm-pack/issues/1426
#
2023-08-19 11:50:25 -07:00
# Excluding `elixir` atm given it's not enabled on Mac and currently unsupported
brew_dependencies : |
hugo
2024-05-29 19:20:24 -07:00
jq
2023-08-19 11:50:25 -07:00
npm
2025-09-24 23:42:42 -07:00
uv
2024-05-29 19:20:24 -07:00
pre-commit
2023-08-19 11:50:25 -07:00
python3
2022-03-27 15:37:05 -07:00
2022-03-26 21:55:56 -07:00
tasks :
2022-10-20 20:07:15 -04:00
# main installer is "setup-dev" which calls other tasks
2022-04-23 00:57:56 -07:00
setup-dev :
2023-01-05 15:40:23 -08:00
preconditions :
- sh : which clang
msg : |
2023-08-19 11:50:25 -07:00
2023-01-05 15:40:23 -08:00
🔴 Can't find `clang`, which is required to install a full development environment (we use `duckdb` in our tests, which requires it).
2024-02-26 04:59:59 -08:00
Please install it. On macOS, that's
2023-01-05 15:40:23 -08:00
xcode-select --install
On Debian Linux, that's
apt-get update && apt-get install clang
2022-03-26 21:55:56 -07:00
desc : Install tools for PRQL development.
cmds :
2023-03-23 12:58:52 -07:00
- task : install-cargo-tools
2023-08-19 11:50:25 -07:00
# We only suggest, rather than install; we don't want to intrude (maybe
# we're being too conservative?).
2023-08-19 20:36:58 -07:00
- cmd : task check-vscode-extensions
ignore_error : true
- cmd : task check-brew-dependencies
ignore_error : true
2022-10-20 20:07:15 -04:00
- task : install-maturin
- task : install-npm-dependencies
- pre-commit install-hooks
2024-01-05 21:09:06 -08:00
- rustup component add llvm-tools-preview
2022-10-20 20:07:15 -04:00
- cmd : |
echo "
🟢 Setup complete! ✅🚀"
silent : true
install-cargo-tools :
2023-03-23 12:58:52 -07:00
desc : Install cargo tools for PRQL development.
cmds :
2023-04-11 22:03:37 -07:00
# 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 }}
2023-03-23 12:58:52 -07:00
- cmd : |
2023-08-19 11:50:25 -07:00
[ "$(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?"
2023-03-23 12:58:52 -07:00
silent : true
2023-04-11 22:03:37 -07:00
2024-05-29 19:20:24 -07:00
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 :
2025-09-24 23:42:42 -07:00
- uv tool install maturin
- uv tool upgrade maturin
2024-05-29 19:20:24 -07:00
2023-04-11 22:03:37 -07:00
install-cargo-tools-source :
cmds :
2023-08-19 11:50:25 -07:00
# `--locked` installs from the underlying lock files (which is not the
# default...)
2023-08-28 06:01:07 +09:00
- "cargo install --locked {{.cargo_crates}}"
2024-09-23 12:57:21 -07:00
- cargo install wasm-pack
2023-04-11 22:03:37 -07:00
install-cargo-tools-binstall :
cmds :
2024-07-27 16:30:10 -07:00
- cmd : cargo install --locked cargo-binstall
2023-07-01 13:23:08 +09:00
platforms : [ linux, darwin]
2023-08-28 06:01:07 +09:00
- "cargo binstall -y --locked {{.cargo_crates}}"
2024-09-23 12:57:21 -07:00
- cargo binstall -y wasm-pack
2023-04-11 22:03:37 -07:00
2023-08-19 20:36:58 -07:00
check-vscode-extensions :
2023-03-27 11:37:02 -07:00
desc : Check and suggest VS Code extensions.
2022-03-27 15:37:05 -07:00
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 ) -}}
2022-04-24 01:23:00 -07:00
{{ if not (contains . $.extensions) }}❌ {{.}} {{else}}✅ {{.}} {{ end }}
2022-03-27 15:37:05 -07:00
{{ end -}}
2022-03-27 12:24:50 -07:00
status :
2022-10-20 20:07:15 -04:00
# If vscode isn't installed, or there are no missing extensions,
# return 0 and exit early.
2022-12-21 23:04:17 -08:00
- '[ ! -x "$(which code)" ] || {{ not (contains "❌" .missing_extensions)
}}'
2022-03-27 12:24:50 -07:00
silent : true
cmds :
- |
2022-05-19 13:42:52 -07:00
echo "
2023-03-27 11:37:02 -07:00
🟡 It looks like VS Code is installed but doesn't have all recommended extensions installed:
2022-03-27 15:37:05 -07:00
{{ .missing_extensions }}
2022-03-27 12:24:50 -07:00
Install them with:
task install-vscode-extensions
2022-03-27 15:37:05 -07:00
"
2023-08-19 20:36:58 -07:00
- exit 1
2022-03-27 12:24:50 -07:00
install-vscode-extensions :
2023-03-27 11:37:02 -07:00
desc : Install recommended VS Code extensions.
2022-03-27 12:24:50 -07:00
cmds :
2022-03-27 15:37:05 -07:00
- |
{{ range ( .vscode_extensions | trim | splitLines ) -}}
code --install-extension {{.}}
{{ end -}}
2022-04-06 08:50:42 -07:00
2023-08-19 11:50:25 -07:00
check-brew-dependencies :
2022-05-19 13:42:52 -07:00
status :
2023-08-19 11:50:25 -07:00
- |
2023-09-08 13:45:32 -07:00
{{ range (.brew_dependencies | trim | splitLines) -}}
[ -n "$(which {{ . }})" ]
2023-08-19 11:50:25 -07:00
{{ end -}}
2023-09-02 01:05:14 -07:00
- |
[ "$(npm -v | awk -F. '{print ($1 > 9 || ($1 == 9 && $2 > 4)) ? 0 : 1}')" -eq 0 ]
2023-08-19 20:36:58 -07:00
silent : true
2023-08-19 11:50:25 -07:00
cmds :
- cmd : |
echo "
🟡 It looks like at least one brew dependency is missing from:
{{ .brew_dependencies }}
2023-09-02 01:05:14 -07:00
...or alternatively that npm < 9.4
These aren't required for initial PRQL development, but they are required for some of the extras.
2023-08-19 11:50:25 -07:00
Install them with:
task install-brew-dependencies
"
2023-08-19 20:36:58 -07:00
- exit 1
2023-08-19 11:50:25 -07:00
install-brew-dependencies :
2022-05-19 13:42:52 -07:00
preconditions :
- sh : which brew
msg : |
2023-08-19 11:50:25 -07:00
🔴 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/
2023-08-19 20:36:58 -07:00
status :
- task check-brew-dependencies
2022-05-19 13:42:52 -07:00
cmds :
2023-08-19 11:50:25 -07:00
- brew install {{.brew_dependencies | trim | splitLines | join " " }}
2022-05-19 13:42:52 -07:00
2022-06-23 00:13:32 -07:00
install-npm-dependencies :
cmds :
2023-10-15 11:09:34 -07:00
- npm install --global prettier prettier-plugin-go-template
2022-06-23 16:10:14 -07:00
- cmd :
2023-03-27 11:37:02 -07:00
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
2022-12-21 23:04:17 -08:00
prettier. See
2022-06-23 16:10:14 -07:00
https://github.com/NiklasPor/prettier-plugin-go-template/issues/58#issuecomment-1085060511
for more info."
silent : true
2022-06-23 00:13:32 -07:00
2022-04-06 08:50:42 -07:00
build-all :
2022-12-31 13:42:14 -08:00
desc : Build everything.
summary : |
Build everything.
Running this isn't required when developing; it's for caching or as a reference.
2022-04-06 08:50:42 -07:00
cmds :
2025-10-07 16:32:25 -07:00
- cargo build --all-targets --all-features --quiet
2023-04-03 11:23:36 -07:00
- cargo build --all-targets --all-features --target=wasm32-unknown-unknown
2025-10-07 16:32:25 -07:00
--quiet
2023-07-31 12:02:31 -07:00
# Build without features, as the dependencies have slightly different
# features themselves and so require recompiling. This is only useful for
# caching.
2025-10-07 16:32:25 -07:00
- cargo build --all-targets --quiet
- cargo build --all-targets --features=default,test-dbs --quiet
- cargo doc --quiet
2023-09-08 13:45:32 -07:00
- task : build-each-crate
2024-05-28 23:52:14 -07:00
- task : web:build
2024-05-11 11:38:37 -07:00
- task : python:build
2023-09-08 13:45:32 -07:00
build-each-crate :
summary : |
Builds each crates individually. This is helpful for caching, since often
2024-01-13 20:16:51 -08:00
we'll want to run `cargo build -p prqlc`, and the dependencies can have
2023-09-08 13:45:32 -07:00
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 ) -}}
2025-10-07 16:32:25 -07:00
cargo build --all-targets -p {{ . }} --quiet
2023-09-08 13:45:32 -07:00
{{ end -}}
2022-06-23 00:39:01 -07:00
2023-11-21 10:25:34 -08:00
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 :
- |
2024-06-19 23:21:46 -04:00
cargo test {{ range without (splitLines .PACKAGES) "prqlc-parser" }} -p={{ . }} {{ end }}
2023-11-21 10:25:34 -08:00
2022-06-23 00:39:01 -07:00
test-all :
2025-10-08 11:22:39 -07:00
desc : Test everything across all workspaces, accepting snapshots.
2022-12-31 13:42:14 -08:00
summary : |
Test everything, accepting snapshots.
Running this isn't required when developing; it's for caching or as a reference.
2022-12-07 11:58:49 -08:00
cmds :
2023-07-31 12:02:31 -07:00
# TODO:
2024-02-08 13:44:57 -08:00
# - We could add `prqlc-c` here.
2023-07-31 12:02:31 -07:00
# - We deliberately don't test some other bindings, such as `prql-php`,
2024-05-11 11:40:37 -07:00
# given they require more dependencies and aren't yet Supported. They
# run in CI.
2025-10-08 11:22:39 -07:00
- task : prqlc:pull-request
2023-01-15 18:29:57 -08:00
- task : test-js
2024-07-27 16:42:13 -07:00
# No nextest here as doesn't work with wasm
2025-04-08 16:34:29 +00:00
- cargo test --target=wasm32-unknown-unknown
2024-05-11 11:38:37 -07:00
- task : python:test
2023-09-08 13:45:32 -07:00
- task : build-all
2022-12-07 11:58:49 -08:00
2024-01-05 21:09:06 -08:00
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.
2024-06-24 17:21:02 -07:00
# 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"
2024-01-05 21:09:06 -08:00
cmds :
2024-01-18 17:16:33 -08:00
- cargo llvm-cov --lcov --output-path lcov.info
2024-01-08 17:18:55 -08:00
--features=default,test-dbs
2024-01-05 21:09:06 -08:00
2025-10-08 11:22:39 -07:00
lint :
desc : Run all lints (pre-commit & cargo clippy).
cmds :
- pre-commit run --all-files
- cargo clippy --all-targets --all-features
2024-09-05 12:41:09 -07:00
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
2023-01-15 18:29:57 -08:00
test-js :
2023-10-18 19:11:37 +02:00
dir : prqlc/bindings/js
2022-12-06 13:07:31 -08:00
cmds :
2022-12-18 21:43:14 -08:00
- npm cit
2022-12-13 10:12:38 -08:00
2023-02-19 19:47:37 -08:00
# Currently disabled; see prql-elixir/README.md for details
2023-03-26 00:05:20 -07:00
test-elixir :
2023-10-18 19:11:37 +02:00
dir : prqlc/bindings/elixir
2023-03-26 00:05:20 -07:00
cmds :
# We could move this line into an `install` task
- mix local.hex --force
- mix deps.get --force
- mix compile
- mix test
2023-01-14 14:17:28 +05:30
2023-07-28 17:51:30 -07:00
build-php :
2024-01-13 18:15:45 -08:00
- cargo build --package prqlc-c --release
2023-10-18 19:11:37 +02:00
- mkdir -p prqlc/bindings/php/lib/
2024-01-13 18:15:45 -08:00
- cp target/release/libprqlc_c.* prqlc/bindings/prqlc-c/prqlc.h
2023-10-18 19:11:37 +02:00
prqlc/bindings/php/lib/
- cd prqlc/bindings/php && composer install
2023-07-28 17:51:30 -07:00
2024-01-13 18:15:45 -08:00
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
2023-07-28 17:51:30 -07:00
test-php :
2023-10-18 19:11:37 +02:00
dir : prqlc/bindings/php
2023-07-28 17:51:30 -07:00
cmds :
- vendor/bin/phpunit tests
2024-05-11 11:40:37 -07:00
# The next two tasks are not used for either:
2022-10-20 20:07:15 -04:00
# - the Dockerfile (installing brew takes forever)
# so the Dockerfile simply installs hugo & nodejs directly
2024-06-09 16:19:05 -07:00
# - 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
2022-10-20 20:07:15 -04:00
# 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