Skip to content

Commit 82b909f

Browse files
committed
feat: run android tests on ubuntu
1 parent 105e664 commit 82b909f

File tree

6 files changed

+150
-93
lines changed

6 files changed

+150
-93
lines changed

.github/workflows/e2e-android.yml

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,80 +10,122 @@ on:
1010

1111
jobs:
1212
e2e-android:
13-
runs-on: macos-13
13+
runs-on: ubuntu-latest
1414
timeout-minutes: 120
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 1
2121

22+
- name: Install pulseaudio
23+
run: sudo apt-get install pulseaudio
24+
25+
- name: Enable KVM group perms
26+
run: |
27+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
28+
sudo udevadm control --reload-rules
29+
sudo udevadm trigger --name-match=kvm
30+
31+
- name: Free Disk Space
32+
uses: jlumbroso/free-disk-space@main
33+
with:
34+
# this might remove tools that are actually needed,
35+
# if set to "true" but frees about 6 GB
36+
tool-cache: false
37+
android: false
38+
dotnet: true
39+
haskell: true
40+
large-packages: true
41+
docker-images: true
42+
swap-storage: true
43+
44+
- name: yarn and gradle caches in /mnt
45+
run: |
46+
rm -rf ~/.yarn
47+
rm -rf ~/.gradle
48+
sudo mkdir -p /mnt/.yarn
49+
sudo mkdir -p /mnt/.gradle
50+
sudo chown -R runner /mnt/.yarn
51+
sudo chown -R runner /mnt/.gradle
52+
ln -s /mnt/.yarn /home/runner/
53+
ln -s /mnt/.gradle /home/runner/
54+
55+
- name: Create artifacts directory on /mnt
56+
run: |
57+
sudo mkdir -p /mnt/artifacts
58+
sudo chown -R runner /mnt/artifacts
59+
2260
- name: Node
23-
uses: actions/setup-node@v3
61+
uses: actions/setup-node@v4
2462
with:
25-
node-version: 18
26-
cache: 'yarn' # cache packages, but not node_modules
27-
cache-dependency-path: 'example/yarn.lock'
63+
node-version: 20
64+
# cache: 'yarn' # cache packages, but not node_modules
65+
# cache-dependency-path: 'example/yarn.lock'
2866

29-
- name: Cache lib node modules
30-
uses: actions/cache@v3
31-
id: lib-npmcache
67+
- name: Use yarn caches
68+
uses: actions/cache@v4
3269
with:
33-
path: lib/node_modules
34-
key: node-modules-${{ hashFiles('**/yarn.lock') }}
70+
path: ~/.yarn
71+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
72+
restore-keys: |
73+
${{ runner.os }}-yarn-
3574
3675
- name: Install lib dependencies
37-
if: steps.lib-npmcache.outputs.cache-hit != 'true'
3876
working-directory: lib
39-
run: yarn install
77+
run: yarn || yarn
4078

4179
- name: Build lib
4280
working-directory: lib
4381
run: yarn build
4482

4583
- name: Use gradle caches
46-
uses: actions/cache@v2
84+
uses: actions/cache@v4
4785
with:
48-
path: ~/.gradle/caches
49-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
86+
path: |
87+
~/.gradle/caches
88+
~/.gradle/wrapper
89+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
5090
restore-keys: |
5191
${{ runner.os }}-gradle-
5292
53-
# - name: Cache node modules
54-
# uses: actions/cache@v3
55-
# id: cache-nm
56-
# with:
57-
# path: node_modules
58-
# key: node-modules-${{ hashFiles('**/yarn.lock') }}
59-
6093
- name: Install node_modules
6194
working-directory: example
62-
run: yarn install && yarn rn-setup
95+
run: (yarn || yarn) && yarn rn-setup
6396

6497
- name: Use specific Java version for sdkmanager to work
65-
uses: actions/setup-java@v2
98+
uses: actions/setup-java@v4
6699
with:
67100
distribution: 'temurin'
68-
java-version: '11'
101+
java-version: '17'
69102

70103
- name: Build
71104
working-directory: example
72-
run: yarn e2e:build:android-release
105+
run: yarn e2e:build:android-release || yarn e2e:build:android-release
106+
107+
- name: Show build outputs
108+
working-directory: example
109+
run: tree android/app/build/outputs/
110+
111+
- name: Kill java processes
112+
run: pkill -9 -f java || true
73113

74114
- name: run tests
75115
uses: reactivecircus/android-emulator-runner@v2
76116
with:
77-
api-level: 31
78117
avd-name: Pixel_API_31_AOSP
118+
profile: 5.4in FWVGA # devices list: avdmanager list device
119+
api-level: 31
120+
force-avd-creation: false
79121
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047
80122
arch: x86_64
81123
disable-animations: true
82124
working-directory: example
83-
script: yarn e2e:test:android-release || yarn e2e:test:android-release || yarn e2e:test:android-release
125+
script: yarn e2e:test:android-release --record-videos all --take-screenshots all --record-logs all --artifacts-location /mnt/artifacts || yarn e2e:test:android-release --record-videos all --take-screenshots all --record-logs all --artifacts-location /mnt/artifactsyarn e2e:test:android-release --record-videos all --take-screenshots all --record-logs all --artifacts-location /mnt/artifacts || yarn e2e:test:android-release --record-videos all --take-screenshots all --record-logs all --artifacts-location /mnt/artifacts
84126

