Skip to content

Commit

Permalink
[Actions/CI]: Switch to macos-latest-xlarge CI runner for Android, iO…
Browse files Browse the repository at this point in the history
…S pipelines (#3474)
  • Loading branch information
satoshiotomakan authored Nov 16, 2023
1 parent 4a5fc03 commit a60033f
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 45 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/ios-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,45 @@ 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

- name: Run iOS tests
run: |
tools/generate-files ios
tools/ios-test
- name: Build sample app
run: |
tools/samples-build ios
14 changes: 13 additions & 1 deletion .github/workflows/kotlin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/kotlin-sample-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion samples/kmp/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion swift/Tests/Keystore/KeyStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ class KeyStoreTests: XCTestCase {
}

func testImportJSON() throws {

let expected = """
{
"activeAccounts": [{
Expand Down
1 change: 1 addition & 0 deletions tests/chains/Aptos/CompilerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions tools/android-build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tools/android-release
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
50 changes: 50 additions & 0 deletions tools/android-sdk
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 9 additions & 1 deletion tools/android-test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 7 additions & 3 deletions tools/install-android-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions tools/install-kotlin-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions tools/kotlin-build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tools/kotlin-release
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tools/kotlin-test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit a60033f

Please sign in to comment.