From f789f8aaa7fc3ba8235e331bcf8fe0ffd4877987 Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 12 May 2022 09:41:33 +1000 Subject: [PATCH] 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 --- .../continous-integration-docker.yml | 10 +++---- .../workflows/continous-integration-os.yml | 27 +++++++------------ docker/Dockerfile | 1 + docker/entrypoint.sh | 25 +++++++++++------ 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/.github/workflows/continous-integration-docker.yml b/.github/workflows/continous-integration-docker.yml index cf984ce7..8df82c41 100644 --- a/.github/workflows/continous-integration-docker.yml +++ b/.github/workflows/continous-integration-docker.yml @@ -117,7 +117,7 @@ jobs: - name: Run all zebrad tests run: | 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. # @@ -142,7 +142,7 @@ jobs: - name: Run tests with fake activation heights run: | 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: TEST_FAKE_ACTIVATION_HEIGHTS: '1' @@ -163,7 +163,7 @@ jobs: - name: Run zebrad large sync tests run: | 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. # @@ -182,7 +182,7 @@ jobs: - name: Run tests with empty lightwalletd launch run: | 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: ZEBRA_TEST_LIGHTWALLETD: '1' @@ -269,4 +269,4 @@ jobs: saves_to_disk: false disk_suffix: tip root_state_path: '/var/cache' - zebra_state_dir: 'zebrad-cache' \ No newline at end of file + zebra_state_dir: 'zebrad-cache' diff --git a/.github/workflows/continous-integration-os.yml b/.github/workflows/continous-integration-os.yml index 11a77b23..861aaf63 100644 --- a/.github/workflows/continous-integration-os.yml +++ b/.github/workflows/continous-integration-os.yml @@ -133,7 +133,7 @@ jobs: uses: actions-rs/cargo@v1.0.3 with: command: test - args: --verbose --all + args: --verbose --workspace -- --nocapture # Explicitly run any tests that are usually #[ignored] @@ -144,7 +144,7 @@ jobs: with: command: test # 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: name: Test ${{ matrix.rust }} zebra-state with fake activation heights on ubuntu-latest @@ -185,7 +185,7 @@ jobs: command: test # Note: this only runs the zebra-state crate tests, # 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: name: Build ${{ matrix.rust }} zebra-chain w/o features on ubuntu-latest @@ -217,6 +217,7 @@ jobs: working-directory: ./zebra-chain run: cargo build --verbose --no-default-features + # Install Zebra with lockfile dependencies, with no caching and default features install-from-lockfile-no-cache: name: Install zebrad from lockfile without cache on ubuntu-latest timeout-minutes: 60 @@ -239,8 +240,10 @@ jobs: command: install args: --locked --path ./zebrad/ zebrad - build: - name: Build stable on ubuntu-latest + # Check that Cargo.lock includes any Cargo.toml changes. + # 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 runs-on: ubuntu-latest @@ -256,25 +259,13 @@ jobs: override: true - uses: Swatinem/rust-cache@v1 - - # This check makes sure the crate dependency check is accurate + - name: Check Cargo.lock is up to date uses: actions-rs/cargo@v1.0.3 with: command: check 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: name: Check deny.toml ${{ matrix.checks }} runs-on: ubuntu-latest diff --git a/docker/Dockerfile b/docker/Dockerfile index 2d7ddd3a..842f20c7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -108,6 +108,7 @@ RUN cargo test --locked --release --features lightwalletd-grpc-tests --workspace COPY ./docker/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"] CMD [ "cargo"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index ee052a99..d86115ea 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,6 +1,11 @@ -#!/bin/bash +#!/usr/bin/env bash +# show the commands we are executing set -x +# exit if a command fails +set -e +# exit if any command in a pipeline fails +set -o pipefail case "$1" in -- | cargo) @@ -9,30 +14,34 @@ case "$1" in if [[ "$RUN_ALL_TESTS" -eq "1" ]]; then # Run all the available tests for the current environment. # 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`, # but we don't actually run any gRPC tests. elif [[ "$TEST_FULL_SYNC" -eq "1" ]]; then # 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 # 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 # 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 # 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 # 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. elif [[ "$TEST_LWD_TRANSACTIONS" -eq "1" ]]; then # 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. else