Skip to content

Commit d17f3b1

Browse files
authored
Merge branch 'main' into move-android-instrumented-test
2 parents c1118ea + 4238aa4 commit d17f3b1

File tree

181 files changed

+1511
-926
lines changed

Some content is hidden

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

181 files changed

+1511
-926
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
[*.{kt,kts}]
55
ij_kotlin_allow_trailing_comma=true
66
ij_kotlin_allow_trailing_comma_on_call_site=true
7+
ktlint_function_naming_ignore_when_annotated_with=Composable, Test

.github/dependabot.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
- package-ecosystem: "gradle"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
registries: "*"
13+
labels: [ "version update" ]
14+
groups:
15+
kotlin-ksp-compose:
16+
patterns:
17+
- "org.jetbrains.kotlin:*"
18+
- "org.jetbrains.kotlin.jvm"
19+
- "com.google.devtools.ksp"
20+
- "androidx.compose.compiler:compiler"
21+
open-pull-requests-limit: 10
22+
registries:
23+
maven-google:
24+
type: "maven-repository"
25+
url: "https://maven.google.com"
26+
replaces-base: true

.github/renovate.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/Build.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ 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
3838

3939
- name: Setup Gradle
4040
uses: gradle/gradle-build-action@v2
4141

42+
- name: Check build-logic
43+
run: ./gradlew check -p build-logic
44+
4245
- name: Check spotless
4346
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache
4447

@@ -72,7 +75,7 @@ jobs:
7275
# Run local tests after screenshot tests to avoid wrong UP-TO-DATE. TODO: Ignore screenshots.
7376
- name: Run local tests
7477
if: always()
75-
run: ./gradlew testDemoDebug testProdDebug :lint:test
78+
run: ./gradlew testDemoDebug :lint:test
7679
# Replace task exclusions with `-Pandroidx.baselineprofile.skipgeneration` when
7780
# https://android-review.googlesource.com/c/platform/frameworks/support/+/2602790 landed in a
7881
# release build
@@ -88,14 +91,14 @@ jobs:
8891
-x collectProdNonMinifiedBenchmarkBaselineProfile
8992

9093
- name: Upload build outputs (APKs)
91-
uses: actions/upload-artifact@v3
94+
uses: actions/upload-artifact@v4
9295
with:
9396
name: APKs
9497
path: '**/build/outputs/apk/**/*.apk'
9598

9699
- name: Upload test results (XML)
97100
if: always()
98-
uses: actions/upload-artifact@v3
101+
uses: actions/upload-artifact@v4
99102
with:
100103
name: test-results
101104
path: '**/build/test-results/test*UnitTest/**.xml'
@@ -105,7 +108,7 @@ jobs:
105108

106109
- name: Upload lint reports (HTML)
107110
if: always()
108-
uses: actions/upload-artifact@v3
111+
uses: actions/upload-artifact@v4
109112
with:
110113
name: lint-reports
111114
path: '**/build/reports/lint-results-*.html'
@@ -128,7 +131,7 @@ jobs:
128131
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
129132

130133
- name: Set up JDK 17
131-
uses: actions/setup-java@v3
134+
uses: actions/setup-java@v4
132135
with:
133136
distribution: 'zulu'
134137
java-version: 17
@@ -151,7 +154,7 @@ jobs:
151154

152155
- name: Upload test reports
153156
if: always()
154-
uses: actions/upload-artifact@v3
157+
uses: actions/upload-artifact@v4
155158
with:
156159
name: test-reports-${{ matrix.api-level }}
157160
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

app-nia-catalog/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ android {
6565
}
6666

