Skip to content

Commit 7cfb154

Browse files
authored
chore: added Lint flow to modules (#2308)
* chore: added Lint flow to modules * chore: header for lint * chore: removed abort on error * chore: remove lint * chore: fixed lints * chore: fix permission
1 parent 1f79273 commit 7cfb154

File tree

16 files changed

+291
-92
lines changed

16 files changed

+291
-92
lines changed

.github/workflows/lint.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Lint and Upload SARIF
16+
17+
on:
18+
pull_request:
19+
branches:
20+
- main
21+
22+
jobs:
23+
lint:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v3
29+
30+
- name: Set up JDK 17
31+
uses: actions/setup-java@v3
32+
with:
33+
distribution: 'adopt'
34+
java-version: '17'
35+
36+
- name: Run Android Lint for ApiDemos/project/kotlin-app
37+
run: ./gradlew :kotlin-app:lintDebug
38+
working-directory: ApiDemos/project
39+
40+
- name: Upload SARIF for ApiDemos/project/kotlin-app
41+
uses: github/codeql-action/upload-sarif@v3
42+
with:
43+
sarif_file: ApiDemos/project/kotlin-app/build/reports/lint-results-debug.sarif
44+
category: ApiDemos-kotlin-app
45+
46+
- name: Run Android Lint for ApiDemos/project/java-app
47+
run: ./gradlew :java-app:lintDebug
48+
working-directory: ApiDemos/project
49+
50+
- name: Upload SARIF for ApiDemos/project/java-app
51+
uses: github/codeql-action/upload-sarif@v3
52+
with:
53+
sarif_file: ApiDemos/project/java-app/build/reports/lint-results-debug.sarif
54+
category: ApiDemos-java-app
55+
56+
- name: Run Android Lint for ApiDemos/project/common-ui
57+
run: ./gradlew :common-ui:lintDebug
58+
working-directory: ApiDemos/project
59+
60+
- name: Upload SARIF for ApiDemos/project/common-ui
61+
uses: github/codeql-action/upload-sarif@v3
62+
with:
63+
sarif_file: ApiDemos/project/common-ui/build/reports/lint-results-debug.sarif
64+
category: ApiDemos-common-ui
65+
66+
- name: Run Android Lint for snippets/app
67+
run: ./gradlew :app:lintGmsDebug
68+
working-directory: snippets
69+
70+
- name: Upload SARIF for snippets/app
71+
uses: github/codeql-action/upload-sarif@v3
72+
with:
73+
sarif_file: snippets/app/build/reports/lint-results-debug.sarif
74+
category: snippets-app
75+
76+
- name: Run Android Lint for snippets/app-utils
77+
run: ./gradlew :app-utils:lintDebug
78+
working-directory: snippets
79+
80+
- name: Upload SARIF for snippets/app-utils
81+
uses: github/codeql-action/upload-sarif@v3
82+
with:
83+
sarif_file: snippets/app-utils/build/reports/lint-results-debug.sarif
84+
category: snippets-app-utils
85+
86+
- name: Run Android Lint for snippets/app-utils-ktx
87+
run: ./gradlew :app-utils-ktx:lintDebug
88+
working-directory: snippets
89+
90+
- name: Upload SARIF for snippets/app-utils-ktx
91+
uses: github/codeql-action/upload-sarif@v3
92+
with:
93+
sarif_file: snippets/app-utils-ktx/build/reports/lint-results-debug.sarif
94+
category: snippets-app-utils-ktx
95+
96+
- name: Run Android Lint for snippets/app-rx
97+
run: ./gradlew :app-rx:lintDebug
98+
working-directory: snippets
99+
100+
- name: Upload SARIF for snippets/app-rx
101+
uses: github/codeql-action/upload-sarif@v3
102+
with:
103+
sarif_file: snippets/app-rx/build/reports/lint-results-debug.sarif
104+
category: snippets-app-rx
105+
106+
- name: Run Android Lint for snippets/app-places-ktx
107+
run: ./gradlew :app-places-ktx:lintDebug
108+
working-directory: snippets
109+
110+
- name: Upload SARIF for snippets/app-places-ktx
111+
uses: github/codeql-action/upload-sarif@v3
112+
with:
113+
sarif_file: snippets/app-places-ktx/build/reports/lint-results-debug.sarif
114+
category: snippets-app-places-ktx
115+
116+
- name: Run Android Lint for snippets/app-ktx
117+
run: ./gradlew :app-ktx:lintDebug
118+
working-directory: snippets
119+
120+
- name: Upload SARIF for snippets/app-ktx
121+
uses: github/codeql-action/upload-sarif@v3
122+
with:
123+
sarif_file: snippets/app-ktx/build/reports/lint-results-debug.sarif
124+
category: snippets-app-ktx
125+
126+
- name: Run Android Lint for snippets/app-compose
127+
run: ./gradlew :app-compose:lintDebug
128+
working-directory: snippets
129+
130+
- name: Upload SARIF for snippets/app-compose
131+
uses: github/codeql-action/upload-sarif@v3
132+
with:
133+
sarif_file: snippets/app-compose/build/reports/lint-results-debug.sarif
134+
category: snippets-app-compose
135+
136+
- name: Run Android Lint for WearOS/Wearable
137+
run: ./gradlew :Wearable:lintDebug
138+
working-directory: WearOS
139+
140+
- name: Upload SARIF for WearOS/Wearable
141+
uses: github/codeql-action/upload-sarif@v3
142+
with:
143+
sarif_file: WearOS/Wearable/build/reports/lint-results-debug.sarif
144+
category: WearOS-Wearable

ApiDemos/project/common-ui/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ android {
4545
sourceCompatibility = JavaVersion.VERSION_17
4646
targetCompatibility = JavaVersion.VERSION_17
4747
}
48+
49+
lint {
50+
disable += setOf("MissingInflatedId", "OnClick")
51+
sarifOutput = layout.buildDirectory.file("reports/lint-results-debug.sarif").get().asFile
52+
}
4853
kotlin {
4954
compilerOptions {
5055
jvmTarget.set(JvmTarget.JVM_17)

ApiDemos/project/common-ui/src/main/res/layout/camera_demo.xml

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
Copyright 2025 Google LLC
43
54
Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +15,8 @@
1615
-->
1716
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
1817
xmlns:app="http://schemas.android.com/apk/res-auto"
19-
android:layout_width="match_parent"
2018
android:id="@+id/map_container"
19+
android:layout_width="match_parent"
2120
android:layout_height="match_parent">
2221

2322
<com.google.android.material.appbar.MaterialToolbar
@@ -30,20 +29,22 @@
3029
app:layout_constraintTop_toTopOf="parent"
3130
app:title="@string/background_color_customization_demo_label"
3231
app:titleTextColor="?attr/colorOnPrimary" />
32+
3333
<androidx.fragment.app.FragmentContainerView
3434
android:id="@+id/map"
35+
class="com.google.android.gms.maps.SupportMapFragment"
3536
android:layout_width="match_parent"
36-
android:layout_height="match_parent"
37-
class="com.google.android.gms.maps.SupportMapFragment" />
37+
android:layout_height="match_parent" />
38+
3839
<LinearLayout
40+
android:id="@+id/first_container"
41+
android:layout_width="match_parent"
42+
android:layout_height="wrap_content"
3943
android:background="@color/white"
4044
android:baselineAligned="false"
4145
app:layout_constraintEnd_toEndOf="parent"
4246
app:layout_constraintStart_toStartOf="parent"
43-
app:layout_constraintTop_toBottomOf="@id/top_bar"
44-
android:id="@+id/first_container"
45-
android:layout_width="match_parent"
46-
android:layout_height="wrap_content">
47+
app:layout_constraintTop_toBottomOf="@id/top_bar">
4748

4849
<LinearLayout
4950
android:layout_width="wrap_content"
@@ -63,54 +64,54 @@
6364
android:layout_height="wrap_content"
6465
android:checked="true"
6566
android:onClick="onToggleAnimate"
66-
android:textOn="@string/animate"
67-
android:textOff="@string/animate" />
67+
android:textOff="@string/animate"
68+
android:textOn="@string/animate" />
6869
</LinearLayout>
6970

7071
<RelativeLayout
7172
android:layout_width="0dp"
7273
android:layout_height="match_parent"
73-
android:gravity="center_horizontal"
74-
android:layout_weight="1">
74+
android:layout_weight="1"
75+
android:gravity="center_horizontal">
7576

7677
<com.google.android.material.button.MaterialButton
7778
android:id="@+id/scroll_left"
7879
android:layout_width="wrap_content"
7980
android:layout_height="wrap_content"
80-
android:minWidth="48dp"
81-
android:onClick="onScrollLeft"
8281
android:layout_alignParentLeft="true"
8382
android:layout_centerVertical="true"
83+
android:minWidth="48dp"
84+
android:onClick="onScrollLeft"
8485
android:text="@string/left_arrow" />
8586

8687
<com.google.android.material.button.MaterialButton
8788
android:id="@+id/scroll_up"
8889
android:layout_width="wrap_content"
8990
android:layout_height="wrap_content"
90-
android:minWidth="48dp"
91-
android:onClick="onScrollUp"
9291
android:layout_alignParentTop="true"
9392
android:layout_toRightOf="@id/scroll_left"
93+
android:minWidth="48dp"
94+
android:onClick="onScrollUp"
9495
android:text="@string/up_arrow" />
9596

9697
<com.google.android.material.button.MaterialButton
9798
android:id="@+id/scroll_down"
9899
android:layout_width="wrap_content"
99100
android:layout_height="wrap_content"
100-
android:minWidth="48dp"
101-
android:onClick="onScrollDown"
102101
android:layout_below="@id/scroll_up"
103102
android:layout_toRightOf="@id/scroll_left"
103+
android:minWidth="48dp"
104+
android:onClick="onScrollDown"
104105
android:text="@string/down_arrow" />
105106

106107
<com.google.android.material.button.MaterialButton
107108
android:id="@+id/scroll_right"
108109
android:layout_width="wrap_content"
109110
android:layout_height="wrap_content"
110-
android:minWidth="48dp"
111-
android:onClick="onScrollRight"
112111
android:layout_centerVertical="true"
113112
android:layout_toRightOf="@id/scroll_down"
113+
android:minWidth="48dp"
114+
android:onClick="onScrollRight"
114115
android:text="@string/right_arrow" />
115116
</RelativeLayout>
116117

@@ -138,37 +139,37 @@
138139
</LinearLayout>
139140

140141
<LinearLayout
141-
android:orientation="vertical"
142142
android:layout_width="wrap_content"
143143
android:layout_height="fill_parent"
144-
android:layout_gravity="right">
144+
android:layout_gravity="right"
145+
android:orientation="vertical">
145146

146147
<com.google.android.material.button.MaterialButton
147148
android:id="@+id/tilt_more"
148149
android:layout_width="wrap_content"
149150
android:layout_height="wrap_content"
150151
android:minWidth="48dp"
151-
android:text="@string/tilt_more"
152-
android:onClick="onTiltMore" />
152+
android:onClick="onTiltMore"
153+
android:text="@string/tilt_more" />
153154

154155
<com.google.android.material.button.MaterialButton
155156
android:id="@+id/tilt_less"
156157
android:layout_width="wrap_content"
157158
android:layout_height="wrap_content"
158159
android:minWidth="48dp"
159-
android:text="@string/tilt_less"
160-
android:onClick="onTiltLess" />
160+
android:onClick="onTiltLess"
161+
android:text="@string/tilt_less" />
161162
</LinearLayout>
162163
</LinearLayout>
163164

164165
<LinearLayout
166+
android:id="@+id/second_container"
167+
android:layout_width="match_parent"
168+
android:layout_height="wrap_content"
165169
android:background="@color/white"
166170
app:layout_constraintEnd_toEndOf="parent"
167171
app:layout_constraintStart_toStartOf="parent"
168-
app:layout_constraintTop_toBottomOf="@id/first_container"
169-
android:id="@+id/second_container"
170-
android:layout_width="match_parent"
171-
android:layout_height="wrap_content">
172+
app:layout_constraintTop_toBottomOf="@id/first_container">
172173

173174
<com.google.android.material.checkbox.MaterialCheckBox
174175
android:id="@+id/duration_toggle"
@@ -186,28 +187,28 @@
186187
</LinearLayout>
187188

188189
<LinearLayout
190+
android:id="@+id/third_container"
191+
android:layout_width="match_parent"
192+
android:layout_height="wrap_content"
189193
android:background="@color/white"
190194
app:layout_constraintEnd_toEndOf="parent"
191195
app:layout_constraintStart_toStartOf="parent"
192-
app:layout_constraintTop_toBottomOf="@id/second_container"
193-
android:id="@+id/third_container"
194-
android:layout_width="match_parent"
195-
android:layout_height="wrap_content">
196+
app:layout_constraintTop_toBottomOf="@id/second_container">
196197

197198
<com.google.android.material.button.MaterialButton
198199
android:id="@+id/sydney"
199200
android:layout_width="0dp"
200201
android:layout_height="wrap_content"
201-
android:onClick="onGoToSydney"
202202
android:layout_weight="0.5"
203+
android:onClick="onGoToSydney"
203204
android:text="@string/go_to_sydney" />
204205

205206
<com.google.android.material.button.MaterialButton
206207
android:id="@+id/bondi"
207208
android:layout_width="0dp"
208209
android:layout_height="wrap_content"
209-
android:onClick="onGoToBondi"
210210
android:layout_weight="0.5"
211+
android:onClick="onGoToBondi"
211212
android:text="@string/go_to_bondi" />
212213
</LinearLayout>
213214

0 commit comments

Comments
 (0)