85-
- uses: actions/upload-artifact@v3
127+
- uses: actions/upload-artifact@v4
86128
if: failure()
87129
with:
88130
name: e2e-test-videos
89-
path: ./example/artifacts/
131+
path: /mnt/artifacts

.github/workflows/mocha-android.yml

Lines changed: 64 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,62 @@ on:
1010

1111
jobs:
1212
mocha-android:
13-
runs-on: macos-12
13+
runs-on: ubuntu-latest
1414
timeout-minutes: 120
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 1
2121

22-
- name: Setup Docker Colima 1
23-
uses: douglascamata/setup-docker-macos-action@v1-alpha
24-
id: docker1
25-
continue-on-error: true
22+
- name: Enable KVM group perms
23+
run: |
24+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
25+
sudo udevadm control --reload-rules
26+
sudo udevadm trigger --name-match=kvm
27+
28+
- name: Free Disk Space
29+
uses: jlumbroso/free-disk-space@main
2630
with:
27-
lima: v0.18.0
28-
colima: v0.5.6
29-
30-
- name: Setup Docker Colima 2
31-
if: steps.docker1.outcome != 'success'
32-
uses: douglascamata/setup-docker-macos-action@v1-alpha
33-
id: docker2
34-
continue-on-error: true
31+
# this might remove tools that are actually needed,
32+
# if set to "true" but frees about 6 GB
33+
tool-cache: false
34+
android: false
35+
dotnet: true
36+
haskell: true
37+
large-packages: true
38+
docker-images: true
39+
swap-storage: true
40+
41+
- name: yarn and gradle caches in /mnt
42+
run: |
43+
rm -rf ~/.yarn
44+
rm -rf ~/.gradle
45+
sudo mkdir -p /mnt/.yarn
46+
sudo mkdir -p /mnt/.gradle
47+
sudo chown -R runner /mnt/.yarn
48+
sudo chown -R runner /mnt/.gradle
49+
ln -s /mnt/.yarn /home/runner/
50+
ln -s /mnt/.gradle /home/runner/
51+
52+
- name: Create artifacts directory on /mnt
53+
run: |
54+
sudo mkdir -p /mnt/artifacts
55+
sudo chown -R runner /mnt/artifacts
56+
57+
- name: Node
58+
uses: actions/setup-node@v4
3559
with:
36-
lima: v0.18.0
37-
colima: v0.5.6
60+
node-version: 20
3861

39-
- name: Setup Docker Default
40-
if: steps.docker1.outcome != 'success' && steps.docker2.outcome != 'success'
41-
uses: docker-practice/[email protected]
42-
timeout-minutes: 30
62+
- name: Use yarn caches
63+
uses: actions/cache@v4
64+
with:
65+
path: ~/.yarn
66+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
67+
restore-keys: |
68+
${{ runner.os }}-yarn-
4369
4470
- name: Run regtest setup
4571
working-directory: example/docker
@@ -53,24 +79,9 @@ jobs:
5379
timeout-minutes: 2
5480
run: while ! nc -z '127.0.0.1' 60001; do sleep 1; done
5581

56-
- name: Node
57-
uses: actions/setup-node@v3
58-
with:
59-
node-version: 18
60-
cache: 'yarn' # cache packages, but not node_modules
61-
cache-dependency-path: 'example/yarn.lock'
62-
63-
- name: Cache lib node modules
64-
uses: actions/cache@v3
65-
id: lib-npmcache
66-
with:
67-
path: lib/node_modules
68-
key: node-modules-${{ hashFiles('**/yarn.lock') }}
69-
7082
- name: Install lib dependencies
71-
if: steps.lib-npmcache.outputs.cache-hit != 'true'
7283
working-directory: lib
73-
run: yarn --no-audit --prefer-offline || yarn --no-audit --prefer-offline
84+
run: yarn || yarn
7485

7586
- name: Build lib
7687
working-directory: lib
@@ -84,31 +95,32 @@ jobs:
8495
restore-keys: |
8596
${{ runner.os }}-gradle-
8697
87-
# - name: Cache node modules
88-
# uses: actions/cache@v3
89-
# id: cache-nm
90-
# with:
91-
# path: node_modules
92-
# key: node-modules-${{ hashFiles('**/yarn.lock') }}
93-
9498
- name: Install node_modules
9599
working-directory: example
96-
run: yarn install && yarn rn-setup
100+
run: (yarn || yarn) && yarn rn-setup
97101

98102
- name: Use specific Java version for sdkmanager to work
99-
uses: actions/setup-java@v2
103+
uses: actions/setup-java@v4
100104
with:
101105
distribution: 'temurin'
102-
java-version: '11'
106+
java-version: '17'
103107

