This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (124 loc) · 4.86 KB
/
android_app_build_debug.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: Android Build Debug and Upload
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build-and-test:
runs-on: ubuntu-latest
env:
ANDROID_APP_PATH: "sample/application"
steps:
#Get the code
- uses: actions/checkout@v4
# Check if the application folder contains an Android project
- name: Check for Android project
run: |
if [ -f "${{env.ANDROID_APP_PATH}}/build.gradle" ] || [ -f "${{env.ANDROID_APP_PATH}}/build.gradle.kts" ]; then
echo "Android project found"
if [ -n "$(find ${{env.ANDROID_APP_PATH}}/app/src/main/java -name "*.kt" -type f)" ]; then
echo "Module app is written in Kotlin"
exit 1
else
echo "Module app is written in Java"
fi
else
echo "No Android project found"
exit 1
fi
# Enable KVM for emulator
- 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
# Setup min version of Java required by Gradle v8
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
# Let gradle action handle all cache reated to gradle operations
- name: Gradle cache
uses: gradle/gradle-build-action@v3
# Build the debug apk
- name: Build debug apk
run: |
chmod +x ${{env.ANDROID_APP_PATH}}/gradlew
./${{env.ANDROID_APP_PATH}}/gradlew assembleDebug -p ${{env.ANDROID_APP_PATH}}
# Save/Restore avd cache for faster boot
- name: AVD cache
uses: actions/cache@v4
id: avd-cache-new
with:
path: |
~/.android/avd/*
~/.android/adb*
$ANDROID_HOME/emulator/*
key: avd-eval-test-new
# Create an AVD if it's not cached yet
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache-new.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
avd-name: "test"
api-level: 29
target: google_apis
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Check GithubA env
run: echo "$GITHUB_CONTEXT"
- name: tests 1
run: |
echo $ANDROID_HOME
ls -a $ANDROID_HOME
echo "########"
echo $ANDROID_HOME/cmdline-tools
ls -a $ANDROID_HOME/cmdline-tools
echo "########"
echo $ANDROID_HOME/cmdline-tools/latest
ls -a $ANDROID_HOME/cmdline-tools/latest
echo "########"
echo .android
ls -a ~/.android
# Setup/Start the emulator to launch instrumented tests
- name: Setup & Start Emulator
timeout-minutes: 10
run: |
bash .github/scripts/setup_emulators.sh
- name: tests 3
run: |
echo "########"
find "$ANDROID_HOME" -name "*emulator*" -print
# - name: Start Android Emulator
# timeout-minutes: 1
# continue-on-error: true
# run: |
# echo "Starting emulator"
# nohup $ANDROID_HOME/cmdline-tools/latest/emulator/emulator -avd "test" -no-audio -no-snapshot -no-window &
# $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
# $ANDROID_HOME/platform-tools/adb devices
# echo "Emulator started"
# Instrumented tests
- name: Run tests
run: ./${{env.ANDROID_APP_PATH}}/gradlew connectedCheck -p ${{env.ANDROID_APP_PATH}}
# Kills the running emulator on the default port
- name: Kill Emulator
run: $ANDROID_HOME/platform-tools/adb -s emulator-5554 emu kill
# - name: run tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 29
# force-avd-creation: false
# emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# disable-animations: true
# script: ./${{env.ANDROID_APP_PATH}}/gradlew connectedCheck -p ${{env.ANDROID_APP_PATH}}
# # Upload the debug apk to GitHub
# - name: Upload debug apk
# uses: actions/upload-artifact@v4
# with:
# name: android-debug
# path: "${{env.ANDROID_APP_PATH}}/app/build/outputs/apk/debug/*"