Skip to content

Commit

Permalink
Use cargo-nextest instead of regular cargo test (#1279)
Browse files Browse the repository at this point in the history
… if available.

Makes tests execute faster.
  • Loading branch information
svix-jplatte authored Mar 18, 2024
2 parents 39d86bd + 8c7c6d0 commit 460bec2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/bridge-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
# include relevant information in the cache name
prefix-key: "bridge-${{ matrix.rust }}"

- uses: taiki-e/install-action@nextest

- name: rustfmt
run: cargo fmt -- --check
working-directory: bridge
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/rust-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ jobs:
# include relevant information in the cache name
prefix-key: "rust-client-${{ matrix.rust }}"

- uses: taiki-e/install-action@nextest

- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
working-directory: rust

- name: Run tests
run: cargo test --all
run: cargo nextest run
working-directory: rust
2 changes: 2 additions & 0 deletions .github/workflows/server-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
# include relevant information in the cache name
prefix-key: "server-${{ matrix.rust }}"

- uses: taiki-e/install-action@nextest

- name: rustfmt
run: cargo fmt -- --check
working-directory: server
Expand Down
16 changes: 14 additions & 2 deletions bridge/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#!/bin/sh -e
#!/bin/bash

if [[ -z "$TEST_COMMAND" ]]; then
if [[ -z "$CARGO_HOME" ]]; then
CARGO_HOME="$HOME/.cargo"
fi

if command -v cargo-nextest || [[ -e "$CARGO_HOME/bin/cargo-nextest" ]]; then
TEST_COMMAND="cargo nextest run"
else
TEST_COMMAND="cargo test"
fi
fi

AWS_DEFAULT_REGION="elasticmq" \
AWS_ACCESS_KEY_ID="x" \
AWS_SECRET_ACCESS_KEY="x" \
PUBSUB_EMULATOR_HOST=localhost:8085 \
PUBSUB_PROJECT_ID=local-project \
cargo test --all-features -- "$@"
${TEST_COMMAND} --all-features -- "$@"
34 changes: 23 additions & 11 deletions server/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
#!/bin/sh -e
#!/bin/bash

# Run tests with various configurations:
# Run tests with various configurations.

if [[ -z "$TEST_COMMAND" ]]; then
if [[ -z "$CARGO_HOME" ]]; then
CARGO_HOME="$HOME/.cargo"
fi

if command -v cargo-nextest || [[ -e "$CARGO_HOME/bin/cargo-nextest" ]]; then
TEST_COMMAND="cargo nextest run"
else
TEST_COMMAND="cargo test"
fi
fi

# Common variables:
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
Expand All @@ -15,40 +27,40 @@ echo "*********** RUN 1 ***********"
export SVIX_QUEUE_TYPE="redis"
export SVIX_CACHE_TYPE="redis"
export SVIX_REDIS_DSN="redis://localhost:6379"
cargo test
cargo test -- --ignored redis
${TEST_COMMAND}
${TEST_COMMAND} -- --ignored redis
)

echo "*********** RUN 2 ***********"
(
export SVIX_QUEUE_TYPE="redis"
export SVIX_CACHE_TYPE="memory"
export SVIX_REDIS_DSN="redis://localhost:6379"
cargo test
${TEST_COMMAND}
)

echo "*********** RUN 3 ***********"
(
export SVIX_QUEUE_TYPE="redis"
export SVIX_CACHE_TYPE="none"
export SVIX_REDIS_DSN="redis://localhost:6379"
cargo test
${TEST_COMMAND}
)

echo "*********** RUN 4 ***********"
(
export SVIX_QUEUE_TYPE="rediscluster"
export SVIX_CACHE_TYPE="rediscluster"
export SVIX_REDIS_DSN="redis://localhost:6380"
cargo test
cargo test -- --ignored redis
${TEST_COMMAND}
${TEST_COMMAND} -- --ignored redis
)

echo "*********** RUN 5 ***********"
(
export SVIX_QUEUE_TYPE="memory"
export SVIX_CACHE_TYPE="none"
cargo test
${TEST_COMMAND}
)

echo "*********** RUN 6 ***********"
Expand All @@ -57,6 +69,6 @@ echo "*********** RUN 6 ***********"
export SVIX_CACHE_TYPE="redis"
export SVIX_REDIS_DSN="redis://localhost:6379"
export SVIX_RABBIT_DSN="amqp://xivs:xivs@localhost:5672/%2f"
cargo test
cargo test -- --ignored rabbitmq
${TEST_COMMAND}
${TEST_COMMAND} -- --ignored rabbitmq
)

0 comments on commit 460bec2

Please sign in to comment.