github wf: reduce emulator disk-size to 6G #662
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: ETA tests | |
| on: | |
| push: | |
| branches: | |
| - '*' | |
| - '!master' | |
| - '!l10n_master' | |
| tags: | |
| - '*' | |
| pull_request: | |
| branches: | |
| - 'master' | |
| env: | |
| GRADLE_COMMON_ARGS: | |
| # Emulator already has '-noaudio' option. But in logcat there are many such errors | |
| # W audio_hw_generic: Not supplying enough data to HAL, expected position 5964952 , only wrote 5964864 | |
| # This is trial to see if it removes these warnings | |
| QEMU_AUDIO_DRV: none | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # Fix timestamps | |
| - name: restore timestamps | |
| uses: chetan/git-restore-mtime-action@v2 | |
| # Since NDK & Cmake timestamps are used by ninja to determine if a target is up-to-date | |
| # and since installation of these files with SKD manager gives the files the timestamp of installation | |
| # We have to manually set a fixed timestamp accross all jobs | |
| - name: Check if we must use local Android NDK & CMAKE | |
| run: | | |
| set -x | |
| NDK_VERSION=$(grep "NDK_VERSION" app/gradle.properties | cut -d "=" -f 2) | |
| echo "NDK_VERSION=$NDK_VERSION" >> $GITHUB_ENV | |
| CMAKE_VERSION=$(grep "SDK_CMAKE_VERSION" app/gradle.properties | cut -d "=" -f 2) | |
| echo "CMAKE_VERSION=$CMAKE_VERSION" >> $GITHUB_ENV | |
| if [ ! -e $ANDROID_SDK_ROOT/ndk/$NDK_VERSION ]; then | |
| echo "ANDROID_NDK_IS_LOCAL_DOWNLOAD=1" >> $GITHUB_ENV | |
| fi | |
| if [ ! -e $ANDROID_SDK_ROOT/cmake/$CMAKE_VERSION ]; then | |
| echo "ANDROID_CMAKE_IS_LOCAL_DOWNLOAD=1" >> $GITHUB_ENV | |
| fi | |
| echo "done" | |
| - name: download some SDK components & touch with fixed date | |
| run: | | |
| set -x | |
| if [ "a$ANDROID_NDK_IS_LOCAL_DOWNLOAD" = "a1" ]; then | |
| $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "ndk;$NDK_VERSION" | |
| find $ANDROID_SDK_ROOT/ndk/$NDK_VERSION -exec touch -t 202301010000 '{}' \; | |
| fi | |
| if [ "a$ANDROID_CMAKE_IS_LOCAL_DOWNLOAD" = "a1" ]; then | |
| $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "cmake;$CMAKE_VERSION" | |
| find $ANDROID_SDK_ROOT/cmake/$CMAKE_VERSION -exec touch -t 202301010000 '{}' \; | |
| fi | |
| echo "done" | |
| - name: Display environment variables | |
| run: set | |
| - name: Create ninja wrapper | |
| if: ${{ env.ANDROID_CMAKE_IS_LOCAL_DOWNLOAD == 1 }} | |
| run: | | |
| set -x | |
| export NINJACMD=$ANDROID_SDK_ROOT/cmake/$CMAKE_VERSION/bin/ninja && | |
| mv "$NINJACMD" "$NINJACMD".orig && | |
| echo "#!/bin/sh" > "$NINJACMD" && | |
| #echo "$NINJACMD.orig -d explain -v \$@" >> "$NINJACMD" && | |
| echo "$NINJACMD.orig -v \$@" >> "$NINJACMD" && | |
| chmod +x "$NINJACMD" && | |
| touch -r "$NINJACMD".orig "$NINJACMD" && | |
| echo "content of "$NINJACMD"" && | |
| cat "$NINJACMD" && | |
| echo "done" | |
| # Switch to java 11 since AGP requires java 11 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Run build with Gradle wrapper | |
| run: > | |
| ./gradlew | |
| ${{ env.GRADLE_COMMON_ARGS }} | |
| assembleDebug | |
| assembleAndroidTest | |
| compileStandardDebugUnitTestSources | |
| compileStandardReleaseUnitTestSources | |
| compileDebugUnitTestSources | |
| compileReleaseUnitTestSources | |
| bundleLibRuntimeToJarDebug | |
| bundleLibRuntimeToJarRelease | |
| - uses: actions/cache/save@v4 | |
| id: cache | |
| with: | |
| path: | | |
| app/build/ | |
| app/.cxx/ | |
| version_last_tag.txt | |
| .gradle/ | |
| library/pixymeta-android/build/ | |
| library/Android-Exif-Extended/build/ | |
| library/pixymeta-android/build/ | |
| library/Android-Exif-Extended/build/ | |
| ~/.android/debug.keystore | |
| key: build-macos-${{ github.run_id }} | |
| - uses: actions/cache/save@v4 | |
| if: ${{ env.ANDROID_NDK_IS_LOCAL_DOWNLOAD == 1 }} | |
| id: cache-ndk | |
| with: | |
| path: | | |
| $ANDROID_HOME/ndk/${{ env.NDK_VERSION }}/ | |
| key: build-macos-localNdk-${{ github.run_id }} | |
| - uses: actions/cache/save@v4 | |
| if: ${{ env.ANDROID_CMAKE_IS_LOCAL_DOWNLOAD == 1 }} | |
| id: cache-cmake | |
| with: | |
| path: | | |
| $ANDROID_HOME/cmake/${{ env.CMAKE_VERSION }}/ | |
| key: build-macos-localCmake-${{ github.run_id }} | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: build-outputs-linux-run${{ github.run_attempt }} | |
| path: | | |
| version_last_tag.txt | |
| app/build/outputs/ | |
| buildWithPrebuiltLibs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| # Switch to java 11 since AGP requires java 11 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Run build with Gradle wrapper ('assembleRelease -PusePrebuiltLib=true') | |
| run: ./gradlew assembleRelease -PusePrebuiltLib=true ${{ env.GRADLE_COMMON_ARGS }} | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: build-outputs-linux-with-prebuilt-libs-run${{ github.run_attempt }} | |
| path: | | |
| version_last_tag.txt | |
| app/build/outputs/ | |
| buildWindows: | |
| runs-on: windows-latest | |
| needs: buildWithPrebuiltLibs | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| # Switch to java 11 since AGP requires java 11 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Run build with Gradle wrapper ('assembleDebug' task) | |
| run: ./gradlew assembleDebug ${{ env.GRADLE_COMMON_ARGS }} | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: build-outputs-windows-run${{ github.run_attempt }} | |
| path: | | |
| version_last_tag.txt | |
| app/build/outputs/ | |
| buildMacOS: | |
| runs-on: macos-latest | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| # Switch to java 11 since AGP requires java 11 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Run build with Gradle wrapper ('assembleDebug' task) | |
| run: ./gradlew assembleDebug ${{ env.GRADLE_COMMON_ARGS }} | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: build-outputs-macos-run${{ github.run_attempt }} | |
| path: | | |
| version_last_tag.txt | |
| app/build/outputs/ | |
| test: | |
| #continue-on-error: true | |
| env: | |
| with_avd_cache: false | |
| runs-on: ubuntu-latest | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| api-level: [26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36] | |
| #target: [default, google_apis] #Keep only 1 target until https://github.com/ReactiveCircus/android-emulator-runner/issues/278 is fixed | |
| target: [google_apis] | |
| include: | |
| - arch: x86 | |
| - ram-size: 3072M | |
| # Re-enable below when default target is enabled again | |
| # - api-level: 30 | |
| # target: default | |
| # arch: x86_64 | |
| - api-level: 30 | |
| arch: x86_64 | |
| - api-level: 31 | |
| arch: x86_64 | |
| - api-level: 32 | |
| arch: x86_64 | |
| - api-level: 33 | |
| arch: x86_64 | |
| - api-level: 34 | |
| arch: x86_64 | |
| - api-level: 35 | |
| arch: x86_64 | |
| - api-level: 36 | |
| arch: x86_64 | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # Fix timestamps | |
| - name: restore timestamps | |
| uses: chetan/git-restore-mtime-action@v2 | |
| # Get test pictures | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: 'ianare/exif-samples' | |
| path: 'tests/data/exif-samples' | |
| - name: | | |
| set timestamp of sample pictures to fixed date: 2021-07-01 09:18 | |
| run: find tests/data/exif-samples | xargs touch -t 202107010918 | |
| - name: Check if we must use local Android NDK & CMAKE | |
| run: | | |
| set -x | |
| NDK_VERSION=$(grep "NDK_VERSION" app/gradle.properties | cut -d "=" -f 2) | |
| echo "NDK_VERSION=$NDK_VERSION" >> $GITHUB_ENV | |
| CMAKE_VERSION=$(grep "SDK_CMAKE_VERSION" app/gradle.properties | cut -d "=" -f 2) | |
| echo "CMAKE_VERSION=$CMAKE_VERSION" >> $GITHUB_ENV | |
| if [ ! -e $ANDROID_SDK_ROOT/ndk/$NDK_VERSION ]; then | |
| echo "ANDROID_NDK_IS_LOCAL_DOWNLOAD=1" >> $GITHUB_ENV | |
| fi | |
| if [ ! -e $ANDROID_SDK_ROOT/cmake/$CMAKE_VERSION ]; then | |
| echo "ANDROID_CMAKE_IS_LOCAL_DOWNLOAD=1" >> $GITHUB_ENV | |
| fi | |
| echo "done" | |
| - name: Display environment variables | |
| run: set | |
| # Switch to java 11 since AGP requires java 11 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| app/build/ | |
| app/.cxx/ | |
| version_last_tag.txt | |
| .gradle/ | |
| library/pixymeta-android/build/ | |
| library/Android-Exif-Extended/build/ | |
| library/pixymeta-android/build/ | |
| library/Android-Exif-Extended/build/ | |
| ~/.android/debug.keystore | |
| key: build-macos-${{ github.run_id }} | |
| - uses: actions/cache/restore@v4 | |
| if: ${{ env.ANDROID_NDK_IS_LOCAL_DOWNLOAD == 1 }} | |
| id: cache-ndk | |
| with: | |
| path: | | |
| $ANDROID_HOME/ndk/${{ env.NDK_VERSION }}/ | |
| key: build-macos-localNdk-${{ github.run_id }} | |
| - uses: actions/cache/restore@v4 | |
| if: ${{ env.ANDROID_CMAKE_IS_LOCAL_DOWNLOAD == 1 }} | |
| id: cache-cmake | |
| with: | |
| path: | | |
| $ANDROID_HOME/cmake/${{ env.CMAKE_VERSION }}/ | |
| key: build-macos-localCmake-${{ github.run_id }} | |
| - name: AVD cache | |
| if: ${{ env.with_avd_cache == 'true' }} | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: avd-${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }} | |
| - name: Enable KVM | |
| 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: create AVD and generate snapshot for caching (${{ matrix.api-level }}, ${{ matrix.target }}, ${{ matrix.arch }}) | |
| if: ${{ env.with_avd_cache == 'true' && steps.avd-cache.outputs.cache-hit != 'true' }} | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| target: ${{ matrix.target }} | |
| arch: ${{ matrix.arch }} | |
| ram-size: ${{ matrix.ram-size }} | |
| profile: pixel_2 | |
| heap-size: 512M | |
| disk-size: 6G | |
| sdcard-path-or-size: 200M | |
| enable-hw-keyboard: true | |
| emulator-boot-timeout: 900 | |
| 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 tests with avd cache (${{ matrix.api-level }}, ${{ matrix.target }}, ${{ matrix.arch }}) | |
| id: test_with_cache | |
| if: ${{ env.with_avd_cache == 'true' }} | |
| timeout-minutes: 240 | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| target: ${{ matrix.target }} | |
| arch: ${{ matrix.arch }} | |
| ram-size: ${{ matrix.ram-size }} | |
| profile: pixel_2 | |
| heap-size: 512M | |
| disk-size: 6G | |
| sdcard-path-or-size: 200M | |
| enable-hw-keyboard: true | |
| emulator-boot-timeout: 900 | |
| 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: API_LEVEL=${{ matrix.api-level }} fastlane connectedCheck_with_screenrecord | |
| - name: run tests without avd cache (${{ matrix.api-level }}, ${{ matrix.target }}, ${{ matrix.arch }}) | |
| id: test_without_cache | |
| if: ${{ env.with_avd_cache != 'true' }} | |
| timeout-minutes: 240 | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| target: ${{ matrix.target }} | |
| arch: ${{ matrix.arch }} | |
| ram-size: ${{ matrix.ram-size }} | |
| profile: pixel_2 | |
| heap-size: 512M | |
| disk-size: 6G | |
| sdcard-path-or-size: 200M | |
| enable-hw-keyboard: true | |
| emulator-boot-timeout: 900 | |
| script: API_LEVEL=${{ matrix.api-level }} fastlane connectedCheck_with_screenrecord | |
| # Get test output if nothing was downloaded from device. Typically, if the step has hit timeout | |
| - name: Get test output | |
| if: always() && (steps.test_with_cache.outcome == 'failure' || steps.test_without_cache.outcome == 'failure' || steps.test_with_cache.outcome == 'cancelled' || steps.test_without_cache.outcome == 'cancelled') | |
| run: | | |
| set -x | |
| echo "Outcome of 'test_with_cache' ${{ steps.test_with_cache.outcome }}" | |
| echo "Outcome of 'test_without_cache' ${{ steps.test_without_cache.outcome }}" | |
| if [ ! -d tests/output ] || [ -f tests/output/get_output_of_tests-started-not-completed ]; then | |
| sync | |
| # This requires a running emulator instance. | |
| # but the instance of the previous step is not reachable inside this step. | |
| # TODO | |
| #/usr/bin/sh -c \/usr/local/lib/android/sdk/emulator/emulator -port 5554 -avd test -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim & | |
| #fastlane wait_for_idle | |
| #fastlane get_output_of_tests | |
| #adb shell logcat -d > tests/output/screenrecords/0_final_logcat.txt | |
| else | |
| echo "tests/output exists." | |
| echo "Content:" | |
| ls tests/output | |
| fi | |
| # Check for some pattern in logcat | |
| - name: Check for some pattern in logcat | |
| continue-on-error: true | |
| if: always() | |
| run: | | |
| set -x | |
| cd tests && ./check_logcat_match.sh | |
| # actions/upload-artifact@v3 doesn't keep timestamps, so use tar as an intermediate | |
| # Moreover, by using this intermediate file, the files created by the test suite won't be inside the artifact | |
| - name: Tar tests/output artifacts | |
| if: always() | |
| run: tar -cf test_output_artifact.tar --exclude="tests/output/screenrecords" tests/output/ | |
| - name: Install tools for bash tests | |
| id: install_test_tools | |
| #if: ${{ false }} # Don't run them for now because locally I use the perl version of findimagedupes which is different | |
| if: always() | |
| run: | | |
| set -x | |
| #set | |
| #echo HOME=$HOME | |
| # The findimagedupes package in ubuntu-jammy show warnings. So use the one from ppa:bastif/findimagedupes | |
| # 'Use of uninitialized value in concatenation (.) or string at /usr/lib/x86_64-linux-gnu/perl5/5.34/findimagedupes/C.pm line 4.' | |
| if [ $(lsb_release -cs) = "jammy" ]; then | |
| sudo add-apt-repository ppa:bastif/findimagedupes | |
| sudo apt update | |
| fi | |
| sudo apt-get -y install exiv2 exiftool imagemagick findimagedupes | |
| - name: Run bash tests | |
| if: always() && steps.install_test_tools.outcome == 'success' | |
| continue-on-error: true | |
| run: | | |
| # run tests | |
| set -x | |
| cd tests && ./run_tests.sh || true | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-api${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }}-run${{ github.run_attempt }}-reports | |
| path: | | |
| version_last_tag.txt | |
| app/build/reports/ | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-api${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }}-run${{ github.run_attempt }}-screenrecords | |
| path: | | |
| version_last_tag.txt | |
| tests/output/screenrecords/ | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-api${{ matrix.api-level }}-${{ matrix.target }}-${{ matrix.arch }}-run${{ github.run_attempt }}-output | |
| path: | | |
| test_output_artifact.tar | |
| # From: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries | |
| cleanup-cache: | |
| runs-on: ubuntu-latest | |
| #if: ${{ always() }} # If tests failed, we don't want to remove the build cache in case we want to rerun the failed tests | |
| needs: test | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Cleanup | |
| run: | | |
| gh extension install actions/gh-actions-cache | |
| REPO=${{ github.repository }} | |
| BRANCH=${{ github.ref_name }} | |
| for cachePrefix in build-macos build-macos-localNdk build-macos-localCmake; do | |
| echo "Fetching list of cache key" | |
| #cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 ) | |
| cacheKeysForPR=$cachePrefix-${{ github.run_id }} | |
| ## Setting this to not fail the workflow while deleting cache keys. | |
| set +e | |
| echo "Deleting caches..." | |
| for cacheKey in $cacheKeysForPR | |
| do | |
| gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm | |
| done | |
| done | |
| echo "Done" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |