fix(build): make slim tests optional

This commit is contained in:
Harsh Shandilya 2023-06-28 10:46:37 +05:30
parent d8a76cf1e7
commit c089e5ae5a
No known key found for this signature in database
3 changed files with 19 additions and 15 deletions

View file

@ -46,7 +46,7 @@ jobs:
- name: Run unit tests
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 # v2.4.2
with:
arguments: --no-configuration-cache --stacktrace check
arguments: --no-configuration-cache --stacktrace check -PslimTests
gradle-home-cache-cleanup: true
cache-read-only: ${{ github.ref != 'refs/heads/main' }}

View file

@ -58,7 +58,7 @@ jobs:
- name: Build project
shell: bash
run: |
./gradlew assemble
./gradlew assemble -PslimTests
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@f6e388ebf0efc915c6c5b165b019ee61a6746a38 # v2.20.1

View file

@ -31,6 +31,7 @@ class AndroidCommonPlugin : Plugin<Project> {
const val COMPILE_SDK = 34
const val MIN_SDK = 26
const val TARGET_SDK = 34
const val SLIM_TESTS_PROPERTY = "slimTests"
}
override fun apply(project: Project) {
@ -68,9 +69,11 @@ class AndroidCommonPlugin : Plugin<Project> {
val libs = catalog.named("libs")
project.dependencies.addProvider("lintChecks", libs.findLibrary("slack-compose-lints").get())
}
}
private fun Project.configureSlimTests() {
private fun Project.configureSlimTests() {
if (!providers.gradleProperty(SLIM_TESTS_PROPERTY).isPresent) {
return
}
// Disable unit test tasks on the release build type for Android Library projects
extensions.findByType<LibraryAndroidComponentsExtension>()?.run {
beforeVariants(selector().withBuildType("release")) {
@ -86,4 +89,5 @@ private fun Project.configureSlimTests() {
it.enableAndroidTest = false
}
}
}
}