2023-12-19 12:04:02 +03:00
|
|
|
set positional-arguments
|
|
|
|
|
2024-03-21 13:40:01 +03:00
|
|
|
# This produces "-p engine -p lang-graphql -p ...".
|
|
|
|
# See https://github.com/rust-lang/cargo/issues/4463 for why we build each
|
|
|
|
# package explicitly instead of `cargo build --workspace --all-targets`.
|
|
|
|
PACKAGE_SELECTOR := `ls crates | sed 's/^/-p /' | xargs echo`
|
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
|
2024-04-22 16:42:32 +03:00
|
|
|
docker compose -f ci.docker-compose.yaml run --build --rm source_only "$@"
|
2023-12-19 12:04:02 +03:00
|
|
|
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
|
2024-04-22 16:42:32 +03:00
|
|
|
docker compose -f ci.docker-compose.yaml run --build --rm test_setup "$@"
|
2023-12-19 12:04:02 +03:00
|
|
|
exit_code=$?
|
|
|
|
docker compose -f ci.docker-compose.yaml down
|
|
|
|
exit $exit_code
|
|
|
|
|
|
|
|
# build used by CI
|
|
|
|
ci-build:
|
2024-03-15 20:23:10 +03:00
|
|
|
just docker_with_source_only \
|
2024-03-21 13:40:01 +03:00
|
|
|
cargo build {{ PACKAGE_SELECTOR }} --release --all-targets
|
2024-03-15 20:23:10 +03:00
|
|
|
|
|
|
|
build-local:
|
2024-03-21 13:40:01 +03:00
|
|
|
cargo build {{ PACKAGE_SELECTOR }} --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-04-08 13:13:26 +03:00
|
|
|
"RUSTFLAGS='-D warnings' cargo clippy --no-deps"
|
2023-12-19 12:04:02 +03:00
|
|
|
|
|
|
|
fix:
|
2024-04-08 13:13:26 +03:00
|
|
|
just docker_with_source_only sh -c "cargo clippy --no-deps --fix --allow-no-vcs; cargo fmt"
|
2023-12-19 12:04:02 +03:00
|
|
|
|
2024-04-02 18:08:38 +03:00
|
|
|
format:
|
|
|
|
cargo fmt --check
|
Format everything with Prettier. (#530)
I found myself wanting to rewrite JSON files with `sed`. The problem is,
then I want to run a formatter over them afterwards, and this will
change the whole file, not just the area I touched.
I would like to propose the nuclear option in remedying this: format
everything now. This is a very large change that should make it easier
to keep files to a consistent format in the future.
I have chosen to use Prettier for this because (a) it has a useful
`--write` command and (b) it also does GraphQL, Markdown, YAML, etc.
I've elected to exclude two sets of files:
1. `crates/custom-connector/data/*.json`, because they are actually
multiple JSON objects, one per line, which Prettier cannot parse.
2. `crates/lang-graphql/tests/**/*.graphql`, because it contains invalid
GraphQL, and the parser is intended to work with strangely-formatted
GraphQL.
The main changes are standardizing whitespace, adding a newline at the
end of files, and putting JSON arrays on one line when they fit.
V3_GIT_ORIGIN_REV_ID: 92d4a535c34a3cc00721e8ddc6f17c5717e8ff76
2024-04-30 17:58:09 +03:00
|
|
|
prettier --check .
|
2024-04-02 18:08:38 +03:00
|
|
|
alias fmt := format
|
|
|
|
|
2023-12-19 12:04:02 +03:00
|
|
|
fix-local:
|
2024-04-08 13:13:26 +03:00
|
|
|
cargo clippy --no-deps --fix --allow-no-vcs
|
|
|
|
cargo fmt
|
Format everything with Prettier. (#530)
I found myself wanting to rewrite JSON files with `sed`. The problem is,
then I want to run a formatter over them afterwards, and this will
change the whole file, not just the area I touched.
I would like to propose the nuclear option in remedying this: format
everything now. This is a very large change that should make it easier
to keep files to a consistent format in the future.
I have chosen to use Prettier for this because (a) it has a useful
`--write` command and (b) it also does GraphQL, Markdown, YAML, etc.
I've elected to exclude two sets of files:
1. `crates/custom-connector/data/*.json`, because they are actually
multiple JSON objects, one per line, which Prettier cannot parse.
2. `crates/lang-graphql/tests/**/*.graphql`, because it contains invalid
GraphQL, and the parser is intended to work with strangely-formatted
GraphQL.
The main changes are standardizing whitespace, adding a newline at the
end of files, and putting JSON arrays on one line when they fit.
V3_GIT_ORIGIN_REV_ID: 92d4a535c34a3cc00721e8ddc6f17c5717e8ff76
2024-04-30 17:58:09 +03:00
|
|
|
prettier --write .
|
2023-12-19 12:04:02 +03:00
|
|
|
|
|
|
|
# tests run by CI
|
2024-04-03 14:50:56 +03:00
|
|
|
ci-test: docker-refresh
|
2024-04-22 16:42:32 +03:00
|
|
|
just docker_with_test_env cargo nextest run --archive-file=./bin/nextest.tar.zst --no-fail-fast
|
2024-04-03 11:03:18 +03:00
|
|
|
|
|
|
|
test TESTNAME='':
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
if [[ -z '{{TESTNAME}}' ]]; then
|
2024-04-22 16:42:32 +03:00
|
|
|
COMMAND=(cargo nextest run --archive-file=./bin/nextest.tar.zst --no-fail-fast)
|
2024-04-03 11:03:18 +03:00
|
|
|
else
|
2024-04-22 16:42:32 +03:00
|
|
|
COMMAND=(cargo nextest run --archive-file=./bin/nextest.tar.zst --no-fail-fast -E 'test(={{TESTNAME}})')
|
2023-12-19 12:04:02 +03:00
|
|
|
fi
|
2024-04-22 16:42:32 +03:00
|
|
|
echo "${COMMAND[*]}"
|
|
|
|
just docker_with_test_env "${COMMAND[@]}"
|
2023-12-19 12:04:02 +03:00
|
|
|
|
2024-04-03 14:50:56 +03:00
|
|
|
update-golden-files: docker-refresh
|
2024-04-22 16:42:32 +03:00
|
|
|
docker compose -f ci.docker-compose.yaml run --rm -e REGENERATE_GOLDENFILES=1 test_setup \
|
|
|
|
cargo nextest run --archive-file=./bin/nextest.tar.zst --no-fail-fast
|
2023-12-19 12:04:02 +03:00
|
|
|
|
|
|
|
# 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
|
|
|
|
2024-04-03 11:03:18 +03:00
|
|
|
# start all the docker deps for running tests (not engine)
|
2024-03-28 13:26:32 +03:00
|
|
|
start-docker-test-deps:
|
2024-03-12 18:26:31 +03:00
|
|
|
# start connectors and wait for health
|
2024-04-03 14:50:56 +03:00
|
|
|
docker compose -f ci.docker-compose.yaml up --wait postgres postgres_connector custom_connector
|
2024-03-12 18:26:31 +03:00
|
|
|
|
2024-03-28 13:26:32 +03:00
|
|
|
# start all the docker run time deps for the engine
|
|
|
|
start-docker-run-deps:
|
|
|
|
# start auth_hook and jaeger
|
|
|
|
docker compose up --wait auth_hook jaeger
|
|
|
|
|
2024-04-03 14:50:56 +03:00
|
|
|
# pull / build all docker deps
|
|
|
|
docker-refresh:
|
|
|
|
docker compose -f ci.docker-compose.yaml pull postgres_connector
|
|
|
|
docker compose -f ci.docker-compose.yaml build custom_connector
|
|
|
|
|
2024-03-12 18:26:31 +03:00
|
|
|
# stop all the docker deps
|
|
|
|
stop-docker:
|
|
|
|
docker compose -f ci.docker-compose.yaml down -v
|
2024-03-28 13:26:32 +03:00
|
|
|
docker compose down -v
|
2024-03-12 18:26:31 +03:00
|
|
|
|
|
|
|
# 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-28 13:26:32 +03:00
|
|
|
test-local: start-docker-test-deps
|
2024-03-12 18:26:31 +03:00
|
|
|
cargo test
|
|
|
|
|
|
|
|
# run a watch process that runs the tests locally
|
2024-03-29 09:36:19 +03:00
|
|
|
watch-local: start-docker-test-deps start-docker-run-deps
|
|
|
|
RUST_LOG=DEBUG \
|
2024-03-13 14:14:07 +03:00
|
|
|
cargo watch \
|
2024-04-11 17:18:58 +03:00
|
|
|
-x 'test --message-format short' \
|
2024-04-08 13:13:26 +03:00
|
|
|
-x 'clippy --no-deps' \
|
2024-03-29 09:36:19 +03:00
|
|
|
-x 'run --bin engine -- \
|
|
|
|
--otlp-endpoint http://localhost:4317 \
|
|
|
|
--authn-config-path auth_config.json \
|
|
|
|
--metadata-path crates/engine/tests/schema.json'
|
2024-03-13 14:14:07 +03:00
|
|
|
|
|
|
|
# check the code is fine
|
|
|
|
lint-local:
|
2024-04-08 13:13:26 +03:00
|
|
|
cargo clippy --no-deps
|
2024-03-12 18:26:31 +03:00
|
|
|
|
2024-03-28 12:16:54 +03:00
|
|
|
# ensure we don't have unused dependencies:
|
|
|
|
machete:
|
|
|
|
cargo machete --with-metadata
|
|
|
|
|
2024-03-15 16:05:32 +03:00
|
|
|
# update golden tests
|
2024-03-28 13:26:32 +03:00
|
|
|
update-golden-files-local: start-docker-test-deps
|
2024-03-15 16:05:32 +03:00
|
|
|
REGENERATE_GOLDENFILES=1 cargo test
|
|
|
|
|
2024-03-28 13:26:32 +03:00
|
|
|
# run the engine using schema from tests
|
|
|
|
run-local: start-docker-test-deps start-docker-run-deps
|
|
|
|
RUST_LOG=DEBUG cargo run --bin engine -- \
|
|
|
|
--otlp-endpoint http://localhost:4317 \
|
|
|
|
--authn-config-path auth_config.json \
|
|
|
|
--metadata-path crates/engine/tests/schema.json
|
2024-04-26 11:43:19 +03:00
|
|
|
|
|
|
|
# check the docker build works
|
|
|
|
build-docker-with-nix:
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
echo "$(tput bold)nix build .#engine-docker | gunzip | docker load$(tput sgr0)"
|
|
|
|
gunzip < "$(nix build --no-warn-dirty --no-link --print-out-paths '.#engine-docker')" | docker load
|
|
|
|
|
|
|
|
# check the Postgres arm64 docker build works
|
|
|
|
build-aarch64-docker-with-nix:
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
echo "$(tput bold)nix build .#engine-docker-aarch64-linux | gunzip | docker load$(tput sgr0)"
|
|
|
|
gunzip < "$(nix build --no-warn-dirty --no-link --print-out-paths --system aarch64-linux '.#engine-docker-aarch64-linux')" | docker load
|