6767
dependencies {
68+
implementation(libs.androidx.activity.compose)
69+
6870
implementation(projects.core.designsystem)
6971
implementation(projects.core.ui)
70-
implementation(libs.androidx.activity.compose)
72+
}
73+
74+
dependencyGuard {
75+
configuration("releaseRuntimeClasspath")
7176
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
androidx.activity:activity-compose:1.8.0
2+
androidx.activity:activity-ktx:1.8.0
3+
androidx.activity:activity:1.8.0
4+
androidx.annotation:annotation-experimental:1.3.1
5+
androidx.annotation:annotation-jvm:1.7.0
6+
androidx.annotation:annotation:1.7.0
7+
androidx.appcompat:appcompat-resources:1.6.1
8+
androidx.arch.core:core-common:2.2.0
9+
androidx.arch.core:core-runtime:2.2.0
10+
androidx.autofill:autofill:1.0.0
11+
androidx.browser:browser:1.6.0
12+
androidx.collection:collection-jvm:1.3.0
13+
androidx.collection:collection:1.3.0
14+
androidx.compose.animation:animation-android:1.5.4
15+
androidx.compose.animation:animation-core-android:1.5.4
16+
androidx.compose.animation:animation-core:1.5.4
17+
androidx.compose.animation:animation:1.5.4
18+
androidx.compose.foundation:foundation-android:1.5.4
19+
androidx.compose.foundation:foundation-layout-android:1.5.4
20+
androidx.compose.foundation:foundation-layout:1.5.4
21+
androidx.compose.foundation:foundation:1.5.4
22+
androidx.compose.material3:material3:1.1.2
23+
androidx.compose.material:material-icons-core-android:1.5.4
24+
androidx.compose.material:material-icons-core:1.5.4
25+
androidx.compose.material:material-icons-extended-android:1.5.4
26+
androidx.compose.material:material-icons-extended:1.5.4
27+
androidx.compose.material:material-ripple-android:1.5.4
28+
androidx.compose.material:material-ripple:1.5.4
29+
androidx.compose.runtime:runtime-android:1.5.4
30+
androidx.compose.runtime:runtime-saveable-android:1.5.4
31+
androidx.compose.runtime:runtime-saveable:1.5.4
32+
androidx.compose.runtime:runtime:1.5.4
33+
androidx.compose.ui:ui-android:1.5.4
34+
androidx.compose.ui:ui-geometry-android:1.5.4
35+
androidx.compose.ui:ui-geometry:1.5.4
36+
androidx.compose.ui:ui-graphics-android:1.5.4
37+
androidx.compose.ui:ui-graphics:1.5.4
38+
androidx.compose.ui:ui-text-android:1.5.4
39+
androidx.compose.ui:ui-text:1.5.4
40+
androidx.compose.ui:ui-tooling-preview-android:1.5.4
41+
androidx.compose.ui:ui-tooling-preview:1.5.4
42+
androidx.compose.ui:ui-unit-android:1.5.4
43+
androidx.compose.ui:ui-unit:1.5.4
44+
androidx.compose.ui:ui-util-android:1.5.4
45+
androidx.compose.ui:ui-util:1.5.4
46+
androidx.compose.ui:ui:1.5.4
47+
androidx.compose:compose-bom:2023.10.01
48+
androidx.concurrent:concurrent-futures:1.1.0
49+
androidx.core:core-ktx:1.12.0
50+
androidx.core:core:1.12.0
51+
androidx.customview:customview-poolingcontainer:1.0.0
52+
androidx.customview:customview:1.0.0
53+
androidx.emoji2:emoji2:1.4.0
54+
androidx.exifinterface:exifinterface:1.3.6
55+
androidx.fragment:fragment:1.5.1
56+
androidx.interpolator:interpolator:1.0.0
57+
androidx.lifecycle:lifecycle-common-java8:2.6.2
58+
androidx.lifecycle:lifecycle-common:2.6.2
59+
androidx.lifecycle:lifecycle-livedata-core:2.6.2
60+
androidx.lifecycle:lifecycle-livedata:2.6.2
61+
androidx.lifecycle:lifecycle-process:2.6.2
62+
androidx.lifecycle:lifecycle-runtime-ktx:2.6.2
63+
androidx.lifecycle:lifecycle-runtime:2.6.2
64+
androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2
65+
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2
66+
androidx.lifecycle:lifecycle-viewmodel:2.6.2
67+
androidx.loader:loader:1.0.0
68+
androidx.metrics:metrics-performance:1.0.0-alpha04
69+
androidx.profileinstaller:profileinstaller:1.3.1
70+
androidx.savedstate:savedstate-ktx:1.2.1
71+
androidx.savedstate:savedstate:1.2.1
72+
androidx.startup:startup-runtime:1.1.1
73+
androidx.tracing:tracing:1.0.0
74+
androidx.vectordrawable:vectordrawable-animated:1.1.0
75+
androidx.vectordrawable:vectordrawable:1.1.0
76+
androidx.versionedparcelable:versionedparcelable:1.1.1
77+
androidx.viewpager:viewpager:1.0.0
78+
com.google.accompanist:accompanist-drawablepainter:0.32.0
79+
com.google.code.findbugs:jsr305:3.0.2
80+
com.google.dagger:dagger-lint-aar:2.50
81+
com.google.dagger:dagger:2.50
82+
com.google.dagger:hilt-android:2.50
83+
com.google.dagger:hilt-core:2.50
84+
com.google.guava:listenablefuture:1.0
85+
com.squareup.okhttp3:okhttp:4.12.0
86+
com.squareup.okio:okio-jvm:3.6.0
87+
com.squareup.okio:okio:3.6.0
88+
io.coil-kt:coil-base:2.5.0
89+
io.coil-kt:coil-compose-base:2.5.0
90+
io.coil-kt:coil-compose:2.5.0
91+
io.coil-kt:coil:2.5.0
92+
javax.inject:javax.inject:1
93+
org.jetbrains.kotlin:kotlin-stdlib-common:1.9.21
94+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10
95+
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10
96+
org.jetbrains.kotlin:kotlin-stdlib:1.9.21
97+
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3
98+
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.7.3
99+
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.3
100+
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3
101+
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.5.0
102+
org.jetbrains.kotlinx:kotlinx-datetime:0.5.0
103+
org.jetbrains:annotations:23.0.0

app/build.gradle.kts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ plugins {
2525
alias(libs.plugins.nowinandroid.android.application.firebase)
2626
id("com.google.android.gms.oss-licenses-plugin")
2727
alias(libs.plugins.baselineprofile)
28+
alias(libs.plugins.roborazzi)
2829
}
2930

3031
android {
@@ -96,51 +97,49 @@ dependencies {
9697
implementation(projects.core.data)
9798
implementation(projects.core.model)
9899
implementation(projects.core.analytics)
99-
100100
implementation(projects.sync.work)
101101

102-
androidTestImplementation(projects.core.testing)
103-
androidTestImplementation(projects.core.datastoreTest)
104-
androidTestImplementation(projects.core.dataTest)
105-
androidTestImplementation(projects.core.network)
106-
androidTestImplementation(libs.androidx.navigation.testing)
107-
androidTestImplementation(libs.accompanist.testharness)
108-
androidTestImplementation(kotlin("test"))
109-
debugImplementation(libs.androidx.compose.ui.testManifest)
110-
debugImplementation(projects.uiTestHiltManifest)
111-
112102
implementation(libs.androidx.activity.compose)
113-
implementation(libs.androidx.appcompat)
114103
implementation(libs.androidx.core.ktx)
115104
implementation(libs.androidx.core.splashscreen)
116-
implementation(libs.androidx.compose.runtime)
105+
implementation(libs.androidx.tracing.ktx)
117106
implementation(libs.androidx.lifecycle.runtimeCompose)
118-
implementation(libs.androidx.compose.runtime.tracing)
119107
implementation(libs.androidx.compose.material3.windowSizeClass)
120-
implementation(libs.androidx.hilt.navigation.compose)
121108
implementation(libs.androidx.navigation.compose)
122-
implementation(libs.androidx.window.manager)
123109
implementation(libs.androidx.profileinstaller)
124110
implementation(libs.kotlinx.coroutines.guava)
125111
implementation(libs.coil.kt)
126112

127-
baselineProfile(project(":benchmarks"))
113+
debugImplementation(libs.androidx.compose.ui.testManifest)
114+
debugImplementation(projects.uiTestHiltManifest)
115+
116+
kspTest(libs.hilt.compiler)
128117

129-
// Core functions
130-
testImplementation(projects.core.testing)
131-
testImplementation(projects.core.datastoreTest)
132118
testImplementation(projects.core.dataTest)
133-
testImplementation(projects.core.network)
134-
testImplementation(libs.androidx.navigation.testing)
119+
testImplementation(projects.core.testing)
135120
testImplementation(libs.accompanist.testharness)
121+
testImplementation(libs.hilt.android.testing)
136122
testImplementation(libs.work.testing)
137-
testImplementation(kotlin("test"))
138-
kspTest(libs.hilt.compiler)
139123

124+
testDemoImplementation(libs.robolectric)
125+
testDemoImplementation(libs.roborazzi)
126+
127+
androidTestImplementation(projects.core.testing)
128+
androidTestImplementation(projects.core.dataTest)
129+
androidTestImplementation(projects.core.datastoreTest)
130+
androidTestImplementation(libs.androidx.navigation.testing)
131+
androidTestImplementation(libs.accompanist.testharness)
132+
androidTestImplementation(libs.hilt.android.testing)
133+
134+
baselineProfile(projects.benchmarks)
140135
}
141136

142137
baselineProfile {
143138
// Don't build on every iteration of a full assemble.
144139
// Instead enable generation directly for the release build variant.
145140
automaticGenerationDuringBuild = false
146141
}
142+
143+
dependencyGuard {
144+
configuration("prodReleaseRuntimeClasspath")
145+
}

0 commit comments

Comments
 (0)