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`.
|
2024-05-01 12:04:24 +03:00
|
|
|
PACKAGE_SELECTOR := `find crates -name "Cargo.toml" -type f | xargs dirname | xargs -n 1 basename | 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-05-28 11:50:46 +03:00
|
|
|
"RUSTFLAGS='-D warnings' cargo clippy --all-targets --no-deps"
|
2023-12-19 12:04:02 +03:00
|
|
|
|
|
|
|
fix:
|
2024-05-28 11:50:46 +03:00
|
|
|
just docker_with_source_only sh -c "cargo clippy --all-targets --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-06-04 17:14:54 +03:00
|
|
|
! command -v nix || nix fmt -- --check .
|
2024-04-02 18:08:38 +03:00
|
|
|
alias fmt := format
|
|
|
|
|
2023-12-19 12:04:02 +03:00
|
|
|
fix-local:
|
2024-05-28 11:50:46 +03:00
|
|
|
cargo clippy --all-targets --no-deps --fix --allow-no-vcs
|
2024-04-08 13:13:26 +03:00
|
|
|
cargo fmt
|
2024-05-02 11:43:16 +03:00
|
|
|
just fix-format
|
2024-06-04 17:14:54 +03:00
|
|
|
! command -v nix || nix fmt
|
2024-05-02 11:43:16 +03:00
|
|
|
|
|
|
|
fix-format:
|
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
|
|
|
|
2024-05-31 17:10:36 +03:00
|
|
|
test *ARGS:
|
2024-04-03 11:03:18 +03:00
|
|
|
#!/usr/bin/env bash
|
2024-05-31 17:10:36 +03:00
|
|
|
COMMAND=(cargo nextest run --archive-file=./bin/nextest.tar.zst --no-fail-fast "$@")
|
|
|
|
echo "cargo nextest run --no-fail-fast $*"
|
2024-04-22 16:42:32 +03:00
|
|
|
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-06-17 22:15:16 +03:00
|
|
|
docker compose -f ci.docker-compose.yaml run --rm -e UPDATE_GOLDENFILES=1 test_setup \
|
2024-04-22 16:42:32 +03:00
|
|
|
cargo nextest run --archive-file=./bin/nextest.tar.zst --no-fail-fast
|
2024-05-02 11:43:16 +03:00
|
|
|
just fix-format
|
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 \
|
2024-05-17 17:41:32 +03:00
|
|
|
-p engine --bench generate_ir \
|
|
|
|
-p execute --bench generate_ir
|
2023-12-19 12:04:02 +03:00
|
|
|
|
|
|
|
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-05-31 17:10:36 +03:00
|
|
|
test-local *ARGS: start-docker-test-deps
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
if command -v cargo-nextest; then
|
|
|
|
COMMAND=(cargo nextest run)
|
|
|
|
else
|
|
|
|
COMMAND=(cargo test)
|
|
|
|
fi
|
|
|
|
COMMAND+=(--no-fail-fast "$@")
|
|
|
|
echo "${COMMAND[*]}"
|
|
|
|
"${COMMAND[@]}"
|
2024-03-12 18:26:31 +03:00
|
|
|
|
|
|
|
# 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-06-27 21:43:43 +03:00
|
|
|
cargo watch -i "**/*.snap.new" \
|
2024-05-07 13:13:38 +03:00
|
|
|
-x test \
|
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 \
|
2024-06-27 15:42:27 +03:00
|
|
|
--metadata-path crates/engine/tests/schema.json \
|
|
|
|
--expose-internal-errors'
|
2024-03-13 14:14:07 +03:00
|
|
|
|
|
|
|
# check the code is fine
|
|
|
|
lint-local:
|
2024-05-28 11:50:46 +03:00
|
|
|
cargo clippy --all-targets --no-deps
|
2024-06-04 17:14:54 +03:00
|
|
|
! command -v nix || nix flake check
|
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-06-17 22:15:16 +03:00
|
|
|
UPDATE_GOLDENFILES=1 cargo test
|
2024-05-02 11:43:16 +03:00
|
|
|
just fix-format
|
2024-03-15 16:05:32 +03:00
|
|
|
|
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 \
|
2024-06-27 15:42:27 +03:00
|
|
|
--metadata-path crates/engine/tests/schema.json \
|
|
|
|
--expose-internal-errors
|
2024-04-26 11:43:19 +03:00
|
|
|
|
|
|
|
# check the docker build works
|
2024-05-02 17:22:44 +03:00
|
|
|
build-docker-with-nix binary="engine":
|
2024-04-26 11:43:19 +03:00
|
|
|
#!/usr/bin/env bash
|
2024-05-02 17:22:44 +03:00
|
|
|
echo "$(tput bold)nix build .#{{ binary }}-docker | gunzip | docker load$(tput sgr0)"
|
|
|
|
gunzip < "$(nix build --no-warn-dirty --no-link --print-out-paths '.#{{ binary }}-docker')" | docker load
|
2024-04-26 11:43:19 +03:00
|
|
|
|
2024-05-02 17:22:44 +03:00
|
|
|
# check the arm64 docker build works
|
|
|
|
build-aarch64-docker-with-nix binary="engine":
|
2024-04-26 11:43:19 +03:00
|
|
|
#!/usr/bin/env bash
|
2024-05-02 17:22:44 +03:00
|
|
|
echo "$(tput bold)nix build .#{{ binary }}-docker-aarch64-linux | gunzip | docker load$(tput sgr0)"
|
|
|
|
gunzip < "$(nix build --no-warn-dirty --no-link --print-out-paths --system aarch64-linux '.#{{ binary }}-docker-aarch64-linux')" | docker load
|