-
Notifications
You must be signed in to change notification settings - Fork 99
144 lines (137 loc) · 6.73 KB
/
e2e-android.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: E2E - Android
on:
workflow_call:
inputs:
android-api-level:
required: true
type: number
jobs:
android:
env:
# `if` conditions can't directly access secrets, so we use a workaround
# See https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
BASH_ENV: ~/.profile
name: Android (SDK ${{ inputs.android-api-level }})
runs-on:
- nscloud-ubuntu-22.04-amd64-16x64-with-cache
- nscloud-cache-size-20gb
- nscloud-cache-tag-wallet-e2e-android
# We pay by the minute.
# If it takes longer it usually fails, so no need to pay for more
timeout-minutes: 25
steps:
- uses: google-github-actions/auth@v2
if: ${{ env.SECRETS_AVAILABLE }}
with:
project_id: celo-mobile-mainnet
credentials_json: ${{ secrets.MAINNET_SERVICE_ACCOUNT_KEY }}
- name: Google Secrets
if: ${{ env.SECRETS_AVAILABLE }}
id: google-secrets
uses: google-github-actions/get-secretmanager-secrets@v2.2.2
with:
secrets: |-
E2E_WALLET_CONNECT_PROJECT_ID:projects/1027349420744/secrets/E2E_WALLET_CONNECT_PROJECT_ID
E2E_DEFAULT_RECIPIENT_MNEMONIC:projects/1027349420744/secrets/E2E_DEFAULT_RECIPIENT_MNEMONIC
E2E_DEFAULT_RECIPIENT_PRIVATE_KEY:projects/1027349420744/secrets/E2E_DEFAULT_RECIPIENT_PRIVATE_KEY
E2E_WALLET_MNEMONIC:projects/1027349420744/secrets/E2E_WALLET_MNEMONIC
E2E_WALLET_PRIVATE_KEY:projects/1027349420744/secrets/E2E_WALLET_PRIVATE_KEY
E2E_WALLET_SINGLE_VERIFIED_MNEMONIC:projects/1027349420744/secrets/E2E_WALLET_SINGLE_VERIFIED_MNEMONIC
E2E_WALLET_MULTIPLE_VERIFIED_MNEMONIC:projects/1027349420744/secrets/E2E_WALLET_MULTIPLE_VERIFIED_MNEMONIC
E2E_WALLET_12_WORDS_MNEMONIC:projects/1027349420744/secrets/E2E_WALLET_12_WORDS_MNEMONIC
- uses: actions/checkout@v4
- name: Set env
run: |
ANDROID_HOME="$HOME/android-tools"
echo "ANDROID_HOME=$ANDROID_HOME" >> $GITHUB_ENV
echo "$ANDROID_HOME/cmdline-tools/latest/bin" >> $GITHUB_PATH
echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH
echo "$ANDROID_HOME/emulator" >> $GITHUB_PATH
- name: Store compileSdkVersion in env
run: echo "ANDROID_COMPILE_SDK_VERSION=$(grep 'compileSdkVersion' android/build.gradle | grep -o '[0-9]\+')" >> $GITHUB_ENV
# See https://namespace.so/docs/actions/nscloud-cache-action
- name: Cache
uses: namespacelabs/nscloud-cache-action@v1
with:
cache: gradle
path: ${{ env.ANDROID_HOME}}
- uses: ./.github/actions/yarn-install
- name: Setup runner
run: |
set -x
mkdir -p $ANDROID_HOME
curl https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip -o cli-tools.zip
unzip cli-tools.zip -d "$ANDROID_HOME/cmdline-tools"
# Command line tools need to be placed in $ANDROID_HOME/cmdline-tools/latest to function properly
# and because we cache $ANDROID_HOME, we need remove the existing version and move the new one
rm -rf "$ANDROID_HOME/cmdline-tools/latest"
mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest"
# Temporarily disable checking for EPIPE error and use yes to accept all licenses
set +o pipefail
yes | sdkmanager --licenses
set -o pipefail
# Install Android SDK
sdkmanager "platform-tools" "platforms;android-${{ env.ANDROID_COMPILE_SDK_VERSION }}"
# Install Ninja
sudo apt-get install ninja-build
# Allow the emulator to use /dev/kvm
sudo adduser $USER kvm
sudo chown $USER /dev/kvm
shell: bash
- name: Setup emulator
run: >
yarn ts-node ./.github/scripts/setupAndroidEmulator.ts
--image "system-images;android-${{ inputs.android-api-level }};default;x86_64"
--emulatorName Pixel_API_${{ inputs.android-api-level }}_AOSP_x86_64
# Since the e2e runners have access to the Valora branding,
# This check ensures there are no type errors there.
# The `yarn build` step done in the test workflow also includes it but does it with the default celo branding.
- name: TS check
run: yarn build:ts
- name: Check E2E wallet balance
run: NODE_OPTIONS='--unhandled-rejections=strict' yarn ts-node ./e2e/scripts/check-e2e-wallet-balance.ts
- name: Create Detox Build
run: CELO_TEST_CONFIG=e2e yarn detox build -c android.release
- name: Run Detox
run: >
yarn detox test
--device-name Pixel_API_${{ inputs.android-api-level }}_AOSP_x86_64
--configuration android.release
--artifacts-location e2e/artifacts
--take-screenshots=failing
--record-videos=failing
--record-logs=failing
--loglevel info
--debug-synchronization 10000
--maxWorkers 12
--headless
--retries 3
--device-boot-args="-snapshot ci_boot"
env:
E2E_WALLET_CONNECT_PROJECT_ID: ${{ steps.google-secrets.outputs.E2E_WALLET_CONNECT_PROJECT_ID }}
E2E_DEFAULT_RECIPIENT_MNEMONIC: ${{ steps.google-secrets.outputs.E2E_DEFAULT_RECIPIENT_MNEMONIC }}
E2E_DEFAULT_RECIPIENT_PRIVATE_KEY: ${{ steps.google-secrets.outputs.E2E_DEFAULT_RECIPIENT_PRIVATE_KEY }}
E2E_WALLET_MNEMONIC: ${{ steps.google-secrets.outputs.E2E_WALLET_MNEMONIC }}
E2E_WALLET_PRIVATE_KEY: ${{ steps.google-secrets.outputs.E2E_WALLET_PRIVATE_KEY }}
E2E_WALLET_SINGLE_VERIFIED_MNEMONIC: ${{ steps.google-secrets.outputs.E2E_WALLET_SINGLE_VERIFIED_MNEMONIC }}
E2E_WALLET_MULTIPLE_VERIFIED_MNEMONIC: ${{ steps.google-secrets.outputs.E2E_WALLET_MULTIPLE_VERIFIED_MNEMONIC }}
E2E_WALLET_12_WORDS_MNEMONIC: ${{ steps.google-secrets.outputs.E2E_WALLET_12_WORDS_MNEMONIC }}
- name: Publish Android JUnit Report
if: always()
uses: mikepenz/action-junit-report@v4
with:
check_name: Android (${{ inputs.android-api-level }}) e2e Test Report
report_paths: 'e2e/test-results/junit.xml'
- name: 'Upload Android E2E Artifacts'
if: failure() || cancelled()
uses: actions/upload-artifact@v4
with:
name: android-${{ inputs.android-api-level }}-e2e-artifact
path: e2e/artifacts
- name: 'Upload Android E2E HTML Report'
if: always()
uses: actions/upload-artifact@v4
with:
name: android-${{ inputs.android-api-level }}-e2e-test-report
path: e2e/test-results