2024-08-29 15:07:49 +03:00
set positional-arguments : = true
2024-08-14 17:45:50 +03:00
set shell : = ["bash ", "-c "]
2023-12-19 12:04:02 +03:00
default :
2024-08-29 15:07:49 +03:00
just --list
2023-12-19 12:04:02 +03:00
2024-07-25 19:15:52 +03:00
build :
2024-08-29 15:07:49 +03:00
cargo build --release --all-targets
2023-12-19 12:04:02 +03:00
2024-08-19 17:01:16 +03:00
audit :
2024-08-29 15:07:49 +03:00
cargo audit
2024-08-19 17:01:16 +03:00
audit-fix :
2024-08-29 15:07:49 +03:00
cargo audit fix
2024-08-19 17:01:16 +03:00
2024-04-02 18:08:38 +03:00
format :
2024-08-29 15:07:49 +03:00
cargo fmt --check
npx --yes prettier --check .
! command -v nix || nix fmt -- --check .
2024-04-02 18:08:38 +03:00
alias fmt : = format
2024-07-25 19:15:52 +03:00
fix :
2024-08-29 15:07:49 +03:00
cargo clippy --all-targets --no-deps --fix --allow-no-vcs
cargo fmt
just fix-format
! command -v nix || nix fmt
2024-05-02 11:43:16 +03:00
fix-format :
2024-08-29 15:07:49 +03:00
npx --yes prettier --write .
2023-12-19 12:04:02 +03:00
2024-07-23 14:43:29 +03:00
run-local-with-shell :
2024-08-29 15:07:49 +03:00
#!/usr/bin/env bash
cargo run --bin custom-connector | ts "custom-connector:" &
OTLP_ENDPOINT = http://localhost:4317 \
cargo run --bin dev-auth-webhook | ts "dev-auth-webhook:" &
RUST_LOG = DEBUG cargo run --bin engine -- \
--otlp-endpoint http://localhost:4317 \
--authn-config-path static/auth/auth_config.json \
--metadata-path static/sample-schema.json \
--expose-internal-errors | ts "engine: " &
wait
2024-07-23 14:43:29 +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-08-29 15:07:49 +03:00
# start connectors and wait for health
docker compose -f ci.docker-compose.yaml up --wait postgres postgres_connector custom_connector custom_connector_ndc_v01
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 :
2024-08-29 15:07:49 +03:00
# start auth_hook and jaeger
docker compose up --wait auth_hook jaeger
2024-03-28 13:26:32 +03:00
2024-04-03 14:50:56 +03:00
# pull / build all docker deps
docker-refresh :
2024-08-29 15:07:49 +03:00
docker compose -f ci.docker-compose.yaml pull postgres_connector
docker compose -f ci.docker-compose.yaml build custom_connector
2024-04-03 14:50:56 +03:00
2024-03-12 18:26:31 +03:00
# stop all the docker deps
stop-docker :
2024-08-29 15:07:49 +03:00
docker compose -f ci.docker-compose.yaml down -v
docker compose down -v
2024-03-12 18:26:31 +03:00
# run the tests using local engine (once)
2024-07-25 19:15:52 +03:00
test *ARGS : start -docker -test -deps
2024-08-29 15:07:49 +03:00
#!/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-07-25 19:15:52 +03:00
watch : start -docker -test -deps start -docker -run -deps
2024-08-29 15:07:49 +03:00
RUST_LOG = DEBUG \
cargo watch -i "**/*.snap.new" \
-x test \
-x 'clippy --no-deps' \
-x ' run --bin engine -- \
--otlp-endpoint http://localhost:4317 \
--authn-config-path static/auth/auth_config.json \
--metadata-path static/sample-schema.json \
--expose-internal-errors'
2024-03-13 14:14:07 +03:00
# check the code is fine
2024-07-25 19:15:52 +03:00
lint :
2024-08-29 15:07:49 +03:00
cargo clippy --all-targets --no-deps
! 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 :
2024-08-29 15:07:49 +03:00
cargo machete --with-metadata
2024-03-28 12:16:54 +03:00
2024-03-15 16:05:32 +03:00
# update golden tests
2024-07-25 19:15:52 +03:00
update-golden-files : start -docker -test -deps
2024-08-29 15:07:49 +03:00
UPDATE_GOLDENFILES = 1 cargo test
just fix-format
2024-03-15 16:05:32 +03:00
2024-07-11 17:15:12 +03:00
update-custom-connector-schema-in-test-metadata : && fix -format
2024-08-29 15:07:49 +03:00
docker compose -f ci.docker-compose.yaml up --build --wait custom_connector
just update-schema-in-test-metadata "8102" "v0.2"
2024-07-11 17:15:12 +03:00
2024-08-29 15:07:49 +03:00
update-postgres-schema-in-test-metadata : && fix -format
docker compose -f ci.docker-compose.yaml up --build --wait postgres postgres_connector
just update-schema-in-test-metadata "8080" "v0.1"
update-schema-in-test-metadata PORT NDC_VERSION : && fix -format
#!/usr/bin/env bash
set -e
new_capabilities = $( curl http://localhost:{ { PORT } } /capabilities | jq)
new_schema = $( curl http://localhost:{ { PORT } } /schema | jq)
ndc_version = "{{ NDC_VERSION }}"
# Should only be tests that actually talk to the running connector and therefore must be up to date
test_directories = ( ./crates/engine/tests/execute)
find " ${ test_directories [@] } " -name '*.json' -print0 |
while IFS = read -r -d '' file; do
# Check if the file actually contains a custom connector DataConnectorLink
if jq -e '
( . | type = = "object" ) and has( "subgraphs" ) and ( .subgraphs | length > 0) and ( .subgraphs[ ] | has( "objects" ) and ( .objects | length > 0) )
and any( .subgraphs[ ] .objects[ ] ; .kind = = "DataConnectorLink" and .definition.url.singleUrl.value = = "http://localhost:{{ PORT }}" ) ' " $file " >/dev/null; then
# Update its schema, capabilities and version
jq --argjson newCapabilities " $new_capabilities " --argjson newSchema " $new_schema " --arg ndcVersion " $ndc_version " '
( .subgraphs[ ] .objects[ ] | select ( .kind = = "DataConnectorLink" and .definition.url.singleUrl.value = = "http://localhost:{{ PORT }}" ) .definition.schema)
| = ( .capabilities = $newCapabilities | .schema = $newSchema | .version = $ndcVersion )
' $file \
| sponge $file
echo " Updated $file "
else
echo " Skipping $file : Does not appear to be a metadata file with a matching connector "
fi
done
docker compose -f ci.docker-compose.yaml down
2024-07-11 17:15:12 +03:00
2024-03-28 13:26:32 +03:00
# run the engine using schema from tests
2024-07-25 19:15:52 +03:00
run : start -docker -test -deps start -docker -run -deps
2024-08-29 15:07:49 +03:00
RUST_LOG = DEBUG cargo run --bin engine -- \
--otlp-endpoint http://localhost:4317 \
--authn-config-path static/auth/auth_config.json \
--metadata-path static/sample-schema.json \
--expose-internal-errors