graphql-engine/v3/justfile

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

166 lines
5.3 KiB
Makefile
Raw Normal View History

set positional-arguments
# 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`
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 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 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:
just docker_with_source_only \
cargo build {{ PACKAGE_SELECTOR }} --release --all-targets
build-local:
cargo build {{ PACKAGE_SELECTOR }} --release --all-targets
# linting run by CI
ci-lint:
just docker_with_source_only sh -c \
"RUSTFLAGS='-D warnings' cargo clippy --no-deps"
fix:
just docker_with_source_only sh -c "cargo clippy --no-deps --fix --allow-no-vcs; cargo fmt"
Run `cargo fmt` in CI (#431) <!-- Thank you for submitting this PR! :) --> ## Description When I run `cargo fmt` on my branches, it makes more diff than I want. This PR fixes that by adding `just format` / `just fmt`, and adding it to a CI job. <!-- Questions to consider answering: 1. What user-facing changes are being made? 2. What are issues related to this PR? (Consider adding `(close #<issue-no>)` to the PR title) 3. What is the conceptual design behind this PR? 4. How can this PR be tested/verified? 5. Does the PR have limitations? 6. Does the PR introduce breaking changes? --> ## Changelog - Add a changelog entry (in the "Changelog entry" section below) if the changes in this PR have any user-facing impact. See [changelog guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide). - If no changelog is required ignore/remove this section and add a `no-changelog-required` label to the PR. ### Product _(Select all products this will be available in)_ - [ ] community-edition - [ ] cloud <!-- product : end : DO NOT REMOVE --> ### Type <!-- See changelog structure: https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog --> _(Select only one. In case of multiple, choose the most appropriate)_ - [ ] highlight - [ ] enhancement - [ ] bugfix - [ ] behaviour-change - [ ] performance-enhancement - [ ] security-fix <!-- type : end : DO NOT REMOVE --> ### Changelog entry <!-- - Add a user understandable changelog entry - Include all details needed to understand the change. Try including links to docs or issues if relevant - For Highlights start with a H4 heading (#### <entry title>) - Get the changelog entry reviewed by your team --> _Replace with changelog entry_ <!-- changelog-entry : end : DO NOT REMOVE --> <!-- changelog : end : DO NOT REMOVE --> V3_GIT_ORIGIN_REV_ID: e31e352f27b9ad0129c3759fead051b1a8d86758
2024-04-02 18:08:38 +03:00
format:
cargo fmt --check
prettier --check .
Run `cargo fmt` in CI (#431) <!-- Thank you for submitting this PR! :) --> ## Description When I run `cargo fmt` on my branches, it makes more diff than I want. This PR fixes that by adding `just format` / `just fmt`, and adding it to a CI job. <!-- Questions to consider answering: 1. What user-facing changes are being made? 2. What are issues related to this PR? (Consider adding `(close #<issue-no>)` to the PR title) 3. What is the conceptual design behind this PR? 4. How can this PR be tested/verified? 5. Does the PR have limitations? 6. Does the PR introduce breaking changes? --> ## Changelog - Add a changelog entry (in the "Changelog entry" section below) if the changes in this PR have any user-facing impact. See [changelog guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide). - If no changelog is required ignore/remove this section and add a `no-changelog-required` label to the PR. ### Product _(Select all products this will be available in)_ - [ ] community-edition - [ ] cloud <!-- product : end : DO NOT REMOVE --> ### Type <!-- See changelog structure: https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog --> _(Select only one. In case of multiple, choose the most appropriate)_ - [ ] highlight - [ ] enhancement - [ ] bugfix - [ ] behaviour-change - [ ] performance-enhancement - [ ] security-fix <!-- type : end : DO NOT REMOVE --> ### Changelog entry <!-- - Add a user understandable changelog entry - Include all details needed to understand the change. Try including links to docs or issues if relevant - For Highlights start with a H4 heading (#### <entry title>) - Get the changelog entry reviewed by your team --> _Replace with changelog entry_ <!-- changelog-entry : end : DO NOT REMOVE --> <!-- changelog : end : DO NOT REMOVE --> V3_GIT_ORIGIN_REV_ID: e31e352f27b9ad0129c3759fead051b1a8d86758
2024-04-02 18:08:38 +03:00
alias fmt := format
fix-local:
cargo clippy --no-deps --fix --allow-no-vcs
cargo fmt
prettier --write .
# tests run by CI
ci-test: docker-refresh
just docker_with_test_env cargo nextest run --archive-file=./bin/nextest.tar.zst --no-fail-fast
test TESTNAME='':
#!/usr/bin/env bash
if [[ -z '{{TESTNAME}}' ]]; then
COMMAND=(cargo nextest run --archive-file=./bin/nextest.tar.zst --no-fail-fast)
else
COMMAND=(cargo nextest run --archive-file=./bin/nextest.tar.zst --no-fail-fast -E 'test(={{TESTNAME}})')
fi
echo "${COMMAND[*]}"
just docker_with_test_env "${COMMAND[@]}"
update-golden-files: docker-refresh
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
# 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
# start all the docker deps for running tests (not engine)
start-docker-test-deps:
# start connectors and wait for health
docker compose -f ci.docker-compose.yaml up --wait postgres postgres_connector custom_connector
# 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
# 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
# stop all the docker deps
stop-docker:
docker compose -f ci.docker-compose.yaml down -v
docker compose 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)
test-local: start-docker-test-deps
cargo test
# run a watch process that runs the tests locally
watch-local: start-docker-test-deps start-docker-run-deps
RUST_LOG=DEBUG \
cargo watch \
-x 'test --message-format short' \
-x 'clippy --no-deps' \
-x 'run --bin engine -- \
--otlp-endpoint http://localhost:4317 \
--authn-config-path auth_config.json \
--metadata-path crates/engine/tests/schema.json'
# check the code is fine
lint-local:
cargo clippy --no-deps
# ensure we don't have unused dependencies:
machete:
cargo machete --with-metadata
# update golden tests
update-golden-files-local: start-docker-test-deps
REGENERATE_GOLDENFILES=1 cargo test
# 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
# 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