Skip to content

Commit fc2c491

Browse files
authored
Install Roborazzi (#116)
* Install roborazzi * Add screenshot tests * Add workflows for screenshot tests * Fix workflows * Add roborazzi options in gradle.properties * Simplify workflows * Remove unused workflow * Improve screenshot tests * Improve screenshot tests * Fix spotless
1 parent 2171bb9 commit fc2c491

File tree

223 files changed

+1167
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+1167
-7
lines changed

.github/workflows/build.yaml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,43 @@ jobs:
5454
if: always()
5555
run: release/signing-cleanup.sh
5656

57-
test:
57+
screenshot-test:
5858
needs: build
5959
runs-on: ubuntu-latest
6060
timeout-minutes: 30
6161

62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: Copy CI gradle.properties
66+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
67+
68+
- name: Setup java
69+
uses: actions/setup-java@v4
70+
with:
71+
distribution: 'zulu'
72+
java-version: 17
73+
74+
- name: Setup Gradle
75+
uses: gradle/actions/setup-gradle@v4
76+
77+
- name: Build tests & Create screenshots
78+
run: ./gradlew verifyRoborazziDebug --stacktrace
79+
80+
- name: Upload test results
81+
uses: actions/upload-artifact@v4
82+
if: always()
83+
with:
84+
name: screenshot-test-results
85+
path: |
86+
**/build/reports/*
87+
**/build/outputs/roborazzi
88+
89+
instrumented-test:
90+
needs: [build, screenshot-test]
91+
runs-on: ubuntu-latest
92+
timeout-minutes: 30
93+
6294
strategy:
6395
matrix:
6496
# Disable 21-23 for now as the devices seem to be flakey on CI
@@ -128,7 +160,7 @@ jobs:
128160
if: always()
129161
uses: actions/upload-artifact@v4
130162
with:
131-
name: test-results-${{ matrix.api-level }}
163+
name: instrumented-test-results-${{ matrix.api-level }}
132164
path: |
133165
**/build/reports/*
134166
**/build/outputs/*/connected/*
@@ -137,7 +169,7 @@ jobs:
137169
if: github.event_name == 'push' # only deploy for pushed commits (not PRs)
138170

139171
runs-on: ubuntu-latest
140-
needs: [ build, test ]
172+
needs: [ build, screenshot-test, instrumented-test ]
141173
timeout-minutes: 30
142174
env:
143175
TERM: dumb

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
alias(libs.plugins.android.library) apply false
66
alias(libs.plugins.kotlin.android) apply false
77
alias(libs.plugins.compose.compiler) apply false
8+
alias(libs.plugins.roborazzi) apply false
89
alias(libs.plugins.metalava) apply false
910
alias(libs.plugins.maven.publish) apply false
1011
alias(libs.plugins.dependency.guard) apply false

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ android.nonTransitiveRClass=true
2525
org.gradle.parallel=true
2626
org.gradle.caching=true
2727

28+
# roborazzi
29+
roborazzi.record.filePathStrategy=relativePathFromRoborazziContextOutputDirectory
30+
31+
# publish
2832
SONATYPE_HOST=CENTRAL_PORTAL
2933
RELEASE_SIGNING_ENABLED=true
3034

gradle/libs.versions.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ androidxtest-junit = "1.1.3"
2323
espresso = "3.3.0"
2424
junit = "4.13"
2525

26+
# Roborazzi for screenshot testing
27+
roborazzi = "1.36.0"
28+
robolectric = "4.14.1"
29+
2630
[libraries]
2731

2832
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
@@ -52,6 +56,12 @@ androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core",
5256

5357
junit = { module = "junit:junit", version.ref = "junit" }
5458

59+
# Roborazzi dependencies
60+
roborazzi = { module = "io.github.takahirom.roborazzi:roborazzi", version.ref = "roborazzi" }
61+
roborazzi-compose = { module = "io.github.takahirom.roborazzi:roborazzi-compose", version.ref = "roborazzi" }
62+
roborazzi-junit-rule = { module = "io.github.takahirom.roborazzi:roborazzi-junit-rule", version.ref = "roborazzi" }
63+
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
64+
5565
# Dependencies of the included build-logic
5666
android-pluginGradle = { module = "com.android.tools.build:gradle", version.ref = "agp" }
5767
kotlin-pluginGradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
@@ -62,6 +72,7 @@ android-application = { id = "com.android.application", version.ref = "agp" }
6272
android-library = { id = "com.android.library", version.ref = "agp" }
6373
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
6474
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
75+
roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" }
6576
jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
6677
metalava = { id = "me.tylerbwong.gradle.metalava", version.ref = "metalava" }
6778
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }

pre_check.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,33 @@ echo "Starting pre-check validations..."
99
echo ""
1010

1111
# Verify dependency changes
12-
echo "🔍 [1/4] Checking dependency guard..."
12+
echo "🔍 [1/5] Checking dependency guard..."
1313
./gradlew dependencyGuard
1414
echo "✓ Dependency guard check passed"
1515
echo ""
1616

1717
# Verify code formatting
18-
echo "🔍 [2/4] Checking code formatting..."
18+
echo "🔍 [2/5] Checking code formatting..."
1919
./gradlew spotlessCheck --init-script gradle/init.gradle.kts
2020
echo "✓ Code formatting check passed"
2121
echo ""
2222

2323
# Verify API compatibility
24-
echo "🔍 [3/4] Checking API compatibility..."
24+
echo "🔍 [3/5] Checking API compatibility..."
2525
./gradlew metalavaCheckCompatibilityRelease
2626
echo "✓ API compatibility check passed"
2727
echo ""
2828

2929
# Static analysis and lint checks
30-
echo "🔍 [4/4] Running lint checks..."
30+
echo "🔍 [4/5] Running lint checks..."
3131
./gradlew lintDebug
3232
echo "✓ Lint check passed"
3333
echo ""
3434

35+
# Verify screenshots
36+
echo "🔍 [5/5] Checking screenshots..."
37+
./gradlew verifyRoborazziDebug
38+
echo "✓ Screenshots check passed"
39+
echo ""
40+
3541
echo "✅ All pre-checks passed successfully!"

readmore-foundation/build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id("readmore.android.library")
33
id("readmore.android.compose")
4+
alias(libs.plugins.roborazzi)
45
alias(libs.plugins.maven.publish)
56
alias(libs.plugins.jetbrains.dokka)
67
alias(libs.plugins.metalava)
@@ -16,6 +17,14 @@ android {
1617
excludes += '/META-INF/{AL2.0,LGPL2.1}'
1718
}
1819
}
20+
testOptions {
21+
unitTests {
22+
includeAndroidResources = true
23+
all {
24+
it.systemProperties["robolectric.pixelCopyRenderMode"] = "hardware"
25+
}
26+
}
27+
}
1928
}
2029

2130
metalava {
@@ -24,6 +33,10 @@ metalava {
2433
reportLintsAsErrors.set(true)
2534
}
2635

36+
roborazzi {
37+
outputDir.set(file("screenshots"))
38+
}
39+
2740
dependencies {
2841
implementation libs.compose.foundation.foundation
2942
implementation libs.compose.ui.util
@@ -32,6 +45,15 @@ dependencies {
3245
// Test dependencies
3346
// ======================
3447

48+
// Roborazzi for screenshot testing
49+
testImplementation libs.roborazzi
50+
testImplementation libs.roborazzi.compose
51+
testImplementation libs.roborazzi.junit.rule
52+
testImplementation libs.robolectric
53+
testImplementation libs.junit
54+
testImplementation libs.compose.ui.test.junit4
55+
testImplementation libs.androidx.test.ext.junit
56+
3557
androidTestImplementation libs.junit
3658
androidTestImplementation libs.androidx.test.core
3759
androidTestImplementation libs.androidx.test.runner
7.81 KB
11 KB
8.01 KB

0 commit comments

Comments
 (0)