Skip to content

Commit ac9dafa

Browse files
authored
Merge branch 'main' into cleanup-dependencies
2 parents 2ba04df + 9234331 commit ac9dafa

File tree

8 files changed

+69
-40
lines changed

8 files changed

+69
-40
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ updates:
1818
- "org.jetbrains.kotlin.jvm"
1919
- "com.google.devtools.ksp"
2020
- "androidx.compose.compiler:compiler"
21+
open-pull-requests-limit: 10
2122
registries:
2223
maven-google:
2324
type: "maven-repository"

.github/workflows/Build.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
3232

3333
- name: Set up JDK 17
34-
uses: actions/setup-java@v3
34+
uses: actions/setup-java@v4
3535
with:
3636
distribution: 'zulu'
3737
java-version: 17
@@ -75,7 +75,7 @@ jobs:
7575
# Run local tests after screenshot tests to avoid wrong UP-TO-DATE. TODO: Ignore screenshots.
7676
- name: Run local tests
7777
if: always()
78-
run: ./gradlew testDemoDebug testProdDebug :lint:test
78+
run: ./gradlew testDemoDebug :lint:test
7979
# Replace task exclusions with `-Pandroidx.baselineprofile.skipgeneration` when
8080
# https://android-review.googlesource.com/c/platform/frameworks/support/+/2602790 landed in a
8181
# release build
@@ -91,14 +91,14 @@ jobs:
9191
-x collectProdNonMinifiedBenchmarkBaselineProfile
9292

9393
- name: Upload build outputs (APKs)
94-
uses: actions/upload-artifact@v3
94+
uses: actions/upload-artifact@v4
9595
with:
9696
name: APKs
9797
path: '**/build/outputs/apk/**/*.apk'
9898

9999
- name: Upload test results (XML)
100100
if: always()
101-
uses: actions/upload-artifact@v3
101+
uses: actions/upload-artifact@v4
102102
with:
103103
name: test-results
104104
path: '**/build/test-results/test*UnitTest/**.xml'
@@ -108,7 +108,7 @@ jobs:
108108

109109
- name: Upload lint reports (HTML)
110110
if: always()
111-
uses: actions/upload-artifact@v3
111+
uses: actions/upload-artifact@v4
112112
with:
113113
name: lint-reports
114114
path: '**/build/reports/lint-results-*.html'
@@ -131,7 +131,7 @@ jobs:
131131
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
132132

133133
- name: Set up JDK 17
134-
uses: actions/setup-java@v3
134+
uses: actions/setup-java@v4
135135
with:
136136
distribution: 'zulu'
137137
java-version: 17
@@ -154,7 +154,7 @@ jobs:
154154

155155
- name: Upload test reports
156156
if: always()
157-
uses: actions/upload-artifact@v3
157+
uses: actions/upload-artifact@v4
158158
with:
159159
name: test-reports-${{ matrix.api-level }}
160160
path: '**/build/reports/androidTests'

.github/workflows/Release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
2222

2323
- name: Set up JDK 17
24-
uses: actions/setup-java@v3
24+
uses: actions/setup-java@v4
2525
with:
2626
distribution: 'zulu'
2727
java-version: 17

