Skip to content

Commit

Permalink
Merge pull request #25 from SecUSo/update-workflow
Browse files Browse the repository at this point in the history
Update workflow and fix dependencies
  • Loading branch information
coderPaddyS authored Jun 21, 2024
2 parents 9afa653 + 687e8cf commit 69467d8
Show file tree
Hide file tree
Showing 30 changed files with 178 additions and 1,182 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/android-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Android Emulator Tests
on: [ push, pull_request ]

jobs:
check-if-tests-exist:
runs-on: ubuntu-latest
outputs:
status: ${{ steps.check-androidTest.outputs.NOT_EMPTY }}
min-sdk-version: ${{ steps.get-sdk-version.outputs.MIN_SDK_VERSION }}
target-sdk-version: ${{ steps.get-sdk-version.outputs.TARGET_SDK_VERSION }}
app-id: ${{ steps.get-app-id.outputs.APP_ID }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Check if androidTest folder is not empty
run: |
echo "NOT_EMPTY=$([ "$(ls -A BackupApp/src/androidTest)" ] && echo 'true' || echo 'false')"
echo "NOT_EMPTY=$([ "$(ls -A BackupApp/src/androidTest)" ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
id: check-androidTest
- name: Get min and target sdk
if: steps.check-androidTest.outputs.NOT_EMPTY == 'true'
id: get-sdk-version
run: |
echo "MIN_SDK_VERSION=$(cat BackupApp/build.gradle | grep minSdkVersion | rev | cut -d' ' -f 1 | rev)" >> $GITHUB_OUTPUT
echo "TARGET_SDK_VERSION=$(cat BackupApp/build.gradle | grep targetSdkVersion | rev | cut -d' ' -f 1 | rev)" >> $GITHUB_OUTPUT
- name: Get app ID
id: get-app-id
run: |
echo "APP_ID=$(cat BackupApp/build.gradle | grep applicationId | rev | cut -d' ' -f 1 | rev | tr -d '"')" >> $GITHUB_OUTPUT
test:
needs: check-if-tests-exist
if: needs.check-if-tests-exist.outputs.status == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [34, "${{ needs.check-if-tests-exist.outputs.min-sdk-version }}", "${{ needs.check-if-tests-exist.outputs.target-sdk-version }}"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'recursive'

- 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
- name: Gradle cache
uses: gradle/gradle-build-action@v3

- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}

- name: Set up JDK environment
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.api-level >= 30 && 'google_apis' || 'default' }}
arch: ${{ matrix.api-level < 21 && 'x86' || 'x86_64' }}
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: Run connected tests
uses: ReactiveCircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.api-level >= 30 && 'google_apis' || 'default' }}
arch: ${{ matrix.api-level < 21 && 'x86' || 'x86_64' }}
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: |
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}} || true
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}}.test || true
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}}.androidTest || true
./gradlew :BackupApp:connectedCheck --stacktrace
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}} || true
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}}.test || true
adb uninstall ${{needs.check-if-tests-exist.outputs.app-id}}.androidTest || true
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Continuous Integration
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"

- name: Set up JDK environment
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: 17

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Run local unit tests
run: bash ./gradlew test --stacktrace

build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"

- name: Set up JDK environment
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: 17

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Build the app
run: bash ./gradlew build --stacktrace
53 changes: 0 additions & 53 deletions .github/workflows/main.yml

This file was deleted.

8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.idea/
misc.xml
.DS_Store
/build
/captures
Expand Down
122 changes: 0 additions & 122 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/gradle.xml

This file was deleted.

Loading

0 comments on commit 69467d8

Please sign in to comment.