-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: Ie0a37f53046a3219f6ea9ae4deccacb48e531fe9
- Loading branch information
1 parent
7fd5d47
commit a14b142
Showing
7 changed files
with
230 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,7 +153,7 @@ jobs: | |
timeout-minutes: 55 | ||
strategy: | ||
matrix: | ||
api-level: [27, 31] | ||
api-level: [26, 30] | ||
|
||
steps: | ||
- name: Delete unnecessary tools 🔧 | ||
|
@@ -189,56 +189,15 @@ jobs: | |
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v3 | ||
|
||
- name: Build projects and run instrumentation tests including screenshots | ||
id: dropshotsverify | ||
continue-on-error: true | ||
- name: Build projects and run instrumentation tests | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: ${{ matrix.api-level }} | ||
arch: x86_64 | ||
disable-animations: true | ||
disk-size: 6000M | ||
heap-size: 600M | ||
profile: pixel_5 | ||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
# Run tests, if they fail, record screenshots and exit with a failure | ||
script: ./gradlew connectedDemoDebugAndroidTest --daemon || echo "Recording new screenshots" ; ./gradlew connectedDemoDebugAndroidTest -Pdropshots.record --daemon --stacktrace ; echo "Done recording new screenshots, exiting with failure" ; exit 5 | ||
|
||
- name: Prevent pushing new screenshots if this is a fork (instrumented) | ||
id: checkfork_screenshots_instrumented | ||
continue-on-error: false | ||
if: steps.dropshotsverify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository | ||
run: | | ||
echo "::error::Instrumented screenshot tests failed, please create a PR in your fork first." && exit 1 | ||
# | ||
# - name: Record new instrumented screenshots | ||
# id: screenshotsrecordinstrumented | ||
# if: steps.dropshotsverify.outcome == 'failure' && github.event_name == 'pull_request' | ||
# uses: reactivecircus/android-emulator-runner@v2 | ||
# with: | ||
# api-level: ${{ matrix.api-level }} | ||
# arch: x86_64 | ||
# disable-animations: true | ||
# disk-size: 6000M | ||
# heap-size: 600M | ||
# profile: pixel_5 | ||
# force-avd-creation: false | ||
# emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
# script: adb shell rm -rf /storage/emulated/0/Download/screenshots && ./gradlew connectedDemoDebugAndroidTest -Pdropshots.record --stacktrace | ||
|
||
- name: Checkout new changes (in case another job already uploaded screenshots) | ||
uses: actions/checkout@v4 | ||
with: | ||
clean: false | ||
|
||
- name: Push new device screenshots if available | ||
uses: stefanzweifel/git-auto-commit-action@4b8a201e31cadd9829df349894b28c54e6c19fe6 | ||
if: steps.dropshotsverify.outcome == 'failure' | ||
with: | ||
file_pattern: 'app/src/androidTest/screenshots/*.png' | ||
disable_globbing: true | ||
commit_message: "🤖 Updates instrumented screenshots. API ${{ matrix.api-level }}" | ||
script: ./gradlew connectedDemoDebugAndroidTest --daemon | ||
|
||
- name: Run local tests (including Roborazzi) for the combined coverage report (only API 30) | ||
if: matrix.api-level == 30 | ||
|
@@ -278,3 +237,91 @@ jobs: | |
compression-level: 1 | ||
overwrite: false | ||
path: '**/build/reports/jacoco/' | ||
|
||
|
||
androidTestScreenshots: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 55 | ||
strategy: | ||
matrix: | ||
include: | ||
- api-level: 27 | ||
profile: pixel_5 | ||
- api-level: 33 | ||
profile: pixel_fold | ||
- api-level: "VanillaIceCream" | ||
profile: pixel_fold | ||
|
||
steps: | ||
- name: Delete unnecessary tools 🔧 | ||
uses: jlumbroso/[email protected] | ||
with: | ||
android: false # Don't remove Android tools | ||
tool-cache: true # Remove image tool cache - rm -rf "$AGENT_TOOLSDIRECTORY" | ||
dotnet: true # rm -rf /usr/share/dotnet | ||
haskell: true # rm -rf /opt/ghc... | ||
swap-storage: true # rm -f /mnt/swapfile (4GiB) | ||
docker-images: false # Takes 16s, enable if needed in the future | ||
large-packages: false # includes google-cloud-sdk and it's slow | ||
|
||
- 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 | ||
ls /dev/kvm | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Copy CI gradle.properties | ||
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'zulu' | ||
java-version: 17 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v3 | ||
|
||
- name: Build projects and run instrumentation tests including screenshots | ||
id: dropshotsverify | ||
continue-on-error: true | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: ${{ matrix.api-level }} | ||
arch: x86_64 | ||
disable-animations: true | ||
disk-size: 6000M | ||
heap-size: 600M | ||
profile: pixel_5 | ||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
# Run tests, if they fail, record screenshots and exit with a failure | ||
script: | | ||
./gradlew connectedDemoDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.google.samples.apps.nowinandroid.ui.InstrumentedScreenshotTests --daemon | ||
|| echo "Recording new screenshots" | ||
; ./gradlew connectedDemoDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.google.samples.apps.nowinandroid.ui.InstrumentedScreenshotTests -Pdropshots.record --daemon --stacktrace | ||
; echo "Done recording new screenshots, exiting with failure" | ||
; exit 5 | ||
- name: Prevent pushing new screenshots if this is a fork (instrumented) | ||
id: checkfork_screenshots_instrumented | ||
continue-on-error: false | ||
if: steps.dropshotsverify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository | ||
run: | | ||
echo "::error::Instrumented screenshot tests failed, please create a PR in your fork first." && exit 1 | ||
- name: Checkout new changes (in case another job already uploaded screenshots) | ||
uses: actions/checkout@v4 | ||
with: | ||
clean: false | ||
|
||
- name: Push new device screenshots if available | ||
uses: stefanzweifel/git-auto-commit-action@4b8a201e31cadd9829df349894b28c54e6c19fe6 | ||
if: steps.dropshotsverify.outcome == 'failure' | ||
with: | ||
file_pattern: 'app/src/androidTest/screenshots/*.png' | ||
disable_globbing: true | ||
commit_message: "🤖 Updates instrumented screenshots. API ${{ matrix.api-level }}" |
This file contains 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
This file contains 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
22 changes: 22 additions & 0 deletions
22
...androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/InstrumentedScreenshotTests.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.samples.apps.nowinandroid.ui | ||
|
||
/** | ||
* TODO: Move to a test module. | ||
*/ | ||
annotation class InstrumentedScreenshotTests |
This file contains 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
This file contains 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
This file contains 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