From c089e5ae5a163c36b80bfe50577e669e452ce6f1 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 28 Jun 2023 10:46:37 +0530 Subject: [PATCH] fix(build): make slim tests optional --- .github/workflows/ci.yml | 2 +- .github/workflows/codeql_analysis.yml | 2 +- .../claw/gradle/AndroidCommonPlugin.kt | 30 +++++++++++-------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9c08aea..475056b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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' }} diff --git a/.github/workflows/codeql_analysis.yml b/.github/workflows/codeql_analysis.yml index 38168cea..56ee2e5a 100644 --- a/.github/workflows/codeql_analysis.yml +++ b/.github/workflows/codeql_analysis.yml @@ -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 diff --git a/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/AndroidCommonPlugin.kt b/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/AndroidCommonPlugin.kt index b024a73c..bcb3aab4 100644 --- a/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/AndroidCommonPlugin.kt +++ b/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/AndroidCommonPlugin.kt @@ -31,6 +31,7 @@ class AndroidCommonPlugin : Plugin { 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,22 +69,25 @@ class AndroidCommonPlugin : Plugin { val libs = catalog.named("libs") project.dependencies.addProvider("lintChecks", libs.findLibrary("slack-compose-lints").get()) } -} -private fun Project.configureSlimTests() { - // Disable unit test tasks on the release build type for Android Library projects - extensions.findByType()?.run { - beforeVariants(selector().withBuildType("release")) { - (it as HasUnitTestBuilder).enableUnitTest = false - it.enableAndroidTest = false + 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()?.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. - extensions.findByType()?.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. + extensions.findByType()?.run { + beforeVariants(selector().withBuildType("release")) { + (it as HasUnitTestBuilder).enableUnitTest = false + it.enableAndroidTest = false + } } } }