diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml index a575fe792ea..b8d6bb34c8a 100644 --- a/.github/workflows/android-ci.yml +++ b/.github/workflows/android-ci.yml @@ -12,7 +12,7 @@ concurrency: jobs: build: - runs-on: [ self-hosted, macOS, ARM64, wallet-core ] + runs-on: macos-latest-large if: github.event.pull_request.draft == false steps: - uses: actions/checkout@v3 @@ -29,6 +29,15 @@ jobs: - name: Install system dependencies run: | tools/install-sys-dependencies-mac + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + rust + + - name: Install Rust dependencies + run: | tools/install-rust-dependencies - name: Install Android Dependencies @@ -39,7 +48,7 @@ jobs: uses: actions/cache@v3 with: path: build/local - key: ${{ runner.os }}-internal-${{ hashFiles('tools/install-dependencies') }} + key: ${{ runner.os }}-${{ runner.arch }}-internal-${{ hashFiles('tools/install-dependencies') }} - name: Install internal dependencies run: tools/install-dependencies @@ -51,8 +60,21 @@ jobs: - name: Build Kotlin doc run: tools/kotlin-doc - - name: Run test - run: tools/android-test + - name: Build tests + run: | + pushd android + ./gradlew assembleAndroidTest + popd + + - name: Run tests + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 30 + target: google_apis + arch: x86 + ndk: 23.1.7779620 + cmake: 3.18.1 + script: cd android; ./gradlew connectedAndroidTest - name: Build sample app run: tools/samples-build android diff --git a/.github/workflows/ios-ci.yml b/.github/workflows/ios-ci.yml index 7dcc89a194b..649b15e84a2 100644 --- a/.github/workflows/ios-ci.yml +++ b/.github/workflows/ios-ci.yml @@ -12,24 +12,37 @@ concurrency: jobs: build: - runs-on: [ self-hosted, macOS, ARM64, wallet-core ] + runs-on: macos-latest-xlarge if: github.event.pull_request.draft == false steps: - uses: actions/checkout@v3 + - name: Install system dependencies run: | tools/install-sys-dependencies-mac + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + rust + + - name: Install Rust dependencies + run: | tools/install-rust-dependencies + - name: Cache internal dependencies id: internal_cache uses: actions/cache@v3 with: path: build/local key: ${{ runner.os }}-internal-${{ hashFiles('tools/install-dependencies') }} + - name: Install internal dependencies run: | tools/install-dependencies if: steps.internal_cache.outputs.cache-hit != 'true' + - name: Run codegen tests run: tools/codegen-test @@ -37,6 +50,7 @@ jobs: run: | tools/generate-files ios tools/ios-test + - name: Build sample app run: | tools/samples-build ios diff --git a/.github/workflows/kotlin-ci.yml b/.github/workflows/kotlin-ci.yml index 0a517a03ae8..1198c20ae3c 100644 --- a/.github/workflows/kotlin-ci.yml +++ b/.github/workflows/kotlin-ci.yml @@ -12,7 +12,7 @@ concurrency: jobs: build: - runs-on: [ self-hosted, macOS, ARM64, wallet-core ] + runs-on: macos-latest-xlarge if: github.event.pull_request.draft == false steps: - uses: actions/checkout@v3 @@ -23,6 +23,9 @@ jobs: java-version: '17' distribution: 'temurin' + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + - name: Setup Gradle uses: gradle/gradle-build-action@v2 with: @@ -31,6 +34,15 @@ jobs: - name: Install system dependencies run: | tools/install-sys-dependencies-mac + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: | + rust + + - name: Install Rust dependencies + run: | tools/install-rust-dependencies - name: Install emsdk diff --git a/.github/workflows/kotlin-sample-ci.yml b/.github/workflows/kotlin-sample-ci.yml index 4c42e44dcd5..f96b2a4b280 100644 --- a/.github/workflows/kotlin-sample-ci.yml +++ b/.github/workflows/kotlin-sample-ci.yml @@ -12,7 +12,7 @@ concurrency: jobs: build: - runs-on: [ self-hosted, macOS, ARM64, wallet-core ] + runs-on: macos-latest-xlarge if: github.event.pull_request.draft == false steps: - uses: actions/checkout@v3 @@ -23,6 +23,9 @@ jobs: java-version: '17' distribution: 'temurin' + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + - name: Install Kotlin Dependencies run: tools/install-kotlin-dependencies diff --git a/samples/kmp/shared/build.gradle.kts b/samples/kmp/shared/build.gradle.kts index 14741e42ad6..dc4b6fbb8b1 100644 --- a/samples/kmp/shared/build.gradle.kts +++ b/samples/kmp/shared/build.gradle.kts @@ -35,7 +35,7 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("com.trustwallet:wallet-core-kotlin:4.0.0") + implementation("com.trustwallet:wallet-core-kotlin:4.0.5") } } val commonTest by getting { diff --git a/swift/Tests/Keystore/KeyStoreTests.swift b/swift/Tests/Keystore/KeyStoreTests.swift index 62d907ccfaf..3017d10c304 100755 --- a/swift/Tests/Keystore/KeyStoreTests.swift +++ b/swift/Tests/Keystore/KeyStoreTests.swift @@ -234,7 +234,6 @@ class KeyStoreTests: XCTestCase { } func testImportJSON() throws { - let expected = """ { "activeAccounts": [{ diff --git a/tests/chains/Aptos/CompilerTests.cpp b/tests/chains/Aptos/CompilerTests.cpp index 16d7ae5dc11..fd00034931a 100644 --- a/tests/chains/Aptos/CompilerTests.cpp +++ b/tests/chains/Aptos/CompilerTests.cpp @@ -5,6 +5,7 @@ // file LICENSE at the root of the source code distribution tree. #include "proto/Aptos.pb.h" +#include "proto/TransactionCompiler.pb.h" #include "HexCoding.h" #include "PrivateKey.h" #include "PublicKey.h" diff --git a/tools/android-build b/tools/android-build index bab31390ec8..8c4b1344af8 100755 --- a/tools/android-build +++ b/tools/android-build @@ -7,6 +7,10 @@ set -e source $(dirname $0)/library version=$(wc_read_version $1) +if [[ `uname` == "Darwin" ]]; then + export BOOST_ROOT=$(brew --prefix boost) +fi + pushd android ./gradlew assembleRelease cp wallet-core/build/outputs/aar/wallet-core-release.aar ../build/wallet-core.aar diff --git a/tools/android-release b/tools/android-release index 6371adc941f..2b4bca2da1d 100755 --- a/tools/android-release +++ b/tools/android-release @@ -8,6 +8,10 @@ set -e source $(dirname $0)/library version=$(wc_read_version $1) +if [[ `uname` == "Darwin" ]]; then + export BOOST_ROOT=$(brew --prefix boost) +fi + echo "Building $version" export ANDROID_HOME="$HOME/Library/Android/sdk" diff --git a/tools/android-sdk b/tools/android-sdk new file mode 100644 index 00000000000..2ee8025fdb4 --- /dev/null +++ b/tools/android-sdk @@ -0,0 +1,50 @@ +#!/bin/bash + +export NDK_API_LEVEL=21 + +find_android_ndk() { + if [[ "$ANDROID_NDK_HOME" != "" ]]; then + >&2 echo "Use ANDROID_NDK_HOME" + elif [[ "$ANDROID_HOME" != "" ]]; then + >&2 echo "ANDROID_NDK_HOME is not set. Use ANDROID_HOME value instead" + ANDROID_NDK_HOME="$ANDROID_HOME/ndk" + else + >&2 echo "WARNING: ANDROID_HOME is not set. Use a default path" + ANDROID_NDK_HOME="$HOME/Library/Android/sdk/ndk" + fi + + TEST_CLANG="aarch64-linux-android$NDK_API_LEVEL-clang" + PATH_TO_CLANG=$(find "$ANDROID_NDK_HOME" -iname $TEST_CLANG -print -quit) + + if [[ "$PATH_TO_CLANG" == "" ]]; then + >&2 echo "ERROR: cannot find NDK tools within '$ANDROID_NDK_HOME'" + exit 22 + fi + + echo $(dirname "$PATH_TO_CLANG") +} + +find_android_cmdline_tools() { + # Default version of cmdline tools is 11. + # https://github.com/android-actions/setup-android/blob/9584f05408b63719e3464df8ac85bdbe58f88a64/src/main.ts#L9 + CMDLINE_TOOLS_VERSION="11.0" + + if [[ "$ANDROID_HOME" == "" ]]; then + >&2 echo "ANDROID_HOME is not set. Use a default path" + ANDROID_HOME="$HOME/Library/Android/sdk" + fi + + # cmdline-tools could have a 'latest' version, but if it was installed 2 years ago it may not be 'latest' as of today + if [ -x "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" ]; then + echo "$ANDROID_HOME/cmdline-tools/latest/bin" + return 0 + fi + + if [ -x "$ANDROID_HOME/cmdline-tools/$CMDLINE_TOOLS_VERSION/bin/sdkmanager" ]; then + echo "$ANDROID_HOME/cmdline-tools/$CMDLINE_TOOLS_VERSION/bin" + return 0 + fi + + >&2 echo "ERROR: cannot find SDK cmdline tools within '$ANDROID_HOME'" + exit 22 +} diff --git a/tools/android-test b/tools/android-test index e2f2288d09f..7185d860711 100755 --- a/tools/android-test +++ b/tools/android-test @@ -4,9 +4,17 @@ set -e +source "$(dirname $0)/android-sdk" + +ANDROID_CMDTOOLS=$(find_android_cmdline_tools) + AVD_NAME="integration-tests" PORT=5556 +if [[ `uname` == "Darwin" ]]; then + export BOOST_ROOT=$(brew --prefix boost) +fi + # Make sure it builds before starting an emulator pushd android ./gradlew assembleAndroidTest @@ -17,7 +25,7 @@ SERIAL=emulator-${PORT} # We have to echo "no" because it will ask us if we want to use a custom hardware profile, and we don't. echo -e "\nCreating Android emulator...\n" -echo "no" | "$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager" create avd \ +echo "no" | "$ANDROID_CMDTOOLS/avdmanager" create avd \ -n "${AVD_NAME}" \ -k "system-images;android-33;google_apis;arm64-v8a" \ -f diff --git a/tools/install-android-dependencies b/tools/install-android-dependencies index b91ad4d6520..667e8c4342d 100755 --- a/tools/install-android-dependencies +++ b/tools/install-android-dependencies @@ -2,6 +2,10 @@ set -e +source "$(dirname $0)/android-sdk" + +ANDROID_CMDTOOLS=$(find_android_cmdline_tools) + # Dokka stuff ROOT="$PWD" DOKKA_CLI_JAR=https://repo1.maven.org/maven2/org/jetbrains/dokka/dokka-cli/1.7.20/dokka-cli-1.7.20.jar @@ -16,10 +20,10 @@ https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-html-jvm/0.8.0/kotl https://repo1.maven.org/maven2/org/freemarker/freemarker/2.3.31/freemarker-2.3.31.jar ) -$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --verbose "cmake;3.18.1" "ndk;23.1.7779620" -$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-26;google_apis;x86" +$ANDROID_CMDTOOLS/sdkmanager --verbose "cmake;3.18.1" "ndk;23.1.7779620" +$ANDROID_CMDTOOLS/sdkmanager "system-images;android-30;google_apis;x86" -echo -e "y\ny\ny\ny\ny\n" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses +echo -e "y\ny\ny\ny\ny\n" | $ANDROID_CMDTOOLS/sdkmanager --licenses echo "Downloading Dokka..." DOKKA_DIR="$ROOT/build/dokka" diff --git a/tools/install-kotlin-dependencies b/tools/install-kotlin-dependencies index e837297f31e..42c24dca325 100755 --- a/tools/install-kotlin-dependencies +++ b/tools/install-kotlin-dependencies @@ -2,6 +2,9 @@ set -e -"$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --verbose "cmake;3.22.1" "ndk;25.2.9519653" +source "$(dirname $0)/android-sdk" -yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses +ANDROID_CMDTOOLS=$(find_android_cmdline_tools) + +$ANDROID_CMDTOOLS/sdkmanager --verbose "cmake;3.22.1" "ndk;25.2.9519653" +yes | $ANDROID_CMDTOOLS/sdkmanager --licenses diff --git a/tools/kotlin-build b/tools/kotlin-build index a64537b101f..4681910d30a 100755 --- a/tools/kotlin-build +++ b/tools/kotlin-build @@ -2,6 +2,10 @@ set -e +if [[ `uname` == "Darwin" ]]; then + export BOOST_ROOT=$(brew --prefix boost) +fi + pushd kotlin ./gradlew :wallet-core-kotlin:generateProtos ./gradlew :wallet-core-kotlin:assemble diff --git a/tools/kotlin-release b/tools/kotlin-release index 90552fe9ab2..c6e5f40afa8 100755 --- a/tools/kotlin-release +++ b/tools/kotlin-release @@ -8,6 +8,7 @@ version=$(wc_read_version $1) echo "Building $version" export ANDROID_HOME="$HOME/Library/Android/sdk" +export BOOST_ROOT=$(brew --prefix boost) pushd kotlin ./gradlew :wallet-core-kotlin:generateProtos diff --git a/tools/kotlin-test b/tools/kotlin-test index b6218d532b5..2c97cef3d00 100755 --- a/tools/kotlin-test +++ b/tools/kotlin-test @@ -2,6 +2,10 @@ set -e +if [[ `uname` == "Darwin" ]]; then + export BOOST_ROOT=$(brew --prefix boost) +fi + pushd kotlin ./gradlew :wallet-core-kotlin:jvmTest popd diff --git a/tools/rust-bindgen b/tools/rust-bindgen index 02546de6b1a..0c61c54f467 100755 --- a/tools/rust-bindgen +++ b/tools/rust-bindgen @@ -2,12 +2,13 @@ set -e +source "$(dirname $0)/android-sdk" + TARGET_NAME="libwallet_core_rs.a" TARGET_XCFRAMEWORK_NAME=../swift/WalletCoreRs.xcframework BUILD_FOLDER=../rust/target CRATE="wallet-core-rs" HEADER_NAME="WalletCoreRSBindgen.h" -NDK_API_LEVEL=21 create_xc_framework() { rm -rf $TARGET_XCFRAMEWORK_NAME @@ -16,31 +17,6 @@ create_xc_framework() { cp $BUILD_FOLDER/catalyst/$TARGET_NAME $TARGET_XCFRAMEWORK_NAME/ios-arm64_x86_64-maccatalyst } -find_android_ndk() { - if [[ "$ANDROID_NDK_HOME" != "" ]]; then - echo "Use ANDROID_NDK_HOME" - elif [[ "$ANDROID_HOME" != "" ]]; then - echo "ANDROID_NDK_HOME is not set. Use ANDROID_HOME value instead" - ANDROID_NDK_HOME="$ANDROID_HOME/ndk" - else - echo "WARNING: ANDROID_HOME is not set. Use a default path" - ANDROID_NDK_HOME="$HOME/Library/Android/sdk/ndk" - fi - - TEST_CLANG="aarch64-linux-android$NDK_API_LEVEL-clang" - PATH_TO_CLANG=$(find "$ANDROID_NDK_HOME" -iname $TEST_CLANG -print -quit) - - if [[ "$PATH_TO_CLANG" == "" ]]; then - echo "ERROR: cannot find NDK tools within '$ANDROID_NDK_HOME'" - return 1 - fi - - NDK_BIN_PATH=$(dirname "$PATH_TO_CLANG") - export NDK_BIN_PATH - - return 0 -} - cd rust NATIVE="false" @@ -53,13 +29,13 @@ if [[ "$1" == "native" ]] || [[ "$1" == "" ]]; then NATIVE="true" fi -# Generate bindings for mobile platforms on MacOS only. -if [[ `uname` == "Darwin" ]]; then - # Whether to generate bindings for Android. +# Whether to generate bindings for Android. if [[ "$1" == "android" ]] || [[ "$1" == "" ]]; then ANDROID="true" fi +# Generate bindings for ios platforms on MacOS only. +if [[ `uname` == "Darwin" ]]; then # Whether to generate bindings for iOS. if [[ "$1" == "ios" ]] || [[ "$1" == "" ]]; then IOS="true" @@ -82,7 +58,7 @@ if [[ "$WASM" == "true" ]]; then fi if [[ "$ANDROID" == "true" ]]; then - find_android_ndk + NDK_BIN_PATH=$(find_android_ndk) export AR="$NDK_BIN_PATH/llvm-ar" export CC_aarch64_linux_android="$NDK_BIN_PATH/aarch64-linux-android$NDK_API_LEVEL-clang"