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

View file

@ -58,7 +58,7 @@ jobs:
- name: Build project - name: Build project
shell: bash shell: bash
run: | run: |
./gradlew assemble ./gradlew assemble -PslimTests
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@f6e388ebf0efc915c6c5b165b019ee61a6746a38 # v2.20.1 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 COMPILE_SDK = 34
const val MIN_SDK = 26 const val MIN_SDK = 26
const val TARGET_SDK = 34 const val TARGET_SDK = 34
const val SLIM_TESTS_PROPERTY = "slimTests"
} }
override fun apply(project: Project) { override fun apply(project: Project) {
@ -68,22 +69,25 @@ class AndroidCommonPlugin : Plugin<Project> {
val libs = catalog.named("libs") val libs = catalog.named("libs")
project.dependencies.addProvider("lintChecks", libs.findLibrary("slack-compose-lints").get()) project.dependencies.addProvider("lintChecks", libs.findLibrary("slack-compose-lints").get())
} }
}
private fun Project.configureSlimTests() { private fun Project.configureSlimTests() {
// Disable unit test tasks on the release build type for Android Library projects if (!providers.gradleProperty(SLIM_TESTS_PROPERTY).isPresent) {
extensions.findByType<LibraryAndroidComponentsExtension>()?.run { return
beforeVariants(selector().withBuildType("release")) { }
(it as HasUnitTestBuilder).enableUnitTest = false // Disable unit test tasks on the release build type for Android Library projects
it.enableAndroidTest = false extensions.findByType<LibraryAndroidComponentsExtension>()?.run {
beforeVariants(selector().withBuildType("release")) {
(it as HasUnitTestBuilder).enableUnitTest = false
it.enableAndroidTest = false
}
} }
}
// Disable unit test tasks on the release build type for Android Application projects. // Disable unit test tasks on the release build type for Android Application projects.
extensions.findByType<ApplicationAndroidComponentsExtension>()?.run { extensions.findByType<ApplicationAndroidComponentsExtension>()?.run {
beforeVariants(selector().withBuildType("release")) { beforeVariants(selector().withBuildType("release")) {
(it as HasUnitTestBuilder).enableUnitTest = false (it as HasUnitTestBuilder).enableUnitTest = false
it.enableAndroidTest = false it.enableAndroidTest = false
}
} }
} }
} }