fix(ci): make test selection and logging consistent (#4375)

* fix(ci): sentry is not longer being activated in test builds

This removes sentry from all the test execution, as some tests might fail as sentry wasn't initially built, or it might take more time to build as it will have to build with sentry.

* fix(build): workaround the failed to fetch oauth token error

* Drop sentry dependencies when enable-sentry feature is disabled

* Make lightwalletd gRPC tests depend on a new lightwalletd-grpc-tests feature

* fix(ci): remove enable-sentry feature from tests

* Add lightwalletd-grpc-tests feature for functionality or efficiency

And document where it is just used to stop re-compilations.

* Remove redundant `cmake` and `protobuf-compiler` dependencies

* Document Zebra's optional production and test feature flags

* Minimise dependencies in zcash-params/Dockerfile

* Minimise dependencies in docker/Dockerfile

* Add a workflow TODO

* Catch more errors in entrypoint.sh

Also makes entrypoint.sh compatible with more distributions

* Remove unnecessary quoting in entrypoint.sh

* Use exactly the same arguments to call CI tests

* Remove a redundant CI build

* Rename Cargo.lock check job

Co-authored-by: Gustavo Valverde <gustavo@iterativo.do>
This commit is contained in:
teor 2022-05-12 09:41:33 +10:00 committed by GitHub
parent 12e8130941
commit f789f8aaa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 31 deletions

View File

@ -117,7 +117,7 @@ jobs:
- name: Run all zebrad tests - name: Run all zebrad tests
run: | run: |
docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }}
docker run --name zebrad-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} cargo test --locked --release --features lightwalletd-grpc-tests --workspace -- --include-ignored docker run --name zebrad-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} cargo test --locked --release --features lightwalletd-grpc-tests --workspace -- --nocapture --include-ignored
# Run state tests with fake activation heights. # Run state tests with fake activation heights.
# #
@ -142,7 +142,7 @@ jobs:
- name: Run tests with fake activation heights - name: Run tests with fake activation heights
run: | run: |
docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }}
docker run -e TEST_FAKE_ACTIVATION_HEIGHTS --name zebrad-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} cargo test --locked --release --package zebra-state --lib -- with_fake_activation_heights docker run -e TEST_FAKE_ACTIVATION_HEIGHTS --name zebrad-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} cargo test --locked --release --package zebra-state --lib -- --nocapture --include-ignored with_fake_activation_heights
env: env:
TEST_FAKE_ACTIVATION_HEIGHTS: '1' TEST_FAKE_ACTIVATION_HEIGHTS: '1'
@ -163,7 +163,7 @@ jobs:
- name: Run zebrad large sync tests - name: Run zebrad large sync tests
run: | run: |
docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }}
docker run --name zebrad-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} cargo test --locked --release --features lightwalletd-grpc-tests --test acceptance sync_large_checkpoints_ -- --ignored docker run --name zebrad-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored sync_large_checkpoints_
# Test launching lightwalletd with an empty lightwalletd and Zebra state. # Test launching lightwalletd with an empty lightwalletd and Zebra state.
# #
@ -182,7 +182,7 @@ jobs:
- name: Run tests with empty lightwalletd launch - name: Run tests with empty lightwalletd launch
run: | run: |
docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} docker pull ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }}
docker run -e ZEBRA_TEST_LIGHTWALLETD --name lightwalletd-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} cargo test --locked --release --features lightwalletd-grpc-tests --test acceptance -- lightwalletd_integration --nocapture docker run -e ZEBRA_TEST_LIGHTWALLETD --name lightwalletd-tests -t ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored lightwalletd_integration
env: env:
ZEBRA_TEST_LIGHTWALLETD: '1' ZEBRA_TEST_LIGHTWALLETD: '1'

View File

