2023-12-19 12:04:02 +03:00
|
|
|
set positional-arguments
|
|
|
|
|
2024-03-13 14:14:07 +03:00
|
|
|
CLIPPY_ARGS := "-A clippy::result_large_err -D clippy::complexity -A clippy::too_many_arguments -D clippy::style"
|
|
|
|
CLIPPY_FIX_ARGS := "-A clippy::result_large_err -A clippy::too_many_arguments"
|
2024-03-15 20:23:10 +03:00
|
|
|
BUILD_PACKAGE_LIST := "-p custom-connector -p engine -p hasura-authn-core -p hasura-authn-webhook -p hasura-authn-jwt -p lang-graphql -p open-dds -p opendds-derive -p tracing-util"
|
2024-03-13 14:14:07 +03:00
|
|
|
|
2023-12-19 12:04:02 +03:00
|
|
|
default:
|
|
|
|
just --list
|
|
|
|
|
|
|
|
# run commands in a rust docker environment with source code only without starting any dependencies.
|
|
|
|
docker_with_source_only +args:
|
|
|
|
#!/usr/bin/env sh
|
|
|
|
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f ci.docker-compose.yaml run --build --rm source_only "$@"
|
|
|
|
exit_code=$?
|
|
|
|
docker compose -f ci.docker-compose.yaml down
|
|
|
|
exit $exit_code
|
|
|
|
|
|
|
|
# run commands in a rust docker environment including test dependencies and then removes the container dependencies
|
|
|
|
# while emiting the exit code of the docker command
|
|
|
|
docker_with_test_env +args:
|
|
|
|
#!/usr/bin/env sh
|
|
|
|
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f ci.docker-compose.yaml run --build --rm test_setup "$@"
|
|
|
|
exit_code=$?
|
|
|
|
docker compose -f ci.docker-compose.yaml down
|
|
|
|
exit $exit_code
|
|
|
|
|
|
|
|
# build used by CI
|
|
|
|
ci-build:
|
|
|
|
# see https://github.com/rust-lang/cargo/issues/4463 for why we build each
|
|
|
|
# package explictly instead of cargo build --workspace --all-targets
|
2024-03-15 20:23:10 +03:00
|
|
|
just docker_with_source_only \
|
|
|
|
cargo build {{ BUILD_PACKAGE_LIST }} \
|
|
|
|
--release --all-targets
|
|
|
|
|
|
|
|
build-local:
|
|
|
|
# see https://github.com/rust-lang/cargo/issues/4463 for why we build each
|
|
|
|
# package explictly instead of cargo build --workspace --all-targets
|
|
|
|
cargo build {{ BUILD_PACKAGE_LIST }} \
|
|
|
|
--release --all-targets
|
2023-12-19 12:04:02 +03:00
|
|
|
|
|
|
|
# linting run by CI
|
|
|
|
ci-lint:
|
|
|
|
just docker_with_source_only sh -c \
|
2024-03-13 14:14:07 +03:00
|
|
|
"cargo clippy --no-deps -- {{ CLIPPY_ARGS }}"
|
2023-12-19 12:04:02 +03:00
|
|
|
|
|
|
|
fix:
|
2024-03-13 14:14:07 +03:00
|
|
|
just docker_with_source_only sh -c "cargo clippy --no-deps --fix --allow-no-vcs -- {{ CLIPPY_FIX_ARGS }}; cargo fmt"
|
2023-12-19 12:04:02 +03:00
|
|
|
|
|
|
|
fix-local:
|
2024-03-13 14:14:07 +03:00
|
|
|
cargo clippy --no-deps --fix --allow-no-vcs -- {{ CLIPPY_FIX_ARGS }}; cargo fmt
|
2023-12-19 12:04:02 +03:00
|
|
|
|
|
|
|
# tests run by CI
|
|
|
|
ci-test:
|
|
|
|
just docker_with_test_env cargo nextest run
|
|
|
|
|
|
|
|
test *TESTNAME:
|
|
|
|
if [ -z {{TESTNAME}} ]; then \
|
|
|
|
just docker_with_test_env cargo nextest run -E 'all()'; \
|
|
|
|
else \
|
|
|
|
just docker_with_test_env cargo nextest run -E 'test(={{TESTNAME}})'; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
# tests using cargo test and not nextest.
|
|
|
|
# The nextest binary pulled in the docker image only works on linux hosts.
|
|
|
|
cargo-test *args:
|
|
|
|
just docker_with_test_env cargo test {{args}}
|
|
|
|
|
|
|
|
update-golden-files:
|
|
|
|
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f ci.docker-compose.yaml run --build --rm -e REGENERATE_GOLDENFILES=1 test_setup cargo test
|
|
|
|
|
|
|
|
# Benchmarks run by CI
|
|
|
|
ci-bench:
|
|
|
|
# Only bench what is required
|
|
|
|
just docker_with_test_env cargo bench \
|
|
|
|
-p lang-graphql --bench validation --bench parser \
|
|
|
|
-p engine --bench generate_ir --bench execute
|
|
|
|
|
|
|
|
drill:
|
|
|
|
just docker_with_test_env drill --benchmark drill.yml -s -q
|
|
|
|
|
|
|
|
# optional argument to show coverage only for files matched by {{filterexp}} i.e. grep -E filterexp
|
|
|
|
coverage *filterexp:
|
|
|
|
just docker_with_source_only bash coverage.sh '{{filterexp}}'
|
|
|
|
|
|
|
|
generate-benchmarks gh-issue gh-token:
|
|
|
|
just docker_with_test_env bash benchmark.sh {{gh-issue}} {{gh-token}}
|
|
|
|
|
|
|
|
dev:
|
|
|
|
docker compose run --build --rm dev_setup bash
|
|
|
|
docker compose down
|
2024-03-12 18:26:31 +03:00
|
|
|
|
|
|
|
# start all the docker deps (not engine)
|
|
|
|
start-docker:
|
|
|
|
# start connectors and wait for health
|
|
|
|
docker compose -f ci.docker-compose.yaml \
|
|
|
|
up --wait postgres custom_connector
|
|
|
|
# start everything else (don't wait for postgres connector, it doesn't seem
|
|
|
|
# to work)
|
|
|
|
docker compose -f ci.docker-compose.yaml \
|
|
|
|
up -d
|
|
|
|
|
|
|
|
# stop all the docker deps
|
|
|
|
stop-docker:
|
|
|
|
docker compose -f ci.docker-compose.yaml down -v
|
|
|
|
|
|
|
|
# local development commands
|
|
|
|
|
|
|
|
# these work by running tests locally rather than in Docker
|
|
|
|
# to make them work, add the following lines to your `/etc/hosts` file
|
|
|
|
# (without the '#' at the start):
|
|
|
|
# 127.0.0.1 postgres_connector
|
|
|
|
# 127.0.0.1 custom_connector
|
|
|
|
|
|
|
|
# run the tests using local engine (once)
|
2024-03-13 14:14:07 +03:00
|
|
|
test-local: start-docker
|
2024-03-12 18:26:31 +03:00
|
|
|
cargo test
|
|
|
|
|
|
|
|
# run a watch process that runs the tests locally
|
2024-03-13 14:14:07 +03:00
|
|
|
watch-local: start-docker
|
|
|
|
cargo watch \
|
|
|
|
-x test \
|
|
|
|
-x 'clippy --no-deps -- {{ CLIPPY_ARGS }}'
|
|
|
|
|
|
|
|
# check the code is fine
|
|
|
|
lint-local:
|
2024-03-15 20:23:10 +03:00
|
|
|
cargo clippy --no-deps -- {{ CLIPPY_ARGS }}
|
2024-03-12 18:26:31 +03:00
|
|
|
|
2024-03-15 16:05:32 +03:00
|
|
|
# update golden tests
|
|
|
|
update-golden-files-local: start-docker
|
|
|
|
REGENERATE_GOLDENFILES=1 cargo test
|
|
|
|
|