README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The app is currently in development. The `prodRelease` variant is [available on
2222
**Now in Android** displays content from the
2323
[Now in Android](https://developer.android.com/series/now-in-android) series. Users can browse for
2424
links to recent videos, articles and other content. Users can also follow topics they are interested
25-
in.
25+
in, and be notified when new content is published which matches interests they are following.
2626

2727
## Screenshots
2828

@@ -109,12 +109,42 @@ Examples:
109109
manipulate the state of the `Test` repository and verify the resulting behavior, instead of
110110
checking that specific repository methods were called.
111111

112-
## Screenshot tests
112+
To run the tests execute the following gradle tasks:
113+
114+
- `testDemoDebug` run all local tests against the `demoDebug` variant.
115+
- `connectedDemoDebugAndroidTest` run all instrumented tests against the `demoDebug` variant.
113116

114-
**Now In Android** uses [Roborazzi](https://github.com/takahirom/roborazzi) to do screenshot tests
115-
of certain screens and components. To run these tests, run the `verifyRoborazziDemoDebug` or
116-
`recordRoborazziDemoDebug` tasks. Note that screenshots are recorded on CI, using Linux, and other
117-
platforms might generate slightly different images, making the tests fail.
117+
**Note:** You should not run `./gradlew test` or `./gradlew connectedAndroidTest` as this will execute
118+
tests against _all_ build variants which is both unecessary and will result in failures as only the
119+
`demoDebug` variant is supported. No other variants have any tests (although this might change in future).
120+
121+
## Screenshot tests
122+
A screenshot test takes a screenshot of a screen or a UI component within the app, and compares it
123+
with a previously recorded screenshot which is known to be rendered correctly.
124+
125+
For example, Now in Android has [screenshot tests](https://github.com/android/nowinandroid/blob/main/app/src/testDemoDebug/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppScreenSizesScreenshotTests.kt)
126+
to verify that the navigation is displayed correctly on different screen sizes
127+
([known correct screenshots](https://github.com/android/nowinandroid/tree/main/app/src/testDemoDebug/screenshots)).
128+
129+
Now In Android uses [Roborazzi](https://github.com/takahirom/roborazzi) to run screenshot tests
130+
of certain screens and UI components. When working with screenshot tests the following gradle tasks are useful:
131+
132+
- `verifyRoborazziDemoDebug` run all screenshot tests, verifying the screenshots against the known
133+
correct screenshots.
134+
- `recordRoborazziDemoDebug` record new "known correct" screenshots. Use this command when you have
135+
made changes to the UI and manually verified that they are rendered correctly. Screenshots will be
136+
stored in `modulename/src/test/screenshots`.
137+
- `compareRoborazziDemoDebug` create comparison images between failed tests and the known correct
138+
images. These can also be found in `modulename/src/test/screenshots`.
139+
140+
**Note:** The known correct screenshots stored in this repository are recorded on CI using Linux. Other
141+
platforms may (and probably will) generate slightly different images, making the screenshot tests fail.
142+
When working on a non-Linux platform, a workaround to this is to run `recordRoborazziDemoDebug` on the
143+
`main` branch before starting work. After making changes, `verifyRoborazziDemoDebug` will identify only
144+
legitimate changes.
145+
146+
For more information about screenshot testing
147+
[check out this talk](https://www.droidcon.com/2023/11/15/easy-screenshot-testing-with-compose/).
118148

119149
# UI
120150
The app was designed using [Material 3 guidelines](https://m3.material.io/). Learn more about the design process and

build-logic/convention/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dependencies {
4141
compileOnly(libs.firebase.performance.gradlePlugin)
4242
compileOnly(libs.kotlin.gradlePlugin)
4343
compileOnly(libs.ksp.gradlePlugin)
44+
implementation(libs.truth)
4445
}
4546

4647
tasks {

build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/Badging.kt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import com.android.build.api.artifact.SingleArtifact
2020
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
2121
import com.android.build.gradle.BaseExtension
2222
import com.android.SdkConstants
23+
import com.google.common.truth.Truth.assertWithMessage
2324
import org.gradle.api.DefaultTask
24-
import org.gradle.api.GradleException
2525
import org.gradle.api.Project
2626
import org.gradle.api.file.DirectoryProperty
2727
import org.gradle.api.file.RegularFileProperty
@@ -40,7 +40,6 @@ import org.gradle.kotlin.dsl.register
4040
import org.gradle.language.base.plugins.LifecycleBasePlugin
4141
import org.gradle.process.ExecOperations
4242
import java.io.File
43-
import java.nio.file.Files
4443
import javax.inject.Inject
4544

4645
@CacheableTask
@@ -98,17 +97,12 @@ abstract class CheckBadgingTask : DefaultTask() {
9897

9998
@TaskAction
10099
fun taskAction() {
101-
if (
102-
Files.mismatch(
103-
goldenBadging.get().asFile.toPath(),
104-
generatedBadging.get().asFile.toPath(),
105-
) != -1L
106-
) {
107-
throw GradleException(
108-
"Generated badging is different from golden badging! " +
109-
"If this change is intended, run ./gradlew ${updateBadgingTaskName.get()}",
110-
)
111-
}
100+
assertWithMessage(
101+
"Generated badging is different from golden badging! " +
102+
"If this change is intended, run ./gradlew ${updateBadgingTaskName.get()}",
103+
)
104+
.that(generatedBadging.get().asFile.readText())
105+
.isEqualTo(goldenBadging.get().asFile.readText())
112106
}
113107
}
114108

build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ private fun Project.configureKotlin() {
8383
val warningsAsErrors: String? by project
8484
allWarningsAsErrors = warningsAsErrors.toBoolean()
8585
freeCompilerArgs = freeCompilerArgs + listOf(
86-
"-opt-in=kotlin.RequiresOptIn",
8786
// Enable experimental coroutines APIs, including Flow
8887
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
89-
"-opt-in=kotlinx.coroutines.FlowPreview",
9088
)
9189
}
9290
}

gradle/libs.versions.toml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
[versions]
22
accompanist = "0.32.0"
3-
androidDesugarJdkLibs = "2.0.3"
3+
androidDesugarJdkLibs = "2.0.4"
44
# AGP and tools should be updated together
5-
androidGradlePlugin = "8.1.3"
5+
androidGradlePlugin = "8.2.0"
66
androidTools = "31.1.3"
77
androidxActivity = "1.8.0"
88
androidxAppCompat = "1.6.1"
99
androidxBrowser = "1.6.0"
1010
androidxComposeBom = "2023.10.01"
11-
androidxComposeCompiler = "1.5.3"
11+
androidxComposeCompiler = "1.5.7"
12+
androidxComposeRuntimeTracing = "1.0.0-beta01"
1213
androidxCore = "1.12.0"
1314
androidxCoreSplashscreen = "1.0.1"
1415
androidxDataStore = "1.0.0"
1516
androidxEspresso = "3.5.1"
1617
androidxHiltNavigationCompose = "1.0.0"
1718
androidxLifecycle = "2.6.2"
18-
androidxMacroBenchmark = "1.2.0"
19+
androidxMacroBenchmark = "1.2.2"
1920
androidxMetrics = "1.0.0-alpha04"
2021
androidxNavigation = "2.7.4"
2122
androidxProfileinstaller = "1.3.1"
@@ -25,33 +26,36 @@ androidxTestRules = "1.5.0"
2526
androidxTestRunner = "1.5.2"
2627
androidxTracing = "1.1.0"
2728
androidxUiAutomator = "2.2.0"
29+
androidxWindowManager = "1.2.0"
2830
androidxWork = "2.9.0-rc01"
29-
coil = "2.4.0"
31+
coil = "2.5.0"
3032
dependencyGuard = "0.4.3"
3133
firebaseBom = "32.4.0"
3234
firebaseCrashlyticsPlugin = "2.9.9"
3335
firebasePerfPlugin = "1.4.2"
3436
gmsPlugin = "4.4.0"
3537
googleOss = "17.0.1"
3638
googleOssPlugin = "0.10.6"
37-
hilt = "2.48.1"
39+
hilt = "2.50"
3840
hiltExt = "1.1.0"
3941
jacoco = "0.8.7"
40-
kotlin = "1.9.10"
42+
junit4 = "4.13.2"
43+
kotlin = "1.9.21"
4144
kotlinxCoroutines = "1.7.3"
42-
kotlinxDatetime = "0.4.1"
45+
kotlinxDatetime = "0.5.0"
4346
kotlinxSerializationJson = "1.6.0"
44-
ksp = "1.9.10-1.0.13"
45-
lint = "31.1.3"
47+
ksp = "1.9.21-1.0.16"
48+
lint = "31.2.0"
4649
okhttp = "4.12.0"
4750
protobuf = "3.24.4"
4851
protobufPlugin = "0.9.4"
4952
retrofit = "2.9.0"
5053
retrofitKotlinxSerializationJson = "1.0.0"
5154
robolectric = "4.11.1"
5255
roborazzi = "1.6.0"
53-
room = "2.6.0"
56+
room = "2.6.1"
5457
secrets = "2.0.1"
58+
truth = "1.1.5"
5559
turbine = "1.0.0"
5660

5761
[libraries]
@@ -128,6 +132,7 @@ roborazzi = { group = "io.github.takahirom.roborazzi", name = "roborazzi", versi
128132
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
129133
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
130134
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
135+
truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
131136
turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" }
132137

133138
# Dependencies of the included build-logic

0 commit comments

Comments
 (0)