@ -133,7 +133,7 @@ jobs:
uses: actions-rs/cargo@v1.0.3 uses: actions-rs/cargo@v1.0.3
with: with:
command: test command: test
args: --verbose --all args: --verbose --workspace -- --nocapture
# Explicitly run any tests that are usually #[ignored] # Explicitly run any tests that are usually #[ignored]
@ -144,7 +144,7 @@ jobs:
with: with:
command: test command: test
# Note: this only runs the zebrad acceptance tests, because re-running all the test binaries is slow on Windows # Note: this only runs the zebrad acceptance tests, because re-running all the test binaries is slow on Windows
args: --verbose --package zebrad --test acceptance sync_large_checkpoints_ -- --ignored args: --verbose --package zebrad --test acceptance -- --nocapture --include-ignored sync_large_checkpoints_
test-fake-activation-heights: test-fake-activation-heights:
name: Test ${{ matrix.rust }} zebra-state with fake activation heights on ubuntu-latest name: Test ${{ matrix.rust }} zebra-state with fake activation heights on ubuntu-latest
@ -185,7 +185,7 @@ jobs:
command: test command: test
# Note: this only runs the zebra-state crate tests, # Note: this only runs the zebra-state crate tests,
# because re-running all the test binaries can be slow # because re-running all the test binaries can be slow
args: --verbose --package zebra-state --lib -- with_fake_activation_heights args: --verbose --package zebra-state --lib -- --nocapture --include-ignored with_fake_activation_heights
build-chain-no-features: build-chain-no-features:
name: Build ${{ matrix.rust }} zebra-chain w/o features on ubuntu-latest name: Build ${{ matrix.rust }} zebra-chain w/o features on ubuntu-latest
@ -217,6 +217,7 @@ jobs:
working-directory: ./zebra-chain working-directory: ./zebra-chain
run: cargo build --verbose --no-default-features run: cargo build --verbose --no-default-features
# Install Zebra with lockfile dependencies, with no caching and default features
install-from-lockfile-no-cache: install-from-lockfile-no-cache:
name: Install zebrad from lockfile without cache on ubuntu-latest name: Install zebrad from lockfile without cache on ubuntu-latest
timeout-minutes: 60 timeout-minutes: 60
@ -239,8 +240,10 @@ jobs:
command: install command: install
args: --locked --path ./zebrad/ zebrad args: --locked --path ./zebrad/ zebrad
build: # Check that Cargo.lock includes any Cargo.toml changes.
name: Build stable on ubuntu-latest # This check makes sure the `cargo-deny` crate dependency checks are accurate.
check-cargo-lock:
name: Check Cargo.lock is up to date
timeout-minutes: 60 timeout-minutes: 60
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -257,24 +260,12 @@ jobs:
- uses: Swatinem/rust-cache@v1 - uses: Swatinem/rust-cache@v1
# This check makes sure the crate dependency check is accurate
- name: Check Cargo.lock is up to date - name: Check Cargo.lock is up to date
uses: actions-rs/cargo@v1.0.3 uses: actions-rs/cargo@v1.0.3
with: with:
command: check command: check
args: --locked --all-features --all-targets args: --locked --all-features --all-targets
- name: cargo fetch
uses: actions-rs/cargo@v1.0.3
with:
command: fetch
- name: Build
uses: actions-rs/cargo@v1.0.3
with:
command: build
args: --verbose --release
cargo-deny: cargo-deny:
name: Check deny.toml ${{ matrix.checks }} name: Check deny.toml ${{ matrix.checks }}
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -108,6 +108,7 @@ RUN cargo test --locked --release --features lightwalletd-grpc-tests --workspace
COPY ./docker/entrypoint.sh / COPY ./docker/entrypoint.sh /
RUN chmod u+x /entrypoint.sh RUN chmod u+x /entrypoint.sh
# By default, runs the entrypoint tests specified by the environmental variables (if any are set)
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD [ "cargo"] CMD [ "cargo"]

View File

