diff --git a/.github/workflows/continous-integration-docker.yml b/.github/workflows/continous-integration-docker.yml index cf984ce7b..8df82c41f 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 11a77b23c..861aaf635 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 2d7ddd3a3..842f20c7e 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 ee052a996..d86115ea5 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