Skip to content

Commit 099cc3a

Browse files
committed
Add ci workflows
1 parent 5b6f0b2 commit 099cc3a

File tree

3 files changed

+168
-1
lines changed

3 files changed

+168
-1
lines changed

.github/workflows/android-test.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Android Emulator Tests
2+
on: [ push, pull_request ]
3+
4+
jobs:
5+
check-if-tests-exist:
6+
runs-on: ubuntu-latest
7+
outputs:
8+
status: ${{ steps.check-androidTest.outputs.NOT_EMPTY }}
9+
min-sdk-version: ${{ steps.get-sdk-version.outputs.MIN_SDK_VERSION }}
10+
target-sdk-version: ${{ steps.get-sdk-version.outputs.TARGET_SDK_VERSION }}
11+
app-id: ${{ steps.get-app-id.outputs.APP_ID }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
submodules: "recursive"
17+
- name: Check if androidTest folder is not empty
18+
run: |
19+
echo "NOT_EMPTY=$([ "$(ls -A app/src/androidTest)" ] && echo 'true' || echo 'false')"
20+
echo "NOT_EMPTY=$([ "$(ls -A app/src/androidTest)" ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
21+
id: check-androidTest
22+
- name: Get min and target sdk
23+
if: steps.check-androidTest.outputs.NOT_EMPTY == 'true'
24+
id: get-sdk-version
25+
run: |
26+
echo "MIN_SDK_VERSION=$(cat app/build.gradle | grep minSdkVersion | rev | cut -d' ' -f 1 | rev)" >> $GITHUB_OUTPUT
27+
echo "TARGET_SDK_VERSION=$(cat app/build.gradle | grep targetSdkVersion | rev | cut -d' ' -f 1 | rev)" >> $GITHUB_OUTPUT
28+
- name: Get app ID
29+
id: get-app-id
30+
run: |
31+
echo "APP_ID=$(cat app/build.gradle | grep applicationId | rev | cut -d' ' -f 1 | rev | tr -d '"')" >> $GITHUB_OUTPUT
32+
33+
test:
34+
needs: check-if-tests-exist
35+
if: needs.check-if-tests-exist.outputs.status == 'true'
36+
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
api-level: [34, "${{ needs.check-if-tests-exist.outputs.min-sdk-version }}", "${{ needs.check-if-tests-exist.outputs.target-sdk-version }}"]
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v3
43+
with:
44+
submodules: 'recursive'
45+
46+
- name: Enable KVM group perms
47+
run: |
48+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
49+
sudo udevadm control --reload-rules
50+
sudo udevadm trigger --name-match=kvm
51+
52+
- name: Gradle cache
53+
uses: gradle/gradle-build-action@v3
54+
55+
- name: AVD cache
56+
uses: actions/cache@v4
57+
id: avd-cache
58+
with:
59+
path: |
60+
~/.android/avd/*
61+
~/.android/adb*
62+
key: avd-${{ matrix.api-level }}
63+
64+
- name: Set up JDK environment
65+
uses: actions/setup-java@v3
66+
with:
67+
distribution: 'zulu'
68+
java-version: 17
69+
70+
- name: create AVD and generate snapshot for caching
71+
if: steps.avd-cache.outputs.cache-hit != 'true'
72+
uses: reactivecircus/android-emulator-runner@v2
73+
with:
74+
api-level: ${{ matrix.api-level }}
75+
target: ${{ matrix.api-level >= 30 && 'google_apis' || 'default' }}
76+
arch: ${{ matrix.api-level < 21 && 'x86' || 'x86_64' }}
77+
force-avd-creation: false
78+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
79+
disable-animations: false
80+
script: echo "Generated AVD snapshot for caching."
81+
82+
- name: Run connected tests
83+
uses: ReactiveCircus/android-emulator-runner@v2
84+
with:
85+
api-level: ${{ matrix.api-level }}
86+
target: ${{ matrix.api-level >= 30 && 'google_apis' || 'default' }}
87+
arch: ${{ matrix.api-level < 21 && 'x86' || 'x86_64' }}
88+
force-avd-creation: false
89+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
90+
disable-animations: true
91+
script: |
92+
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}} || true
93+
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}}.test || true
94+
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}}.androidTest || true
95+
chmod +x gradlew
96+
./gradlew :app:connectedCheck --stacktrace
97+
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}} || true
98+
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}}.test || true
99+
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}}.androidTest || true

.github/workflows/changelog.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Changelog Generation
22

33
on:
44
release:
5-
types: [published, released]
5+
types: [published]
66
workflow_dispatch:
77

88
jobs:
@@ -16,6 +16,7 @@ jobs:
1616
- uses: rhysd/changelog-from-release/action@v3
1717
with:
1818
file: CHANGELOG.md
19+
pull_request: true
1920
github_token: ${{ secrets.GITHUB_TOKEN }}
2021
commit_summary_template: 'update changelog for %s changes'
2122
args: -l 2

.github/workflows/ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Continuous Integration
2+
on: [push, pull_request]
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-20.04
7+
steps:
8+
- name: Checkout
9+
uses: actions/checkout@v3
10+
with:
11+
submodules: "recursive"
12+
13+
- name: Set up JDK environment
14+
uses: actions/setup-java@v3
15+
with:
16+
distribution: "zulu"
17+
java-version: 17
18+
19+
- name: Make gradlew executable
20+
run: chmod +x ./gradlew
21+
22+
- name: Setup Gradle
23+
uses: gradle/gradle-build-action@v2
24+
25+
- name: Run local unit tests
26+
run: bash ./gradlew test --stacktrace
27+
28+
build:
29+
runs-on: ubuntu-20.04
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
with:
34+
submodules: "recursive"
35+
36+
- name: Set up JDK environment
37+
uses: actions/setup-java@v3
38+
with:
39+
distribution: "zulu"
40+
java-version: 17
41+
42+
- name: Make gradlew executable
43+
run: chmod +x ./gradlew
44+
45+
- name: Setup Gradle
46+
uses: gradle/gradle-build-action@v2
47+
48+
- name: Run lint check
49+
run: bash ./gradlew lint
50+
51+
- name: Upload lint result
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: lint-results-debug
55+
path: app/build/reports/lint-results-debug.html
56+
57+
- name: Build the app
58+
run: bash ./gradlew build --stacktrace
59+
60+
- name: Build debug apk
61+
run: bash ./gradlew assembleDebug
62+
63+
- name: Upload debug apk
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: debug-apk
67+
path: app/build/outputs/apk/debug/*.apk

0 commit comments

Comments
 (0)