diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index be5005c..97774ef 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -27,6 +27,8 @@ jobs: if: contains(matrix.os, 'macos-12') == false - name: Install sponge and timeout run: brew install coreutils sponge + - name: Install cargo-dist + run: cargo install cargo-dist - name: Install IC SDK (dfx) run: sh -ci "$(curl -sSL https://internetcomputer.org/install.sh)" - name: run test diff --git a/e2e/utils.sh b/e2e/utils.sh index ab994c9..8a0d4f3 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -1,7 +1,6 @@ set -e -GIT_ROOT_DIR=$(git rev-parse --show-toplevel) - +export CARGO_HOME="$HOME" load "$GIT_ROOT_DIR"/e2e/bats-support/load load "$GIT_ROOT_DIR"/e2e/bats-assert/load @@ -22,6 +21,19 @@ install_shared_asset() { cp -R "$ASSET_ROOT"/* "$(dirname "$E2E_NETWORKS_JSON")" } +dfx_extension_install_manually() ( + cd "$GIT_ROOT_DIR" + local extension_name="$1" + package_version=$(HOME="$CARGO_HOME" cargo metadata --format-version=1 | jq -r '.workspace_members[]' | grep "$extension_name" | cut -d" " -f2) + HOME="$CARGO_HOME" cargo dist build --tag="$extension_name-v$package_version" # cargo-dist needs git tag only metadata-related stuff; it won't do git checkout, it will build from HEAD + extensions_dir="$(dfx cache show)/extensions" + arch_platform="$(get_arch_and_platform)" + rm -rf "$extensions_dir/$extension_name-$arch_platform" "${extensions_dir:?}/$extension_name" # remove old versions + mkdir -p "$extensions_dir" + tar xfJ "target/distrib/$extension_name-$arch_platform.tar.xz" -C "$extensions_dir" + mv "$extensions_dir/$extension_name-$arch_platform" "$extensions_dir/$extension_name" +) + standard_setup() { # We want to work from a temporary directory, different for every test. x=$(mktemp -d -t dfx-e2e-XXXXXXXX) @@ -446,3 +458,21 @@ assert_no_dfx_start_or_replica_processes() { fi } +get_arch_and_platform() { + ARCH=$(uname -m) + SYS=$(uname -s) + + if [[ "$ARCH" == "x86_64" ]]; then + if [[ "$SYS" == "Darwin" ]]; then + echo "$ARCH-apple-darwin" + elif [[ "$SYS" == "Linux" ]]; then + echo "$ARCH-unknown-linux-gnu" + else + echo "System not recognized" + fi + elif [[ "$ARCH" == "arm64" && "$SYS" == "Darwin" ]]; then + echo "aarch64-apple-darwin" + else + echo "Architecture not recognized" + fi +} diff --git a/extensions/nns/e2e/tests/nns.bash b/extensions/nns/e2e/tests/nns.bash index 6515d5d..428b4ce 100755 --- a/extensions/nns/e2e/tests/nns.bash +++ b/extensions/nns/e2e/tests/nns.bash @@ -1,7 +1,6 @@ #!/usr/bin/env bats -GIT_ROOT_DIR=$(git rev-parse --show-toplevel) - +export GIT_ROOT_DIR="$(git rev-parse --show-toplevel)" load "$GIT_ROOT_DIR"/e2e/utils.sh assets="$(dirname "$BATS_TEST_FILENAME")"/../assets @@ -9,7 +8,7 @@ assets="$(dirname "$BATS_TEST_FILENAME")"/../assets setup() { standard_setup - dfx extension install nns + dfx_extension_install_manually nns dfx_new } diff --git a/extensions/sns/e2e/tests/sns.bash b/extensions/sns/e2e/tests/sns.bash index f004a1c..fe10352 100755 --- a/extensions/sns/e2e/tests/sns.bash +++ b/extensions/sns/e2e/tests/sns.bash @@ -1,13 +1,13 @@ #!/usr/bin/env bats -GIT_ROOT_DIR=$(git rev-parse --show-toplevel) +export GIT_ROOT_DIR="$(git rev-parse --show-toplevel)" load "$GIT_ROOT_DIR"/e2e/utils.sh setup() { standard_setup - dfx extension install sns + dfx_extension_install_manually sns } teardown() { @@ -60,8 +60,8 @@ SNS_CONFIG_FILE_NAME="sns.yml" } @test "sns deploy fails without config file" { + dfx_extension_install_manually nns dfx_new - dfx extension install nns dfx nns import rm -f sns.yml # Is not expected to be present anyway run dfx sns deploy @@ -70,11 +70,11 @@ SNS_CONFIG_FILE_NAME="sns.yml" } @test "sns deploy succeeds" { + dfx_extension_install_manually nns dfx_new install_shared_asset subnet_type/shared_network_settings/system dfx start --clean --background --host 127.0.0.1:8080 sleep 1 - dfx extension install nns dfx nns install dfx nns import dfx sns import