-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mbs 9655 Extract test summary logic from runner (#587)
Co-authored-by: Sergey Boishtyan <ssboishtyan@avito.ru>
- Loading branch information
1 parent
e2addaa
commit 53fe9d9
Showing
44 changed files
with
685 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/FlakyReportStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.avito.ci.steps | ||
|
||
import com.android.build.gradle.internal.tasks.factory.dependsOn | ||
import com.avito.impact.configuration.internalModule | ||
import com.avito.instrumentation.extractReportCoordinates | ||
import com.avito.instrumentation.instrumentationTask | ||
import com.avito.test.summary.flakyReportTask | ||
import com.avito.test.summary.testSummaryPluginId | ||
import org.gradle.api.Project | ||
import org.gradle.api.Task | ||
import org.gradle.api.tasks.TaskProvider | ||
|
||
class FlakyReportStep(context: String, name: String) : SuppressibleBuildStep(context, name), | ||
ImpactAnalysisAwareBuildStep by ImpactAnalysisAwareBuildStep.Impl() { | ||
|
||
var configuration: String = "" | ||
|
||
override fun registerTask(project: Project, rootTask: TaskProvider<out Task>) { | ||
require(project.pluginManager.hasPlugin(testSummaryPluginId)) { | ||
"FlakyReport step can't be initialized without $testSummaryPluginId plugin applied" | ||
} | ||
|
||
require(configuration.isNotBlank()) { | ||
"FlakyReport step can't be initialized without provided instrumentation configuration" | ||
} | ||
|
||
if (useImpactAnalysis && !project.internalModule.isModified()) return | ||
|
||
val instrumentationTask = project.tasks.instrumentationTask(configuration) | ||
|
||
val flakyReportTask = project.tasks.flakyReportTask() | ||
flakyReportTask.configure { | ||
it.dependsOn(instrumentationTask) | ||
it.reportCoordinates.set(instrumentationTask.extractReportCoordinates()) | ||
} | ||
rootTask.dependsOn(flakyReportTask) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/TestSummaryStep.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.avito.ci.steps | ||
|
||
import com.android.build.gradle.internal.tasks.factory.dependsOn | ||
import com.avito.impact.configuration.internalModule | ||
import com.avito.instrumentation.extractReportCoordinates | ||
import com.avito.instrumentation.instrumentationTask | ||
import com.avito.test.summary.testSummaryPluginId | ||
import com.avito.test.summary.testSummaryTask | ||
import org.gradle.api.Project | ||
import org.gradle.api.Task | ||
import org.gradle.api.tasks.TaskProvider | ||
|
||
class TestSummaryStep(context: String, name: String) : SuppressibleBuildStep(context, name), | ||
ImpactAnalysisAwareBuildStep by ImpactAnalysisAwareBuildStep.Impl() { | ||
|
||
var configuration: String = "" | ||
|
||
override fun registerTask(project: Project, rootTask: TaskProvider<out Task>) { | ||
require(project.pluginManager.hasPlugin(testSummaryPluginId)) { | ||
"TestSummary step can't be initialized without $testSummaryPluginId plugin applied" | ||
} | ||
|
||
require(configuration.isNotBlank()) { | ||
"TestSummary step can't be initialized without provided instrumentation configuration" | ||
} | ||
|
||
if (useImpactAnalysis && !project.internalModule.isModified()) return | ||
|
||
val instrumentationTask = project.tasks.instrumentationTask(configuration) | ||
|
||
val testSummaryTask = project.tasks.testSummaryTask() | ||
testSummaryTask.configure { | ||
it.dependsOn(instrumentationTask) | ||
it.reportCoordinates.set(instrumentationTask.extractReportCoordinates()) | ||
} | ||
rootTask.dependsOn(testSummaryTask) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
subprojects/gradle/cd/src/test/kotlin/com/avito/ci/steps/TestSummaryStepTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package com.avito.ci.steps | ||
|
||
import com.avito.test.gradle.TestProjectGenerator | ||
import com.avito.test.gradle.ciRun | ||
import com.avito.test.gradle.module.AndroidAppModule | ||
import com.avito.test.summary.testSummaryExtensionName | ||
import com.avito.test.summary.testSummaryPluginId | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.io.TempDir | ||
import java.io.File | ||
|
||
internal class TestSummaryStepTest { | ||
|
||
@Test | ||
fun testSummary(@TempDir projectDir: File) { | ||
generateProject( | ||
projectDir, | ||
""" | ||
testSummary { | ||
configuration = "ui" | ||
} | ||
""".trimIndent() | ||
) | ||
|
||
ciRun( | ||
projectDir, | ||
"fullCheck", | ||
dryRun = true | ||
) | ||
.assertThat() | ||
.buildSuccessful() | ||
.tasksShouldBeTriggered( | ||
":app:instrumentationUi", | ||
":app:testSummary", | ||
":app:fullCheck" | ||
) | ||
.inOrder() | ||
} | ||
|
||
@Test | ||
fun flakyReport(@TempDir projectDir: File) { | ||
generateProject( | ||
projectDir, | ||
""" | ||
flakyReport { | ||
configuration = "ui" | ||
} | ||
""".trimIndent() | ||
) | ||
|
||
ciRun( | ||
projectDir, | ||
"fullCheck", | ||
dryRun = true | ||
) | ||
.assertThat() | ||
.buildSuccessful() | ||
.tasksShouldBeTriggered( | ||
":app:instrumentationUi", | ||
":app:flakyReport", | ||
":app:fullCheck" | ||
) | ||
.inOrder() | ||
} | ||
|
||
private fun generateProject(projectDir: File, step: String) { | ||
TestProjectGenerator( | ||
plugins = listOf("com.avito.android.impact"), | ||
modules = listOf( | ||
AndroidAppModule( | ||
name = "app", | ||
plugins = listOf( | ||
testSummaryPluginId, | ||
"com.avito.android.instrumentation-tests", | ||
"com.avito.android.cd" | ||
), | ||
buildGradleExtra = """ | ||
import static com.avito.instrumentation.reservation.request.Device.LocalEmulator | ||
android { | ||
defaultConfig { | ||
testInstrumentationRunner = "no_matter" | ||
} | ||
} | ||
$testSummaryExtensionName { | ||
reportsHost = "stub" | ||
} | ||
instrumentation { | ||
sentryDsn = "stub" | ||
slackToken = "stub" | ||
registry = "stub" | ||
configurations { | ||
ui { | ||
targets { | ||
api29 { | ||
deviceName = "api29" | ||
scheduling { | ||
quota { | ||
minimumSuccessCount = 1 | ||
} | ||
staticDevicesReservation { | ||
device = LocalEmulator.device(27) | ||
count = 1 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
builds { | ||
fullCheck { | ||
$step | ||
} | ||
} | ||
""".trimIndent() | ||
) | ||
) | ||
).generateIn(projectDir) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.