Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Dropshots and edge-to-edge tests #1459

Draft
wants to merge 71 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
9a6d415
Adds Dropshots and edge-to-edge tests
JoseAlcerreca May 21, 2024
9b7317d
CI and temporary (?) fix in 26
JoseAlcerreca May 21, 2024
9d8a8e2
CI
JoseAlcerreca May 21, 2024
cf9e35c
CI
JoseAlcerreca May 22, 2024
a5798a6
CI: enable AVD snapshot
JoseAlcerreca May 22, 2024
bfa05cb
Workaround for emulator bug
JoseAlcerreca May 23, 2024
8a37013
Changes api levels
JoseAlcerreca May 23, 2024
08ed42e
Changes api levels
JoseAlcerreca May 23, 2024
3b398fb
Problems running emulators twice
JoseAlcerreca May 23, 2024
79aaf62
trying random stuff at this point
JoseAlcerreca May 23, 2024
751a276
Now exit with a failure if there are new screenshots
JoseAlcerreca May 23, 2024
82f79d3
Trying harder to exit with a failure
JoseAlcerreca May 23, 2024
4508e8f
Pulls before pushing
JoseAlcerreca May 23, 2024
2307747
Not sure if this is going to do what I want to do
JoseAlcerreca May 23, 2024
b2d0e0d
Adds foldable tests and CI changes
JoseAlcerreca May 24, 2024
62b26ed
Spotless and disables V
JoseAlcerreca May 24, 2024
9531cfb
CI fixes
JoseAlcerreca May 24, 2024
d9b0489
Force newest cmdline tools version on CI
JoseAlcerreca May 24, 2024
8444676
Trying > for multiple lines
JoseAlcerreca May 24, 2024
194ed55
Adding build tools 35 RC before running emulator
JoseAlcerreca May 24, 2024
ee98f10
Using old path
JoseAlcerreca May 24, 2024
2b19bd8
Adds emulator build to hopefully access pixel_fold
JoseAlcerreca May 24, 2024
9e9e7b4
Trying canary channel with low hopes
JoseAlcerreca May 24, 2024
18ac89d
Trying without full path
JoseAlcerreca May 25, 2024
c5e7809
CI
JoseAlcerreca May 25, 2024
369671b
Bump to cmdline tools 11479570
JoseAlcerreca May 25, 2024
1c499e5
Replacing cmdline-tools/latest
JoseAlcerreca May 25, 2024
cb117c2
Let android-emulator-runner install rest of the tools
JoseAlcerreca May 25, 2024
917cfd2
More debug prints
JoseAlcerreca May 27, 2024
ffcb0b9
More debug prints
JoseAlcerreca May 27, 2024
de56d8f
More debug prints
JoseAlcerreca May 27, 2024
e5fdcac
Sets path to /latest
JoseAlcerreca May 27, 2024
a348f1a
Sets path to /latest
JoseAlcerreca May 27, 2024
4c324f4
I don't understand halp
JoseAlcerreca May 27, 2024
b81ebd2
Now using right sdkmanager but More debug
JoseAlcerreca May 27, 2024
8e5153a
Creates avd directory before downloading stuff
JoseAlcerreca May 27, 2024
94df4d9
Fixes api 27 tests and removes debug stuff
JoseAlcerreca May 27, 2024
bf82765
Simplifies edge to edge tests
JoseAlcerreca May 27, 2024
9a43621
CI experiment
JoseAlcerreca May 27, 2024
62cf6ce
CI experiment
JoseAlcerreca May 27, 2024
13aedf4
CI experiment
JoseAlcerreca May 27, 2024
784f94c
CI experiment
JoseAlcerreca May 27, 2024
ece2356
CI experiment
JoseAlcerreca May 27, 2024
3abab25
CI experiment
JoseAlcerreca May 27, 2024
848ab7b
CI experiment
JoseAlcerreca May 27, 2024
60242d1
No idea what's going on
JoseAlcerreca May 27, 2024
d4093a5
Simplify if clause
JoseAlcerreca May 28, 2024
4c79213
The action does some script parsing that is breaking the if clause, l…
JoseAlcerreca May 28, 2024
ee7556f
Script in single line
JoseAlcerreca May 28, 2024
ad5dc1b
Pixel fold is google_apis
JoseAlcerreca May 28, 2024
1160b88
Adds target
JoseAlcerreca May 28, 2024
0005c1b
no google_apis for api 27
JoseAlcerreca May 28, 2024
fde23a4
There is a flaky test but the step should not pass
JoseAlcerreca May 28, 2024
8ff1ac5
Now we can comment out the flaky test
JoseAlcerreca May 28, 2024
d75d4f0
Removes espresso device
JoseAlcerreca May 28, 2024
5ddcba5
Restrict screenshot tests to :app
JoseAlcerreca May 28, 2024
96dd9dc
Weird emulator issues, joy
JoseAlcerreca May 30, 2024
175bb21
Trying again with two emulator steps
JoseAlcerreca May 31, 2024
b4f9e0d
Trying again with two emulator steps
JoseAlcerreca May 31, 2024
39c1bb4
Debug hell
JoseAlcerreca May 31, 2024
dee3bdb
Debug hell
JoseAlcerreca May 31, 2024
f8f80e8
Debug hell
JoseAlcerreca May 31, 2024
b2ad870
Debug hell
JoseAlcerreca May 31, 2024
d16ed17
Debug hell
JoseAlcerreca May 31, 2024
2b28127
Runner hangs when launching emulator for the second time, trying new …
JoseAlcerreca Jun 3, 2024
19edb84
SHAME! I added an infinite loop
JoseAlcerreca Jun 5, 2024
2323822
Fixed! Except for API 35, uploading logcat
JoseAlcerreca Jun 5, 2024
e26492a
Cutout tests, working locally. Need to rebase
JoseAlcerreca Jun 5, 2024
0191ba0
Some more sync points, api 35 emulator crashing
JoseAlcerreca Jun 6, 2024
a61e467
🤖 Updates instrumented screenshots. API 27
JoseAlcerreca Jun 6, 2024
8fe9142
🤖 Updates instrumented screenshots. API 33
JoseAlcerreca Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/ci-gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
#

org.gradle.daemon=false
org.gradle.parallel=true
org.gradle.workers.max=2

org.gradle.jvmargs=-Xmx8g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g
kotlin.incremental=false

# Controls KotlinOptions.allWarningsAsErrors.
Expand Down
144 changes: 144 additions & 0 deletions .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,147 @@ 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
target: default
- api-level: 33
profile: pixel_fold
target: google_apis
# TODO: change from VanillaIceCream to 35 when that image is available
- api-level: VanillaIceCream
profile: pixel_fold
target: google_apis

steps:
- name: Delete unnecessary tools 🔧
uses: jlumbroso/free-disk-space@v1.3.1
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: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17

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

# TODO this workflow needs cmdline-tools 13.0 (for pixel_fold). Remove when not necessary.
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 11479570

# android-emulator-runner uses /latest
- name: Replace cmdlinetools and set path
run: |
rm -rf ${{ env.ANDROID_HOME}}/cmdline-tools/latest
mv ${{ env.ANDROID_HOME}}/cmdline-tools/11479570 ${{ env.ANDROID_HOME}}/cmdline-tools/latest
echo ${{ env.ANDROID_HOME}}/cmdline-tools/latest/bin >> $GITHUB_PATH

# https://github.com/ReactiveCircus/android-emulator-runner/issues/197
- name: Create directory for AVD
run: mkdir -p /home/runner/.android/avd

- name: Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@v2
with:
comment_on_pr: false

- name: Build projects and run instrumented screenshot tests
id: dropshotsverify
continue-on-error: true
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
disable-animations: true
disk-size: 6000M
emulator-build: 11834374 # 34.2.14
heap-size: 600M
profile: ${{ matrix.profile }}
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script:
adb logcat > logcat.log & ./gradlew :app:connectedDemoDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.google.samples.apps.nowinandroid.ui.InstrumentedScreenshotTests --daemon

- name: Upload logcat
if: always()
uses: actions/upload-artifact@v4
with:
name: logcat-${{ matrix.profile }}-${{ matrix.api-level }}
path: logcat.log

- name: Prevent pushing new screenshots if this is a fork
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 screenshots if verification failed
id: dropshotsrecord
continue-on-error: false
if: steps.dropshotsverify.outcome == 'failure'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
disable-animations: true
disk-size: 6000M
emulator-build: 11834374 # 34.2.14
heap-size: 600M
profile: ${{ matrix.profile }}
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script:
./gradlew :app:connectedDemoDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.google.samples.apps.nowinandroid.ui.InstrumentedScreenshotTests -Pdropshots.record --daemon --stacktrace


- name: Checkout new changes (in case another job already uploaded screenshots)
uses: actions/checkout@v4
# if: steps.dropshotsverify.outputs.newgoldens == 'true'
with:
clean: false

- name: Push new device screenshots if available
uses: stefanzweifel/git-auto-commit-action@4b8a201e31cadd9829df349894b28c54e6c19fe6
# if: steps.dropshotsverify.outputs.newgoldens == 'true'
with:
file_pattern: 'app/src/androidTest/screenshots/*.png'
disable_globbing: true
commit_message: "🤖 Updates instrumented screenshots. API ${{ matrix.api-level }}"

- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.profile }}-${{ matrix.api-level }}
path: '**/build/reports/androidTests'

7 changes: 7 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ android {
unitTests {
isIncludeAndroidResources = true
}
// Espresso Device
emulatorControl {
enable = true
}
}
namespace = "com.google.samples.apps.nowinandroid"
}
Expand Down Expand Up @@ -126,9 +130,12 @@ dependencies {
androidTestImplementation(projects.core.dataTest)
androidTestImplementation(projects.core.datastoreTest)
androidTestImplementation(libs.androidx.test.espresso.core)
androidTestImplementation(libs.androidx.test.core)
androidTestImplementation(libs.androidx.navigation.testing)
androidTestImplementation(libs.androidx.compose.ui.test)
androidTestImplementation(libs.hilt.android.testing)
androidTestImplementation(libs.androidx.test.espresso.device)
androidTestImplementation(libs.androidx.test.uiautomator)

baselineProfile(projects.benchmarks)
}
Expand Down
Loading