Skip to content

Commit

Permalink
Update bazel, bazel-common and add jobs for bazel android lint (#123
Browse files Browse the repository at this point in the history
)

Fixes #123
  • Loading branch information
arunkumar9t2 committed Mar 8, 2024
1 parent 41844df commit 3ce0892
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 6 deletions.
7 changes: 5 additions & 2 deletions .bazel/.default.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ build --define=android_standalone_dexing_tool=d8_compat_dx
build --define=android_dexmerger_tool=d8_dexmerger

build --persistent_multiplex_android_tools
build --strategy=AndroidAssetMerger=sandboxed
build --strategy=AndroidLint=sandboxed
build --strategy=AndroidAssetMerger=worker
build --strategy=AndroidLint=worker
build --strategy=AndroidLintAnalyze=worker
build --strategy=DatabindingStubs=worker
build --worker_max_instances=Javac=1
build --worker_max_instances=KotlinCompile=1
Expand All @@ -46,6 +47,8 @@ build --worker_max_instances=RClassGenerator=1
build --worker_max_instances=AndroidAapt2=1
build --worker_max_instances=AndroidAssetMerger=1
build --worker_max_instances=AndroidResourceMerger=1
build --worker_max_instances=AndroidLint=1
build --worker_max_instances=AndroidLintAnalyze=1
build --worker_max_instances=AndroidCompiledResourceMerger=1
build --worker_max_instances=Aapt2Optimize=1
build --worker_max_instances=DatabindingStubs=1
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.0
6.4.0
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Query targets
run: |
bazelisk query 'kind(kt_jvm_test, ...)' --output label > /tmp/targets
- name: Bazel test
uses: ./.github/actions/bazel
with:
bazel-command: test //...
bazel-command: test --target_pattern_file=/tmp/targets
cache-key: bazel-test

bazel-android-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Bazel Android Lint
uses: ./.github/actions/bazel
with:
bazel-command: test //sample-android:sample-android-flavor1-free-debug.lint_test
cache-key: bazel-lint

grazel-build:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ _sandbox
# Bazel
bazel-*
databinding_info.bazelrc
tools/bazel

local.bazelrc

Expand Down
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "grab_bazel_common",
commit = "2abb41f0fae9f9c973ca176e9b6b4b73928de2f8",
commit = "1e751cfd185fd205555f50a5ea6e6c1b52dcdc63",
remote = "https://github.com/grab/grab-bazel-common.git",
)

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ grazel {
rules {
bazelCommon {
gitRepository {
commit = "2abb41f0fae9f9c973ca176e9b6b4b73928de2f8"
commit = "1e751cfd185fd205555f50a5ea6e6c1b52dcdc63"
remote = "https://github.com/grab/grab-bazel-common.git"
}
toolchains {
Expand Down
12 changes: 12 additions & 0 deletions sample-android/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ android_binary(
enable_compose = True,
enable_data_binding = True,
incremental_dexing = True,
lint_options = {
"baseline": "lint_baseline.xml",
},
manifest = "src/debug/AndroidManifest.xml",
manifest_values = {
"versionCode": "1",
Expand Down Expand Up @@ -121,6 +124,9 @@ android_binary(
enable_compose = True,
enable_data_binding = True,
incremental_dexing = True,
lint_options = {
"baseline": "lint_baseline.xml",
},
manifest = "src/debug/AndroidManifest.xml",
manifest_values = {
"versionCode": "1",
Expand Down Expand Up @@ -208,6 +214,9 @@ android_binary(
enable_compose = True,
enable_data_binding = True,
incremental_dexing = True,
lint_options = {
"baseline": "lint_baseline.xml",
},
manifest = "src/debug/AndroidManifest.xml",
manifest_values = {
"versionCode": "1",
Expand Down Expand Up @@ -295,6 +304,9 @@ android_binary(
enable_compose = True,
enable_data_binding = True,
incremental_dexing = True,
lint_options = {
"baseline": "lint_baseline.xml",
},
manifest = "src/debug/AndroidManifest.xml",
manifest_values = {
"versionCode": "1",
Expand Down
4 changes: 4 additions & 0 deletions sample-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ android {
buildFeatures {
compose = true
}

lint {
baseline = file("lint_baseline.xml")
}
}

dependencies {
Expand Down
79 changes: 79 additions & 0 deletions sample-android/lint_baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.4.0-alpha09" type="baseline" client="" dependencies="true" name="" variant="all" version="8.4.0-alpha09">

<issue
id="DiscouragedApi"
message="Should not restrict activity to fixed orientation. This may not be suitable for different form factors, causing the app to be letterboxed."
errorLine1=" android:screenOrientation=&quot;${orientation}&quot;>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="../../../../../sample-android/src/debug/AndroidManifest.xml"
line="35"
column="13"/>
</issue>

<issue
id="Typos"
message="Did you mean &quot;flavor!&quot; instead of &quot;flavor1&quot;?">
<location
file="../sample-android-flavor-flavor1-free-debug_res/out/res/values/values.xml"
line="5"
column="37"/>
</issue>

<issue
id="MonochromeLauncherIcon"
message="The application adaptive icon is missing a monochrome tag"
errorLine1="&lt;adaptive-icon xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;>"
errorLine2="^">
<location
file="../../../../android-armeabi-v7a-fastbuild/bin/sample-android/sample-android-flavor1-free-debug_res/out/res/mipmap-anydpi-v26/ic_launcher.xml"
line="17"
column="1"/>
</issue>

<issue
id="MonochromeLauncherIcon"
message="The application adaptive roundIcon is missing a monochrome tag"
errorLine1="&lt;adaptive-icon xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;>"
errorLine2="^">
<location
file="../../../../android-armeabi-v7a-fastbuild/bin/sample-android/sample-android-flavor1-free-debug_res/out/res/mipmap-anydpi-v26/ic_launcher_round.xml"
line="17"
column="1"/>
</issue>

<issue
id="SetTextI18n"
message="Do not concatenate text displayed with `setText`. Use resource string with placeholders."
errorLine1=" findViewById&lt;TextView>(R.id.text2).text = &quot;Flavored JVM class: ${ModuleName().name()}&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="../../../../../sample-android-flavor/src/main/java/com/grab/grazel/android/flavor/FlavorActivity.kt"
line="33"
column="51"/>
</issue>

<issue
id="SetTextI18n"
message="String literal in `setText` can not be translated. Use Android resources instead."
errorLine1=" findViewById&lt;TextView>(R.id.text2).text = &quot;Flavored JVM class: ${ModuleName().name()}&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
<location
file="../../../../../sample-android-flavor/src/main/java/com/grab/grazel/android/flavor/FlavorActivity.kt"
line="33"
column="52"/>
</issue>

<issue
id="HardcodedText"
message="Hardcoded string &quot;Hello World from Grazel!&quot;, should use `@string` resource"
errorLine1=" android:text=&quot;Hello World from Grazel!&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="../../../../android-armeabi-v7a-fastbuild/bin/sample-android/sample-android-flavor1-free-debug_res/out/res/layout/activity_main.xml"
line="28"
column="9"/>
</issue>

</issues>

0 comments on commit 3ce0892

Please sign in to comment.