Android Instrumented Tests #9145
Workflow file for this run
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 Instrumented Tests" | |
| on: | |
| merge_group: | |
| pull_request: | |
| types: [ opened, synchronize ] # Don't rerun on `edited` to save time | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_sha }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read # required for actions/checkout and repository metadata reads | |
| jobs: | |
| detekt: | |
| name: Detekt | |
| uses: ./.github/workflows/codestyle.yml | |
| gradle-run-tests: | |
| name: Gradle Run Tests | |
| needs: [ detekt ] | |
| permissions: | |
| contents: read # required to read repository metadata in private repositories | |
| issues: read # required to find related pull requests in private repositories | |
| checks: write # required to publish unit test check runs | |
| pull-requests: write # required to publish pull request comments | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| api-level: [ 31 ] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| # trying https://github.com/actions/runner-images/issues/10386#issuecomment-2271613335 | |
| - name: Free Disk Space Before Build | |
| run: | | |
| echo "Disk space before cleanup:" | |
| df -h | |
| sudo rm -rf /usr/local/.ghcup | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| sudo rm -rf /usr/local/lib/android/sdk/ndk | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /usr/local/share/boost | |
| sudo apt-get clean | |
| echo "Disk space after cleanup:" | |
| df -h | |
| - name: Setup Java and Gradle | |
| uses: ./.github/actions/setup-java-gradle | |
| # - name: AVD cache | |
| # - name: AVD cache | |
| # uses: actions/cache@v4 | |
| # id: avd-cache | |
| # with: | |
| # path: | | |
| # ~/.android/avd/* | |
| # ~/.android/adb* | |
| # key: avd-${{ matrix.api-level }} | |
| # | |
| # - name: Create AVD and generate snapshot for caching | |
| # if: steps.avd-cache.outputs.cache-hit != 'true' | |
| # uses: reactivecircus/android-emulator-runner@v2.31.0 | |
| # env: | |
| # GITHUB_USER: ${{ github.actor }} | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # with: | |
| # api-level: ${{ matrix.api-level }} | |
| # force-avd-creation: false | |
| # target: aosp_atd | |
| # arch: x86_64 | |
| # emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| # cores: 4 | |
| # ram-size: 4096M | |
| # heap-size: 2048M | |
| # disable-animations: false | |
| # script: echo "Generated AVD snapshot for caching." | |
| # API 30+ emulators only have x86_64 system images. | |
| - name: Get AVD info | |
| uses: ./.github/actions/get-avd-info | |
| id: avd-info | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| - 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: Android Instrumentation Tests | |
| uses: reactivecircus/android-emulator-runner@0a638108440efd5c7f980e6ba145dbcdd8f32009 | |
| env: | |
| GITHUB_USER: ${{ github.actor }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| arch: ${{ steps.avd-info.outputs.arch }} | |
| target: ${{ steps.avd-info.outputs.target }} | |
| cores: 4 | |
| ram-size: 4096M | |
| heap-size: 2048M | |
| disable-animations: true | |
| script: ./gradlew connectedAndroidOnlyAffectedTest | |
| - name: Archive Test Reports | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: test-reports | |
| path: | | |
| ./**/build/reports/tests/** | |
| ./**/build/reports/androidTests/** | |
| - name: Archive Test Results | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: test-results | |
| path: | | |
| ./**/build/test-results/**/*.xml | |
| ./**/build/outputs/androidTest-results/**/*.xml | |
| - name: Publish Unit Test Results | |
| uses: EnricoMi/publish-unit-test-result-action/linux@c950f6fb443cb5af20a377fd0dfaa78838901040 | |
| if: ${{ always() }} | |
| with: | |
| files: | | |
| **/build/test-results/**/*.xml | |
| **/build/outputs/androidTest-results/**/*.xml | |
| - name: Cleanup Gradle Cache | |
| # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. | |
| # Restoring these files from a GitHub Actions cache might cause problems for future builds. | |
| run: | | |
| rm -f ~/.gradle/caches/modules-2/modules-2.lock | |
| rm -f ~/.gradle/caches/modules-2/gc.properties | |
| upload-test-results-datadadog: | |
| name: Upload Test Results Datadadog | |
| runs-on: ubuntu-latest | |
| needs: gradle-run-tests | |
| if: always() | |
| steps: | |
| - name: Download tests results | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| continue-on-error: true | |
| with: | |
| name: test-results | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e | |
| with: | |
| node-version: 18 | |
| - name: Install datadog-ci | |
| run: | | |
| npm install -g @datadog/datadog-ci | |
| - name: "Upload results" | |
| env: | |
| DATADOG_API_KEY: ${{ secrets.DD_API_KEY }} | |
| DD_ENV: ci | |
| DATADOG_SITE: datadoghq.eu | |
| run: | | |
| find . -name "*.xml" -type f | sed 's/ /\\ /g' | tr '\n' ' ' | xargs -L 1 datadog-ci junit upload --service kalium-android . |