@ -1,6 +1,11 @@
#!/bin/bash #!/usr/bin/env bash
# show the commands we are executing
set -x set -x
# exit if a command fails
set -e
# exit if any command in a pipeline fails
set -o pipefail
case "$1" in case "$1" in
-- | cargo) -- | cargo)
@ -9,30 +14,34 @@ case "$1" in
if [[ "$RUN_ALL_TESTS" -eq "1" ]]; then if [[ "$RUN_ALL_TESTS" -eq "1" ]]; then
# Run all the available tests for the current environment. # Run all the available tests for the current environment.
# If the lightwalletd environmental variables are set, we will also run those tests. # If the lightwalletd environmental variables are set, we will also run those tests.
exec cargo "test" "--locked" "--release" "--features" "lightwalletd-grpc-tests" "--workspace" "--" "--include-ignored" exec cargo test --locked --release --features lightwalletd-grpc-tests --workspace -- --nocapture --include-ignored
# For these tests, we activate the gRPC feature to avoid recompiling `zebrad`, # For these tests, we activate the gRPC feature to avoid recompiling `zebrad`,
# but we don't actually run any gRPC tests. # but we don't actually run any gRPC tests.
elif [[ "$TEST_FULL_SYNC" -eq "1" ]]; then elif [[ "$TEST_FULL_SYNC" -eq "1" ]]; then
# Run a Zebra full sync test. # Run a Zebra full sync test.
exec cargo "test" "--locked" "--release" "--features" "lightwalletd-grpc-tests" "--test" "acceptance" "--" "--nocapture" "--ignored" "full_sync_mainnet" exec cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored full_sync_mainnet
elif [[ "$TEST_DISK_REBUILD" -eq "1" ]]; then elif [[ "$TEST_DISK_REBUILD" -eq "1" ]]; then
# Run a Zebra sync up to the mandatory checkpoint. # Run a Zebra sync up to the mandatory checkpoint.
exec cargo "test" "--locked" "--release" "--features" "test_sync_to_mandatory_checkpoint_${NETWORK,,},lightwalletd-grpc-tests" "--manifest-path" "zebrad/Cargo.toml" "sync_to_mandatory_checkpoint_${NETWORK,,}" #
# TODO: use environmental variables instead of Rust features (part of #2995)
exec cargo test --locked --release --features "test_sync_to_mandatory_checkpoint_${NETWORK,,},lightwalletd-grpc-tests" --package zebrad --test acceptance -- --nocapture --include-ignored "sync_to_mandatory_checkpoint_${NETWORK,,}"
elif [[ "$TEST_CHECKPOINT_SYNC" -eq "1" ]]; then elif [[ "$TEST_CHECKPOINT_SYNC" -eq "1" ]]; then
# Run a Zebra sync starting at the cached mandatory checkpoint, and syncing past it. # Run a Zebra sync starting at the cached mandatory checkpoint, and syncing past it.
exec cargo "test" "--locked" "--release" "--features" "test_sync_past_mandatory_checkpoint_${NETWORK,,},lightwalletd-grpc-tests" "--manifest-path" "zebrad/Cargo.toml" "sync_past_mandatory_checkpoint_${NETWORK,,}" #
# TODO: use environmental variables instead of Rust features (part of #2995)
exec cargo test --locked --release --features "test_sync_past_mandatory_checkpoint_${NETWORK,,},lightwalletd-grpc-tests" --package zebrad --test acceptance -- --nocapture --include-ignored "sync_past_mandatory_checkpoint_${NETWORK,,}"
elif [[ "$TEST_LWD_RPC_CALL" -eq "1" ]]; then elif [[ "$TEST_LWD_RPC_CALL" -eq "1" ]]; then
# Starting at a cached tip, test a JSON-RPC call to Zebra. # Starting at a cached tip, test a JSON-RPC call to Zebra.
exec cargo "test" "--locked" "--release" "--features" "lightwalletd-grpc-tests" "--test" "acceptance" "--" "--nocapture" "--ignored" "fully_synced_rpc_test" exec cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored fully_synced_rpc_test
elif [[ "$TEST_LWD_FULL_SYNC" -eq "1" ]]; then elif [[ "$TEST_LWD_FULL_SYNC" -eq "1" ]]; then
# Starting at a cached Zebra tip, run a lightwalletd sync to tip. # Starting at a cached Zebra tip, run a lightwalletd sync to tip.
exec cargo "test" "--locked" "--release" "--features" "lightwalletd-grpc-tests" "--test" "acceptance" "--" "--nocapture" "--ignored" "lightwalletd_full_sync" exec cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored lightwalletd_full_sync
# These tests actually use gRPC. # These tests actually use gRPC.
elif [[ "$TEST_LWD_TRANSACTIONS" -eq "1" ]]; then elif [[ "$TEST_LWD_TRANSACTIONS" -eq "1" ]]; then
# Starting at a cached tip, test a gRPC call to lightwalletd, which calls Zebra. # Starting at a cached tip, test a gRPC call to lightwalletd, which calls Zebra.
exec cargo "test" "--locked" "--release" "--features" "lightwalletd-grpc-tests" "--test" "acceptance" "--" "--nocapture" "--ignored" "sending_transactions_using_lightwalletd" exec cargo test --locked --release --features lightwalletd-grpc-tests --package zebrad --test acceptance -- --nocapture --include-ignored sending_transactions_using_lightwalletd
# These command-lines are provided by the caller. # These command-lines are provided by the caller.
else else