104-
# - name: Build
105-
# working-directory: example
106-
# run: npx react-native run-android --no-packager
108+
- name: Build
109+
uses: reactivecircus/android-emulator-runner@v2
110+
with:
111+
api-level: 34
112+
avd-name: Pixel_API_31_AOSP
113+
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047
114+
arch: x86_64
115+
disable-animations: true
116+
working-directory: example
117+
script: |
118+
npx react-native run-android --no-packager
107119
108120
- name: run tests
109121
uses: reactivecircus/android-emulator-runner@v2
110122
with:
111-
api-level: 31
123+
api-level: 34
112124
avd-name: Pixel_API_31_AOSP
113125
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none -camera-front none -partition-size 2047
114126
arch: x86_64
@@ -117,8 +129,8 @@ jobs:
117129
script: |
118130
../.github/workflows/mocha-anrdoid.sh
119131
120-
- uses: actions/upload-artifact@v3
132+
- uses: actions/upload-artifact@v4
121133
if: failure()
122134
with:
123135
name: ldk-data
124-
path: example/artifacts/
136+
path: /mnt/artifacts

.github/workflows/mocha-anrdoid.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ echo $EXIT_CODE;
2222
if [ $EXIT_CODE -ne 0 ]; then
2323
adb root
2424
sleep 10
25-
adb pull /data/user/0/com.exmpl/files/ldk/ artifacts/
25+
adb pull /data/user/0/com.exmpl/files/ldk/ /mnt/artifacts/
2626
fi
2727

28+
sleep 10
29+
echo "Test finished"
30+
2831
exit $EXIT_CODE

example/e2e/ldk.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ describe('LDK integration test', () => {
44
});
55

66
beforeEach(async () => {
7-
await device.reloadReactNative();
7+
// await device.reloadReactNative();
88
await element(by.id('dev')).tap();
99
});
1010

example/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"e2e:build:android-release": "detox build --configuration android.emu.release",
1414
"e2e:test:ios-debug": "detox test --configuration ios.sim.debug --record-videos all --take-screenshots all --record-logs all",
1515
"e2e:test:ios-release": "detox test --configuration ios.sim.release --record-videos all --take-screenshots all --record-logs all",
16-
"e2e:test:android-debug": "detox test --configuration android.emu.debug --record-videos all --take-screenshots all --record-logs all",
17-
"e2e:test:android-release": "detox test --configuration android.emu.release --record-videos all --take-screenshots all --record-logs all",
16+
"e2e:test:android-debug": "detox test --configuration android.emu.debug",
17+
"e2e:test:android-release": "detox test --configuration android.emu.release",
1818
"lint:check": "eslint . --ext .js,.jsx,.ts,.tsx",
1919
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
2020
"reinstall": "cd ../lib/ && yarn install && yarn build && cd ../example/ && yarn add ../lib && yarn rn-setup",
@@ -72,7 +72,7 @@
7272
"bitcoin-json-rpc": "^1.3.2",
7373
"chai-as-promised": "^7.1.1",
7474
"concurrently": "^8.2.0",
75-
"detox": "20.17.0",
75+
"detox": "20.20.2",
7676
"electrum-client": "github:BlueWallet/rn-electrum-client#47acb51149e97fab249c3f8a314f708dbee4fb6e",
7777
"eslint": "8.27.0",
7878
"eslint-config-prettier": "^8.5.0",

example/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,7 +2421,7 @@
24212421
bitcoinjs-lib "6.1.4"
24222422

24232423
"@synonymdev/react-native-ldk@../lib":
2424-
version "0.0.141"
2424+
version "0.0.145"
24252425
dependencies:
24262426
"@synonymdev/raw-transaction-decoder" "1.1.0"
24272427
bech32 "^2.0.0"
@@ -4040,10 +4040,10 @@ detect-newline@^3.0.0:
40404040
resolved "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz"
40414041
integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==
40424042

4043-
detox@20.17.0:
4044-
version "20.17.0"
4045-
resolved "https://registry.yarnpkg.com/detox/-/detox-20.17.0.tgz#836d2ebb193572e1f4a97e44af343891a5658f7b"
4046-
integrity sha512-IasYgexfkrCoZuJTaqqKHQ2yflK+tnqifzdLwrp4hdTWlXUlG9j/YcM1Dn3ThSs3b6VNMtbSe6xoPkKD0oNiIQ==
4043+
detox@20.20.2:
4044+
version "20.20.2"
4045+
resolved "https://registry.yarnpkg.com/detox/-/detox-20.20.2.tgz#988619d99e08bd992931458e3db7af248254bf31"
4046+
integrity sha512-X0FWsj8Bry965fEy7N87bKecIIkcAg3AyaCDXFa0yO+kAIajFbSV7LMtNTQP/c1D0eD4+U5sn9zUJWWhQhucWg==
40474047
dependencies:
40484048
ajv "^8.6.3"
40494049
bunyan "^1.8.12"

0 commit comments

Comments
 (0)