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 e868675..77e94cd 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 b43847c..c3ae225 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) @@ -41,9 +43,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() { @@ -142,6 +142,14 @@ move_keys() { } docker_ink_dev() { + # if [[ -z "${CI}" ]]; then + local_docker_cargo "$@" + # else + # ci_docker_cargo "$@" + # fi +} + +local_docker_cargo() { docker run --rm \ -u "${DOCKER_USER}" \ -v "${PWD}":/code \ @@ -153,6 +161,15 @@ docker_ink_dev() { -c "${1}" } +ci_docker_cargo() { + docker run --rm \ + -v "${PWD}":/code \ + --network host \ + --entrypoint /bin/sh \ + "${INK_DEV_IMAGE}" \ + -c "cargo ${1}" +} + build() { cd "${SCRIPT_DIR}"/.. @@ -193,6 +210,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. @@ -204,13 +222,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.