Potential fix for code scanning alert no. 2: Workflow does not contain permissions #1183
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Android Test | |
| permissions: | |
| contents: read | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| android_test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| api-level: [23] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 0 | |
| - name: set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: 17 | |
| - name: Make gradlew executable | |
| run: chmod +x gradlew | |
| - 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 | |
| - uses: gradle/actions/setup-gradle@v3 | |
| - name: Run Tests | |
| id: testing | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| continue-on-error: true | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| arch: ${{ matrix.api-level == 23 && 'x86' || 'x86_64' }} | |
| emulator-options: -no-snapshot -no-window -no-boot-anim -camera-back emulated -camera-front emulated -gpu swiftshader_indirect | |
| script: | | |
| adb logcat -c | |
| touch app/emulator.log | |
| chmod 777 app/emulator.log | |
| adb logcat >> app/emulator.log & | |
| ./gradlew connectedCheck | |
| env: | |
| API_LEVEL: ${{ matrix.api-level }} | |
| - name: Upload Test Results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: logs | |
| path: app/emulator.log | |
| - name: Raise error on test failure | |
| if: steps.testing.outcome != 'success' | |
| run: exit 1 |