Skip to content

Commit

Permalink
Merge branch 'zingolabs:dev' into dev_RN_keychain_keystore_saving_wal…
Browse files Browse the repository at this point in the history
…let_keys
  • Loading branch information
juanky201271 authored Sep 26, 2024
2 parents a9baea6 + 29d2ff2 commit 925a504
Show file tree
Hide file tree
Showing 14 changed files with 754 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
sed -i "/^zingolib/ s/branch = \"dev\"/rev = \"${{ env.zingolib_ref }}\"/" "rust/lib/Cargo.toml"
if cat rust/lib/Cargo.toml | grep "^zingolib" | grep -q "branch"; then exit 1; fi
cd rust
cargo update -p zingolib--aggressive
cargo update -p zingolib --aggressive
- name: Cargo cache
uses: Swatinem/rust-cache@v2
Expand Down
262 changes: 262 additions & 0 deletions .github/workflows/android-ubuntu-e2e-test-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
name: Android Ubuntu e2e tests

on:
workflow_call:
inputs:
timestamp:
required: true
type: string
cache-key:
required: true
type: string
abi:
required: true
type: string
api-level:
required: true
type: string

env:
REPO-OWNER: ${{ github.repository_owner }}
ABI: ${{ inputs.abi }}
API-LEVEL: ${{ inputs.api-level }}
TIMESTAMP: ${{ inputs.timestamp }}

jobs:
android-ubuntu-e2e-test-actions-avd-cache:
name: Avd Cache e2e
runs-on: ubuntu-22.04
env:
CACHE-KEY: ${{ inputs.cache-key }}
steps:
- name: Set envs for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: echo "REPO-OWNER=zingolabs" >> $GITHUB_ENV

- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ env.REPO-OWNER }}/zingo-mobile

- name: Set envs for x86_64
if: ${{ env.ABI == 'x86_64' }}
run: |
echo "AVD-ARCH=x86_64" >> $GITHUB_ENV
- name: Set envs for x86
if: ${{ env.ABI == 'x86' }}
run: |
echo "AVD-ARCH=x86" >> $GITHUB_ENV
- name: Set envs for arm64-v8a
if: ${{ env.ABI == 'arm64-v8a' }}
run: |
echo "AVD-ARCH=arm64-v8a" >> $GITHUB_ENV
- name: Set envs for armeabi-v7a
if: ${{ env.ABI == 'armeabi-v7a' }}
run: |
echo "AVD-ARCH=arm64-v8a" >> $GITHUB_ENV
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Check AVD cache
uses: actions/cache/restore@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.ABI }}-api-${{ env.API-LEVEL }}-e2e
lookup-only: true

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API-LEVEL }}
arch: ${{ env.AVD-ARCH }}
force-avd-creation: true
emulator-options: -no-snapshot-load -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Save AVD cache
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
id: avd-cache-saving
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.ABI }}-api-${{ env.API-LEVEL }}-e2e

android-ubuntu-e2e-test-actions:
name: Android Ubuntu e2e test
needs: android-ubuntu-e2e-test-actions-avd-cache
runs-on: ubuntu-22.04
strategy:
matrix:
test: ["tex_send_address", "reload_while_tx_pending", "change_custom_server", "change_custom_regtest_server", "change_custom_testnet_server", "change_server_from_list", "new_wallet", "screen_awake", "send", "sync_report", "transaction_history"]
env:
CACHE-KEY: ${{ inputs.cache-key }}
steps:
- name: Set envs for zingolib CI
if: ${{ contains(github.repository, 'zingolib') }}
run: echo "REPO-OWNER=zingolabs" >> $GITHUB_ENV

- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ env.REPO-OWNER }}/zingo-mobile

- name: Set envs for x86_64
if: ${{ env.ABI == 'x86_64' }}
run: |
echo "AVD-ARCH=x86_64" >> $GITHUB_ENV
echo "NEXTEST-ABI=x86_64" >> $GITHUB_ENV
- name: Set envs for x86
if: ${{ env.ABI == 'x86' }}
run: |
echo "AVD-ARCH=x86" >> $GITHUB_ENV
echo "NEXTEST-ABI=x86_32" >> $GITHUB_ENV
- name: Set envs for arm64-v8a
if: ${{ env.ABI == 'arm64-v8a' }}
run: |
echo "AVD-ARCH=arm64-v8a" >> $GITHUB_ENV
echo "NEXTEST-ABI=arm64" >> $GITHUB_ENV
- name: Set envs for armeabi-v7a
if: ${{ env.ABI == 'armeabi-v7a' }}
run: |
echo "AVD-ARCH=arm64-v8a" >> $GITHUB_ENV
echo "NEXTEST-ABI=arm32" >> $GITHUB_ENV
- name: Remove unnecessary directories to free up space
run: |
echo "Disk space before post-build cleanup:"
df -h
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/local/lib/android/sdk/ndk
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo apt-get clean
echo "Disk space after post-build cleanup:"
df -h
- name: Grant permissions
run: |
sudo chmod 777 /var/run/docker.sock
sudo chmod 777 ./scripts/e2e_tests_actions.sh
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Install protoc
run: sudo apt install protobuf-compiler

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

- name: Install nextest
uses: taiki-e/install-action@v2
with:
tool: nextest

- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: rust

- name: Pull regchest docker image
run: docker pull zingodevops/regchest:008

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.2
build-root-directory: ./android
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev'}}

- name: Native rust cache
uses: actions/cache/restore@v4
with:
path: android/app/src/main/jniLibs/${{ env.ABI }}
key: native-android-uniffi-${{ env.ABI }}-${{ env.CACHE-KEY }}
fail-on-cache-miss: true

- name: Kotlin uniffi cache
uses: actions/cache/restore@v4
with:
path: android/app/build/generated/source/uniffi/debug/java/uniffi/zingo
key: kotlin-android-uniffi-${{ env.ABI }}-${{ env.CACHE-KEY }}
fail-on-cache-miss: true

- name: Restore AVD cache
uses: actions/cache/restore@v4
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.ABI }}-api-${{ env.API-LEVEL }}-e2e
fail-on-cache-miss: true

- name: Yarn install
run: yarn

- name: Run Build
working-directory: android
run: ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug -PsplitApk=true

- name: Remove unnecessary directories to free up space after build
run: |
echo "Disk space before post-build cleanup:"
df -h
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/local/lib/android/sdk/ndk
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo apt-get clean
echo "Disk space after post-build cleanup:"
df -h
- name: Yarn Start
run: nohup yarn start > "yarn_react_native_start.out" &

- name: Run e2e Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API-LEVEL }}
arch: ${{ env.AVD-ARCH }}
force-avd-creation: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: cargo nextest run e2e::${{ matrix.test }} --features "ci regchest actions" --verbose --release
working-directory: ./rust

- name: Upload test reports
if: ${{ ! cancelled() }}
uses: actions/upload-artifact@v4
with:
name: test-e2e-reports-${{ env.ABI }}-${{ matrix.test }}-${{ env.TIMESTAMP }}
path: android/app/build/outputs/e2e_test_reports
Loading

0 comments on commit 925a504

Please sign in to comment.