From 01d9c0d3a79588f00b5833f4d0b1378d9267731f Mon Sep 17 00:00:00 2001 From: Josh Feinberg <15068619+joshafeinberg@users.noreply.github.com> Date: Fri, 11 Aug 2023 11:26:57 -0500 Subject: [PATCH 1/4] Add check to see if task exists on project before adding dependency --- .../affectedmoduledetector/AffectedModuleDetectorPlugin.kt | 5 +++-- sample/build.gradle | 6 ------ sample/sample-core/build.gradle | 1 + 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetectorPlugin.kt b/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetectorPlugin.kt index 0f563d58..fd6cc2b5 100644 --- a/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetectorPlugin.kt +++ b/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetectorPlugin.kt @@ -171,11 +171,12 @@ class AffectedModuleDetectorPlugin : Plugin { project.pluginManager.withPlugin(pluginId) { getAffectedPath(testType, project)?.let { path -> - if (AffectedModuleDetector.isProjectProvided(project) && !isExcludedModule(config, path)) { + val pathOrNull = project.tasks.findByPath(path) + if (AffectedModuleDetector.isProjectProvided(project) && !isExcludedModule(config, path) && pathOrNull != null) { task.dependsOn(path) } - project.tasks.findByPath(path)?.onlyIf { task -> + pathOrNull?.onlyIf { task -> when { !AffectedModuleDetector.isProjectEnabled(task.project) -> true else -> AffectedModuleDetector.isProjectAffected(task.project) diff --git a/sample/build.gradle b/sample/build.gradle index c1ee6c4c..035333d4 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -19,10 +19,6 @@ buildscript { } } -plugins { - id("io.gitlab.arturbosch.detekt") version "1.20.0" -} - apply plugin: "org.jlleitschuh.gradle.ktlint" apply plugin: "com.dropbox.affectedmoduledetector" @@ -47,8 +43,6 @@ affectedModuleDetector { } allprojects { - apply plugin: Dependencies.Libs.DETEKT_PLUGIN - repositories { google() mavenCentral() diff --git a/sample/sample-core/build.gradle b/sample/sample-core/build.gradle index 76769f0c..b724fe2c 100644 --- a/sample/sample-core/build.gradle +++ b/sample/sample-core/build.gradle @@ -3,6 +3,7 @@ import com.dropbox.sample.Dependencies plugins { id 'com.android.library' id 'kotlin-android' + id("io.gitlab.arturbosch.detekt") version "1.20.0" } affectedTestConfiguration { From 6e544adb534846d026f84965da92e41bc78c039d Mon Sep 17 00:00:00 2001 From: Josh Feinberg <15068619+joshafeinberg@users.noreply.github.com> Date: Fri, 11 Aug 2023 11:32:11 -0500 Subject: [PATCH 2/4] Fix java --- .github/workflows/ci_test_and_publish.yml | 10 ++++++---- .github/workflows/sample_app.yml | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_test_and_publish.yml b/.github/workflows/ci_test_and_publish.yml index 44086bc7..9e8ee81a 100644 --- a/.github/workflows/ci_test_and_publish.yml +++ b/.github/workflows/ci_test_and_publish.yml @@ -20,9 +20,10 @@ jobs: uses: actions/checkout@v2 - name: Set up our JDK environment - uses: actions/setup-java@v1.4.3 + uses: actions/setup-java@v3 with: - java-version: 1.8 + distribution: 'zulu' + java-version: '11' - name: Upload Artifacts run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel @@ -56,9 +57,10 @@ jobs: uses: actions/checkout@v2 - name: Set up our JDK environment - uses: actions/setup-java@v1.4.3 + uses: actions/setup-java@v3 with: - java-version: 1.8 + distribution: 'zulu' + java-version: '11' - name: Run tests uses: reactivecircus/android-emulator-runner@v2 with: diff --git a/.github/workflows/sample_app.yml b/.github/workflows/sample_app.yml index e3ae941d..8d031745 100644 --- a/.github/workflows/sample_app.yml +++ b/.github/workflows/sample_app.yml @@ -17,9 +17,10 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Set up our JDK environment - uses: actions/setup-java@v1.4.3 + uses: actions/setup-java@v3 with: - java-version: 1.8 + distribution: 'zulu' + java-version: '11' - name: Build sample run: | ./gradlew :affectedmoduledetector:publishToMavenLocal From a9e9436b10e2bd62d0849f4b2c3b099a8bdd4fe7 Mon Sep 17 00:00:00 2001 From: Josh Feinberg <15068619+joshafeinberg@users.noreply.github.com> Date: Fri, 11 Aug 2023 13:03:08 -0500 Subject: [PATCH 3/4] Switch emulator --- .github/workflows/ci_test_and_publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_test_and_publish.yml b/.github/workflows/ci_test_and_publish.yml index 9e8ee81a..453f31e7 100644 --- a/.github/workflows/ci_test_and_publish.yml +++ b/.github/workflows/ci_test_and_publish.yml @@ -50,7 +50,7 @@ jobs: fail-fast: false matrix: api-level: - - 29 + - 31 steps: - name: Checkout @@ -64,7 +64,7 @@ jobs: - name: Run tests uses: reactivecircus/android-emulator-runner@v2 with: - api-level: 29 + api-level: 31 script: ./gradlew assemble testCoverage env: API_LEVEL: ${{ matrix.api-level }} From 1741ca9329dca85a602b1d25c368efa13c610b6d Mon Sep 17 00:00:00 2001 From: Josh Feinberg <15068619+joshafeinberg@users.noreply.github.com> Date: Fri, 11 Aug 2023 13:22:46 -0500 Subject: [PATCH 4/4] Update emulator script to use API 31 --- .github/workflows/ci_test_and_publish.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_test_and_publish.yml b/.github/workflows/ci_test_and_publish.yml index 453f31e7..40e6c44e 100644 --- a/.github/workflows/ci_test_and_publish.yml +++ b/.github/workflows/ci_test_and_publish.yml @@ -64,8 +64,13 @@ jobs: - name: Run tests uses: reactivecircus/android-emulator-runner@v2 with: - api-level: 31 - script: ./gradlew assemble testCoverage + api-level: 31 + profile: Nexus 6 + arch: x86_64 + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true + script: ./gradlew assemble testCoverage env: API_LEVEL: ${{ matrix.api-level }} - name: Upload code coverage