mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
38c0e1470b
### What Try not to pollute the CI cache with the wrong thing. ### How 1. Remove the package selector as we don't care about production builds here any more. 2. Tell the test build to not save the cache so there is no write contention. 3. Downgrade `mockito` to v1.4 reduce the size of the cache, because `v1.5` depends on `http` v1. V3_GIT_ORIGIN_REV_ID: 2109c8c7db5d80e3b2c29d2949423e8faebd10b2
147 lines
5.0 KiB
Makefile
147 lines
5.0 KiB
Makefile
set positional-arguments
|
|
|
|
default:
|
|
just --list
|
|
|
|
build:
|
|
cargo build --release --all-targets
|
|
|
|
format:
|
|
cargo fmt --check
|
|
prettier --check .
|
|
! command -v nix || nix fmt -- --check .
|
|
alias fmt := format
|
|
|
|
fix:
|
|
cargo clippy --all-targets --no-deps --fix --allow-no-vcs
|
|
cargo fmt
|
|
just fix-format
|
|
! command -v nix || nix fmt
|
|
|
|
fix-format:
|
|
prettier --write .
|
|
|
|
run-local-with-shell:
|
|
#!/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 crates/engine/tests/schema.json \
|
|
--expose-internal-errors | ts "engine: " &
|
|
wait
|
|
|
|
# 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 custom_connector_ndc_v01
|
|
|
|
# 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
|
|
|
|
# run the tests using local engine (once)
|
|
test *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[@]}"
|
|
|
|
# run a watch process that runs the tests locally
|
|
watch: start-docker-test-deps start-docker-run-deps
|
|
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 crates/engine/tests/schema.json \
|
|
--expose-internal-errors'
|
|
|
|
# check the code is fine
|
|
lint:
|
|
cargo clippy --all-targets --no-deps
|
|
! command -v nix || nix flake check
|
|
|
|
# ensure we don't have unused dependencies:
|
|
machete:
|
|
cargo machete --with-metadata
|
|
|
|
# update golden tests
|
|
update-golden-files: start-docker-test-deps
|
|
UPDATE_GOLDENFILES=1 cargo test
|
|
just fix-format
|
|
|
|
update-custom-connector-schema-in-test-metadata: && fix-format
|
|
#!/usr/bin/env bash
|
|
set -e
|
|
docker compose -f ci.docker-compose.yaml up --build --wait custom_connector
|
|
|
|
new_capabilities=$(curl http://localhost:8102/capabilities | jq)
|
|
new_schema=$(curl http://localhost:8102/schema | jq)
|
|
ndc_version="v0.2"
|
|
|
|
# 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:8102")' "$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:8102").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 custom connector"
|
|
fi
|
|
done
|
|
|
|
docker compose -f ci.docker-compose.yaml down
|
|
|
|
# run the engine using schema from tests
|
|
run: start-docker-test-deps start-docker-run-deps
|
|
RUST_LOG=DEBUG cargo run --bin engine -- \
|
|
--otlp-endpoint http://localhost:4317 \
|
|
--authn-config-path static/auth/auth_config.json \
|
|
--metadata-path crates/engine/tests/schema.json \
|
|
--expose-internal-errors
|
|
|
|
# check the docker build works
|
|
build-docker-with-nix binary="engine":
|
|
#!/usr/bin/env bash
|
|
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
|
|
|
|
# check the arm64 docker build works
|
|
build-aarch64-docker-with-nix binary="engine":
|
|
#!/usr/bin/env bash
|
|
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
|