Skip to content

Commit 8605fee

Browse files
authored
Merge pull request #14 from SecUSo/update-workflow
Update workflows
2 parents 8195879 + 486cedb commit 8605fee

File tree

3 files changed

+81
-14
lines changed

3 files changed

+81
-14
lines changed

.github/workflows/android-test.yml

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: Android Emulator Tests
2-
on: [push, pull_request]
2+
on: [ push, pull_request ]
33

44
jobs:
55
check-if-tests-exist:
66
runs-on: ubuntu-latest
77
outputs:
88
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 }}
912
steps:
1013
- name: Checkout
1114
uses: actions/checkout@v3
@@ -16,36 +19,81 @@ jobs:
1619
echo "NOT_EMPTY=$([ "$(ls -A BackupAPI/src/androidTest)" ] && echo 'true' || echo 'false')"
1720
echo "NOT_EMPTY=$([ "$(ls -A BackupAPI/src/androidTest)" ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
1821
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 BackupAPI/build.gradle | grep minSdkVersion | rev | cut -d' ' -f 1 | rev)" >> $GITHUB_OUTPUT
27+
echo "TARGET_SDK_VERSION=$(cat BackupAPI/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 BackupAPI/build.gradle | grep applicationId | rev | cut -d' ' -f 1 | rev | tr -d '"')" >> $GITHUB_OUTPUT
32+
1933
test:
2034
needs: check-if-tests-exist
2135
if: needs.check-if-tests-exist.outputs.status == 'true'
22-
runs-on: macos-latest
36+
runs-on: ubuntu-latest
2337
strategy:
2438
matrix:
25-
api-level: [29]
26-
target: [default]
27-
arch: [x86_64]
39+
api-level: [34, "${{ needs.check-if-tests-exist.outputs.min-sdk-version }}", "${{ needs.check-if-tests-exist.outputs.target-sdk-version }}"]
2840
steps:
2941
- name: Checkout
3042
uses: actions/checkout@v3
3143
with:
32-
submodules: "recursive"
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 }}
3363

3464
- name: Set up JDK environment
3565
uses: actions/setup-java@v3
3666
with:
37-
distribution: "zulu"
67+
distribution: 'zulu'
3868
java-version: 17
3969

40-
- name: Gradle cache
41-
uses: gradle/gradle-build-action@v2
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."
4281

4382
- name: Run connected tests
4483
uses: ReactiveCircus/android-emulator-runner@v2
4584
with:
4685
api-level: ${{ matrix.api-level }}
47-
target: ${{ matrix.target }}
48-
arch: ${{ matrix.arch }}
49-
profile: Nexus 6
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
5090
disable-animations: true
51-
script: bash ./gradlew :BackupAPI:connectedCheck --stacktrace
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 :BackupAPI: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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,23 @@ jobs:
4545
- name: Setup Gradle
4646
uses: gradle/gradle-build-action@v2
4747

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: BackupAPI/build/reports/lint-results-debug.html
56+
4857
- name: Build the app
4958
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: BackupAPI/build/outputs/apk/debug/*.apk

0 commit comments

Comments
 (0)