Skip to content

Commit

Permalink
Merge pull request #315 from Automattic/integrate_lint
Browse files Browse the repository at this point in the history
Run lint and upload results to Github Code Scanning
  • Loading branch information
wzieba authored Sep 19, 2024
2 parents d46a1c4 + 1b9a5f1 commit 1e3fe8f
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 18 deletions.
9 changes: 9 additions & 0 deletions .buildkite/commands/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -u

echo "--- 🧹 Linting"
./gradlew :demo-app:lintRelease
lint_exit_code=$?

upload_sarif_to_github 'demo-app/build/reports/lint-results-release.sarif'

exit $lint_exit_code
6 changes: 6 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ steps:
artifact_paths:
- "**/build/test-results/*/*.xml"

- label: "Lint"
command: ".buildkite/commands/lint.sh"
plugins: [$CI_TOOLKIT]
artifact_paths:
- "**/build/reports/lint-results*.*"

- label: "Screenshot tests"
command: |
echo "--- 🧪📸 Screenshot Testing"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/shared-pipeline-vars
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export CI_TOOLKIT="automattic/a8c-ci-toolkit#3.5.1"
export CI_TOOLKIT="automattic/a8c-ci-toolkit#3.7.0"
5 changes: 5 additions & 0 deletions demo-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ android {
buildUponDefaultConfig = true
parallel = false
}
lint {
lintConfig = rootProject.file("lint.xml")
checkDependencies = true
sarifReport = System.getenv()["CI"].toBoolean()
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Warning: Auto-generated file, do not edit.-->
<resources xmlns:tools="http://schemas.android.com/tools">
<string-array name="available_languages" translatable="false" tools:ignore="InconsistentArrays">
<string-array name="available_languages" translatable="false" tools:ignore="InconsistentArrays, UnusedResources">
<item>en_US</item>
<item>ar</item>
<item>de</item>
Expand Down
11 changes: 2 additions & 9 deletions gravatar-ui/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>

<application>
<!-- Lib activities-->
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:theme="@style/Theme.AppCompat.NoActionBar" />
</application>
</manifest>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
2 changes: 1 addition & 1 deletion gravatar-ui/src/main/res/values/available_languages.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Warning: Auto-generated file, do not edit.-->
<resources xmlns:tools="http://schemas.android.com/tools">
<string-array name="available_languages" translatable="false" tools:ignore="InconsistentArrays">
<string-array name="available_languages" translatable="false" tools:ignore="InconsistentArrays, UnusedResources">
<item>en_US</item>
<item>ar</item>
<item>de</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ package com.gravatar.services

import okhttp3.Interceptor
import okhttp3.Response
import java.time.Duration
import java.util.concurrent.TimeUnit

private const val TIMEOUT_DURATION = 5L
private const val TIMEOUT_DURATION_MILLIS = 5 * 60 * 1000 // 5 minutes

/**
* Increases the timeout for the avatar upload request
*/
internal class AvatarUploadTimeoutInterceptor(
private val timeout: Duration = Duration.ofMinutes(TIMEOUT_DURATION),
private val timeoutMillis: Int = TIMEOUT_DURATION_MILLIS,
) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request()
val newChain = if (request.method == "POST" && request.url.encodedPath == "/v3/me/avatars") {
chain.withConnectTimeout(timeout.toMillis().toInt(), TimeUnit.MILLISECONDS)
.withReadTimeout(timeout.toMillis().toInt(), TimeUnit.MILLISECONDS)
.withWriteTimeout(timeout.toMillis().toInt(), TimeUnit.MILLISECONDS)
chain.withConnectTimeout(timeoutMillis, TimeUnit.MILLISECONDS)
.withReadTimeout(timeoutMillis, TimeUnit.MILLISECONDS)
.withWriteTimeout(timeoutMillis, TimeUnit.MILLISECONDS)
} else {
chain
}
Expand Down
15 changes: 15 additions & 0 deletions lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<lint>
<!-- i18n issues are ignored as the process is handled via GlotPress -->
<issue id="MissingTranslation" severity="ignore" />
<issue id="ExtraTranslation" severity="ignore" />

<issue id="UnusedResources" severity="error">
<ignore path="demo-app"/>
</issue>

<!-- The special id "all" matches all issues but is only consulted if there is no specific match -->
<!-- https://googlesamples.github.io/android-custom-lint-rules/user-guide.md.html#configuringusinglint.xmlfiles -->
<issue id="all" >
<ignore path="demo-app"/>
</issue>
</lint>

0 comments on commit 1e3fe8f

Please sign in to comment.