Skip to content

Commit 6c5a847

Browse files
committed
build(ci): auto-opt in new modules to CI lint
By defining a 'lintAll' gradle task Related to issue 21063 Assisted-by: Claude Opus 4.7 - all but comments
1 parent 2ea72a6 commit 6c5a847

3 files changed

Lines changed: 25 additions & 12 deletions

File tree

.github/workflows/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ following scripts before submitting a PR.
1111

1212
Alternately, you may run the actions on your fork of `Anki-Android`.
1313

14-
| **Job** | **Command** | **Comments** |
15-
|------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
16-
| [Lint (Kotlin)](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/lint.yml) | `./gradlew lintPlayDebug :api:lintDebug :libanki:lintDebug ktLintCheck lintVitalFullRelease lint-rules:test --daemon` | Android lint rules, formatting and tests for lint rules |
17-
| [Lint (JavaScript)](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/lint.yml) | See script | Prettier, lint & code formatting |
18-
| [Unit Tests](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/tests_unit.yml) | `./gradlew jacocoUnitTestReport --daemon` | Unit tests for the Android Project |
19-
| [Emulator Tests](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/tests_emulator.yml) | `TEST_RELEASE_BUILD=true ./gradlew jacocoAndroidTestReport --daemon` | Emulator tests for the Android Project |
20-
| [CodeQL](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/codeql.yml) | N/A | GitHub-only check.<br/>[Docs](https://codeql.github.com/) |
14+
| **Job** | **Command** | **Comments** |
15+
|------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-----------------------------------------------------------|
16+
| [Lint (Kotlin)](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/lint.yml) | `./gradlew lintAll ktLintCheck lintVitalFullRelease lint-rules:test --daemon` | Android lint rules, formatting and tests for lint rules |
17+
| [Lint (JavaScript)](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/lint.yml) | See script | Prettier, lint & code formatting |
18+
| [Unit Tests](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/tests_unit.yml) | `./gradlew jacocoUnitTestReport --daemon` | Unit tests for the Android Project |
19+
| [Emulator Tests](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/tests_emulator.yml) | `TEST_RELEASE_BUILD=true ./gradlew jacocoAndroidTestReport --daemon` | Emulator tests for the Android Project |
20+
| [CodeQL](https://github.com/ankidroid/Anki-Android/blob/main/.github/workflows/codeql.yml) | N/A | GitHub-only check.<br/>[Docs](https://codeql.github.com/) |
2121

2222
## Other Workflows
2323

.github/workflows/lint.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,10 @@ jobs:
5353
command: ./gradlew :AnkiDroid:compilePlayDebugJavaWithJavac compileLint lint-rules:compileTestJava --daemon
5454

5555
- name: Run Lint Debug
56-
# "lint" is run under the 'Amazon' flavor, so slow in CI
57-
# "lintPlayRelease" doesn't test androidTest
58-
# "lintPlayDebug" doesn't test the API
56+
# "lintAll" opts in all but :AnkiDroid to lint, pinning :AnkiDroid to lintPlayDebug
5957
# "lintVitalFullRelease": if `main` resources are only used in `androidTest` (#15741)
60-
6158
# update workflows/README.md when modifying this line
62-
run: ./gradlew lintPlayDebug :api:lintDebug :libanki:lintDebug ktLintCheck lintVitalFullRelease lint-rules:test --daemon
59+
run: ./gradlew lintAll ktLintCheck lintVitalFullRelease lint-rules:test --daemon
6360

6461
# update workflows/README.md when modifying commands
6562
lintJavascript:

build.gradle.kts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ subprojects {
135135
}
136136
}
137137

138+
// Opt all modules in to lint (with :AnkiDroid pinned to one flavor: 'Play')
139+
val lintAll = tasks.register("lintAll") {
140+
group = "verification"
141+
description = "Runs lint on every module."
142+
dependsOn(":AnkiDroid:lintPlayDebug") // specify 'Play' explicitly so other flavors don't run
143+
}
144+
145+
subprojects {
146+
if (path == ":AnkiDroid") return@subprojects // pinned above to avoid other flavors
147+
afterEvaluate {
148+
// 'lintDebug' applies to all Android modules; 'lint' for all JVM modules
149+
(tasks.findByName("lintDebug") ?: tasks.findByName("lint"))
150+
?.let { lintAll.configure { dependsOn(it) } }
151+
}
152+
}
153+
138154
val jvmVersion = Jvm.current().javaVersion?.majorVersion.parseIntOrDefault(defaultValue = 0)
139155
val minSdk: String = libs.versions.minSdk.get()
140156
val jvmVersionLowerBound = 21

0 commit comments

Comments
 (0)