From ac3706b4127048a712fc618e0d6958d73aa64e64 Mon Sep 17 00:00:00 2001 From: deuszx Date: Wed, 22 Mar 2023 15:27:06 +0100 Subject: [PATCH 1/7] Run E2E shielder tests in the CI. --- .github/workflows/integration_tests.yml | 28 +++++++++++++++++++++++++ shielder/cli/tests/setup_local.sh | 4 +--- shielder/deploy/deploy.sh | 27 ++++++++++++++++++++---- 3 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/integration_tests.yml diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml new file mode 100644 index 0000000..4cd3963 --- /dev/null +++ b/.github/workflows/integration_tests.yml @@ -0,0 +1,28 @@ +name: E2E Shielder tests. + +on: + pull_request: + push: + branches: + - main + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + rust-checks: + runs-on: self-hosted + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + + - name: Install WASM target + run: rustup target add wasm32-unknown-unknown + + - name: Run e2e tests for shielder + run: | + cd shielder && make test-shielder-clean diff --git a/shielder/cli/tests/setup_local.sh b/shielder/cli/tests/setup_local.sh index 9a96be6..d669780 100755 --- a/shielder/cli/tests/setup_local.sh +++ b/shielder/cli/tests/setup_local.sh @@ -10,9 +10,7 @@ get_timestamp() { } log_progress() { - bold=$(tput bold) - normal=$(tput sgr0) - echo "[$(get_timestamp)] [INFO] ${bold}${1}${normal}" + echo "[$(get_timestamp)] [INFO] ${1}" } function setup_testdir() { diff --git a/shielder/deploy/deploy.sh b/shielder/deploy/deploy.sh index a40a6e1..eae72b8 100755 --- a/shielder/deploy/deploy.sh +++ b/shielder/deploy/deploy.sh @@ -4,6 +4,8 @@ set -euo pipefail # Check if run in e2e shielder test context. Defaults to unset. E2E_TEST_CONTEXT=${E2E_TEST:-} +# Check if running in CI context. +CI=${CI:-} SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) @@ -43,9 +45,7 @@ get_timestamp() { } log_progress() { - bold=$(tput bold) - normal=$(tput sgr0) - echo "[$(get_timestamp)] [INFO] ${bold}${1}${normal}" + echo "[$(get_timestamp)] [INFO] ${1}" } random_salt() { @@ -134,6 +134,14 @@ move_keys() { } docker_cargo() { + if [[ -z "${CI}" ]]; then + local_docker_cargo "$@" + else + ci_docker_cargo "$@" + fi +} + +local_docker_cargo() { docker run --rm \ -u "${DOCKER_USER}" \ -v "${PWD}":/code \ @@ -145,6 +153,15 @@ docker_cargo() { -c "cargo ${1}" } +ci_docker_cargo() { + docker run --rm \ + -v "${PWD}":/code \ + --network host \ + --entrypoint /bin/sh \ + "${CARGO_IMAGE}" \ + -c "cargo ${1}" +} + build() { cd "${SCRIPT_DIR}"/.. @@ -185,6 +202,7 @@ prefund_users() { for recipient in "${DAMIAN_PUBKEY}" "${HANS_PUBKEY}"; do transfer ${recipient} done + log_progress "✅ Test accounts prefunded with SNZERO tokens." } # Distribute TOKEN_PER_PERSON of TOKEN_A and TOKEN_B to DAMIAN and HANS. @@ -196,13 +214,14 @@ distribute_tokens() { contract_call "--contract ${token} --message PSP22::transfer --args ${recipient} ${TOKEN_PER_PERSON} 0x00 --suri ${ADMIN}" 1>/dev/null done done + log_progress "✅ PSP22 tokens distributed" } deploy_shielder_contract() { cd "${SCRIPT_DIR}"/.. SHIELDER_ADDRESS=$(contract_instantiate "--args ${MERKLE_LEAVES} --manifest-path contract/Cargo.toml" | jq -r '.contract') export SHIELDER_ADDRESS - log_progress "Shielder address: ${SHIELDER_ADDRESS}" + log_progress "✅ Shielder address: ${SHIELDER_ADDRESS}" } # Set allowance at TOKEN_ALLOWANCE on TOKEN_A and TOKEN_B from SHIELDER, from DAMIAN and HANS. From a50292017dd866aec3cc7d87b00a93b223ae8bcc Mon Sep 17 00:00:00 2001 From: deuszx Date: Mon, 27 Mar 2023 12:27:59 +0200 Subject: [PATCH 2/7] Run E2E tests on push to main only. --- .github/workflows/integration_tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 4cd3963..c3f1fd7 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -1,7 +1,6 @@ name: E2E Shielder tests. on: - pull_request: push: branches: - main From ed043ce0dcb6b3e2c4d21c199a7f0974ee8524ba Mon Sep 17 00:00:00 2001 From: deuszx Date: Mon, 27 Mar 2023 17:29:27 +0200 Subject: [PATCH 3/7] Remove installation of wasm32 target --- .github/workflows/integration_tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index c3f1fd7..feef161 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -19,9 +19,6 @@ jobs: - name: Install Rust toolchain uses: actions-rs/toolchain@v1 - - name: Install WASM target - run: rustup target add wasm32-unknown-unknown - - name: Run e2e tests for shielder run: | cd shielder && make test-shielder-clean From 530fe35a6836c5aab60bc72875a21af50c06972a Mon Sep 17 00:00:00 2001 From: deuszx Date: Mon, 27 Mar 2023 17:32:14 +0200 Subject: [PATCH 4/7] Revert "Remove installation of wasm32 target" This reverts commit ed043ce0dcb6b3e2c4d21c199a7f0974ee8524ba. --- .github/workflows/integration_tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index feef161..c3f1fd7 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -19,6 +19,9 @@ jobs: - name: Install Rust toolchain uses: actions-rs/toolchain@v1 + - name: Install WASM target + run: rustup target add wasm32-unknown-unknown + - name: Run e2e tests for shielder run: | cd shielder && make test-shielder-clean From a0cb15eac246ab0e5489cd74fc0beb1358a55b43 Mon Sep 17 00:00:00 2001 From: deuszx Date: Tue, 18 Apr 2023 17:08:42 +0200 Subject: [PATCH 5/7] Temporarily disable special CI handling --- shielder/deploy/deploy.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shielder/deploy/deploy.sh b/shielder/deploy/deploy.sh index eae72b8..8acf732 100755 --- a/shielder/deploy/deploy.sh +++ b/shielder/deploy/deploy.sh @@ -134,11 +134,11 @@ move_keys() { } docker_cargo() { - if [[ -z "${CI}" ]]; then + # if [[ -z "${CI}" ]]; then local_docker_cargo "$@" - else - ci_docker_cargo "$@" - fi + # else + # ci_docker_cargo "$@" + # fi } local_docker_cargo() { From 0f06693ff32e7823f91b8dcd651063fe1ad40f1c Mon Sep 17 00:00:00 2001 From: deuszx Date: Tue, 18 Apr 2023 17:25:08 +0200 Subject: [PATCH 6/7] Run e2e tests on PR as well - temp --- .github/workflows/integration_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index c3f1fd7..4cd3963 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -1,6 +1,7 @@ name: E2E Shielder tests. on: + pull_request: push: branches: - main From 4db263fe750445c632faab35b2fb76ac01fed195 Mon Sep 17 00:00:00 2001 From: deuszx Date: Tue, 18 Apr 2023 17:29:14 +0200 Subject: [PATCH 7/7] Fix name used in deploy.sh --- shielder/deploy/deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shielder/deploy/deploy.sh b/shielder/deploy/deploy.sh index 4d84338..c3ae225 100755 --- a/shielder/deploy/deploy.sh +++ b/shielder/deploy/deploy.sh @@ -141,7 +141,7 @@ move_keys() { log_progress "✅ Proving keys were made available to CLI" } -docker_cargo() { +docker_ink_dev() { # if [[ -z "${CI}" ]]; then local_docker_cargo "$@" # else