Repository navigation
132 lines (118 loc) · 4.82 KB
/
Copy pathandroid.yml
File metadata and controls
132 lines (118 loc) · 4.82 KB
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
name: Android Build
on:
workflow_call:
jobs:
android-build:
runs-on: ubuntu-latest
timeout-minutes: 75
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_MAXSIZE: 2G
CCACHE_SLOPPINESS: include_file_ctime,include_file_mtime,pch_defines,system_headers,time_macros
CCACHE_DEPEND: true
# Runner image updates touch clang even when it hasn't changed, so
# compare its contents instead of its mtime.
CCACHE_COMPILERCHECK: content
# CMake picks these up as defaults, so every native module goes through ccache.
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version-file: package.json
- name: Install dependencies
run: bun install --frozen-lockfile
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'
- name: Install ccache
run: sudo apt-get install -y ccache
- name: Cache ccache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .ccache
key: ccache-android-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: ccache-android-
# setup-java's Gradle cache is keyed on the Gradle files only, so it never
# picks up new build cache entries. Cache those separately.
- name: Cache Gradle build cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.gradle/caches/build-cache-1
key: gradle-build-cache-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: gradle-build-cache-
- name: Bundle app
run: bun run build:android
working-directory: example
# Built before the emulator exists: Gradle competing with a swiftshader
# emulator for the runner's cores ANRs System UI, and the dialog then
# blocks every test.
- name: Build release APK
run: |
ccache --zero-stats
./gradlew :app:assembleRelease -PreactNativeArchitectures=x86_64 --build-cache
ccache --show-stats
working-directory: example/android
- name: AVD cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-35-google-x86_64
- name: Enable KVM group perms
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
ls /dev/kvm
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
with:
api-level: 35
target: google_apis
arch: x86_64
ram-size: 4096M
profile: pixel
avd-name: pager-view-api-35-google
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-boot-timeout: 12000
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run e2e tests
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
api-level: 35
target: google_apis
arch: x86_64
profile: pixel
avd-name: pager-view-api-35-google
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-boot-timeout: 12000
disable-animations: false
script: |
adb shell settings put global hide_error_dialogs 1
adb install -r example/android/app/build/outputs/apk/release/app-release.apk
bun run e2e:test:android
- name: Upload e2e report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-report-android
path: |
e2e/.e2e/report.json
e2e/.e2e/artifacts
if-no-files-found: warn
retention-days: 7