diff --git a/Makefile b/Makefile index bb1d0fee0b..a152659d7a 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ infra?= ci?=false log_level?=-q kubernetesContext?=beta -localFilter?= +testFilter?= includePrefix?= includeAnnotation?= useCompositeBuild=true @@ -12,8 +12,8 @@ instrumentation=Ui params?= -ifdef localFilter -params +=-PlocalFilter=$(localFilter) +ifdef testFilter +params +=-PcustomFilter=$(testFilter) endif ifdef includePrefix diff --git a/build.gradle.kts b/build.gradle.kts index 13e5e2f2d2..4fa783b9b9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -151,8 +151,12 @@ subprojects { } } + filters.register("ci") { + fromSource.excludeFlaky = true + } + val defaultFilter = "default" - val customFilter: String = project.getOptionalStringProperty("localFilter", defaultFilter) + val customFilter: String = project.getOptionalStringProperty("customFilter", defaultFilter) configurationsContainer.register("Local") { reportSkippedTests = true diff --git a/build.sh b/build.sh index cd0760e681..17eb27c88c 100755 --- a/build.sh +++ b/build.sh @@ -12,4 +12,4 @@ runInBuilder "set -e; ./gradlew help; ./gradlew help -PuseCompositeBuild=false; ./gradlew -p subprojects build ${GRADLE_ARGS}; - ./gradlew :samples:test-app:instrumentationUi :samples:test-app-without-backward-compatibility:instrumentationUi :samples:test-app-screenshot-test:instrumentationScreenshot ${GRADLE_ARGS}" + ./gradlew :samples:test-app:instrumentationUi :samples:test-app-without-backward-compatibility:instrumentationUi :samples:test-app-screenshot-test:instrumentationScreenshot -PcustomFilter=ci ${GRADLE_ARGS}" diff --git a/subprojects/gradle/cd/build.gradle.kts b/subprojects/gradle/cd/build.gradle.kts index 94b6c2c39c..407ac1f7f6 100644 --- a/subprojects/gradle/cd/build.gradle.kts +++ b/subprojects/gradle/cd/build.gradle.kts @@ -8,30 +8,31 @@ plugins { dependencies { implementation(gradleApi()) implementation(Dependencies.funktionaleTry) + implementation(project(":common:report-viewer")) implementation(project(":gradle:android")) - implementation(project(":gradle:impact-shared")) - implementation(project(":gradle:impact")) - implementation(project(":gradle:kotlin-dsl-support")) - implementation(project(":gradle:utils")) + implementation(project(":gradle:artifactory-app-backup")) implementation(project(":gradle:ci-logger")) - implementation(project(":gradle:signer")) implementation(project(":gradle:files")) - implementation(project(":gradle:lint-report")) + implementation(project(":gradle:git")) + implementation(project(":gradle:impact")) + implementation(project(":gradle:impact-shared")) implementation(project(":gradle:instrumentation-tests")) - implementation(project(":gradle:artifactory-app-backup")) + implementation(project(":gradle:kotlin-dsl-support")) + implementation(project(":gradle:lint-report")) + implementation(project(":gradle:prosector")) implementation(project(":gradle:qapps")) - implementation(project(":gradle:tms")) + implementation(project(":gradle:signer")) implementation(project(":gradle:teamcity")) - implementation(project(":gradle:prosector")) - implementation(project(":gradle:git")) + implementation(project(":gradle:test-summary")) + implementation(project(":gradle:tms")) implementation(project(":gradle:upload-cd-build-result")) implementation(project(":gradle:upload-to-googleplay")) - implementation(project(":common:report-viewer")) + implementation(project(":gradle:utils")) - testImplementation(project(":gradle:test-project")) - testImplementation(project(":gradle:impact-shared-test-fixtures")) - testImplementation(project(":gradle:artifactory-app-backup-test-fixtures")) testImplementation(project(":common:test-okhttp")) + testImplementation(project(":gradle:artifactory-app-backup-test-fixtures")) + testImplementation(project(":gradle:impact-shared-test-fixtures")) + testImplementation(project(":gradle:test-project")) } configurations.all { diff --git a/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/BuildStepListExtension.kt b/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/BuildStepListExtension.kt index f3005a3951..af3db5bf93 100644 --- a/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/BuildStepListExtension.kt +++ b/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/BuildStepListExtension.kt @@ -5,9 +5,11 @@ import com.avito.ci.steps.BuildStep import com.avito.ci.steps.CompileUiTests import com.avito.ci.steps.ConfigurationCheck import com.avito.ci.steps.DeployStep +import com.avito.ci.steps.FlakyReportStep import com.avito.ci.steps.ImpactAnalysisAwareBuildStep import com.avito.ci.steps.LintCheck import com.avito.ci.steps.MarkReportAsSourceForTMSStep +import com.avito.ci.steps.TestSummaryStep import com.avito.ci.steps.UiTestCheck import com.avito.ci.steps.UnitTestCheck import com.avito.ci.steps.UploadBuildResult @@ -50,6 +52,12 @@ open class BuildStepListExtension( registerFactory(MarkReportAsSourceForTMSStep::class.java) { name -> MarkReportAsSourceForTMSStep(buildStepListName, name) } + registerFactory(TestSummaryStep::class.java) { name -> + TestSummaryStep(buildStepListName, name) + } + registerFactory(FlakyReportStep::class.java) { name -> + FlakyReportStep(buildStepListName, name) + } registerFactory(UploadToQapps::class.java) { name -> UploadToQapps(buildStepListName, artifactsConfig, name) } @@ -123,6 +131,22 @@ open class BuildStepListExtension( configureAndAdd("markReportAsSourceForTMS", action) } + fun testSummary(closure: Closure) { + configureAndAdd("testSummary", closure) + } + + fun testSummary(action: Action) { + configureAndAdd("testSummary", action) + } + + fun flakyReport(closure: Closure) { + configureAndAdd("flakyReport", closure) + } + + fun flakyReport(action: Action) { + configureAndAdd("flakyReport", action) + } + fun uploadToQapps(closure: Closure) { configureAndAdd("uploadToQapps", closure) } diff --git a/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/FlakyReportStep.kt b/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/FlakyReportStep.kt new file mode 100644 index 0000000000..c5e40e6e95 --- /dev/null +++ b/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/FlakyReportStep.kt @@ -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) { + 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) + } +} diff --git a/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/TestSummaryStep.kt b/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/TestSummaryStep.kt new file mode 100644 index 0000000000..4282eb3d15 --- /dev/null +++ b/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/TestSummaryStep.kt @@ -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) { + 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) + } +} diff --git a/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/UiTestCheck.kt b/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/UiTestCheck.kt index 65c906d088..62e4890398 100644 --- a/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/UiTestCheck.kt +++ b/subprojects/gradle/cd/src/main/kotlin/com/avito/ci/steps/UiTestCheck.kt @@ -16,9 +16,7 @@ open class UiTestCheck(context: String, name: String) : SuppressibleBuildStep(co var configurations = mutableListOf() - /** - * нам пока нужна отправка только по запуску на всех устройствах - */ + @Deprecated("remove after 2020.23") var sendStatistics: Boolean = false fun configurations(vararg configs: String) { @@ -55,6 +53,8 @@ open class UiTestCheck(context: String, name: String) : SuppressibleBuildStep(co uiTestTask.get().also { task -> task.suppressFailure.set(this@UiTestCheck.suppressFailures) task.suppressFlaky.set(this@UiTestCheck.suppressFlaky) + + //todo remove after 2020.23 task.sendStatistics.set(this@UiTestCheck.sendStatistics) // TODO: how to switch off impact analysis? diff --git a/subprojects/gradle/cd/src/test/kotlin/com/avito/ci/steps/TestSummaryStepTest.kt b/subprojects/gradle/cd/src/test/kotlin/com/avito/ci/steps/TestSummaryStepTest.kt new file mode 100644 index 0000000000..dd2008e8c9 --- /dev/null +++ b/subprojects/gradle/cd/src/test/kotlin/com/avito/ci/steps/TestSummaryStepTest.kt @@ -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) + } +} diff --git a/subprojects/gradle/instrumentation-tests-test-fixtures/src/main/kotlin/com/avito/instrumentation/FakeInstrumentationConfigurationData.kt b/subprojects/gradle/instrumentation-tests-test-fixtures/src/main/kotlin/com/avito/instrumentation/FakeInstrumentationConfigurationData.kt index 5a4e0b4236..8e3dcb9a86 100644 --- a/subprojects/gradle/instrumentation-tests-test-fixtures/src/main/kotlin/com/avito/instrumentation/FakeInstrumentationConfigurationData.kt +++ b/subprojects/gradle/instrumentation-tests-test-fixtures/src/main/kotlin/com/avito/instrumentation/FakeInstrumentationConfigurationData.kt @@ -12,7 +12,6 @@ fun InstrumentationConfiguration.Data.Companion.createStubInstance( name: String = "name", instrumentationParams: InstrumentationParameters = InstrumentationParameters(), reportSkippedTests: Boolean = true, - reportFlakyTests: Boolean = false, impactAnalysisPolicy: ImpactAnalysisPolicy = ImpactAnalysisPolicy.Off, kubernetesNamespace: String = "kubernetesNamespace", targets: List = emptyList(), @@ -22,7 +21,6 @@ fun InstrumentationConfiguration.Data.Companion.createStubInstance( ): InstrumentationConfiguration.Data = InstrumentationConfiguration.Data( name = name, instrumentationParams = instrumentationParams, - reportFlakyTests = reportFlakyTests, reportSkippedTests = reportSkippedTests, impactAnalysisPolicy = impactAnalysisPolicy, kubernetesNamespace = kubernetesNamespace, diff --git a/subprojects/gradle/instrumentation-tests-test-fixtures/src/main/kotlin/com/avito/instrumentation/FakeInstrumentationTestsActionParams.kt b/subprojects/gradle/instrumentation-tests-test-fixtures/src/main/kotlin/com/avito/instrumentation/FakeInstrumentationTestsActionParams.kt index 3352f4b833..0f7bf39a76 100644 --- a/subprojects/gradle/instrumentation-tests-test-fixtures/src/main/kotlin/com/avito/instrumentation/FakeInstrumentationTestsActionParams.kt +++ b/subprojects/gradle/instrumentation-tests-test-fixtures/src/main/kotlin/com/avito/instrumentation/FakeInstrumentationTestsActionParams.kt @@ -1,8 +1,5 @@ package com.avito.instrumentation -import com.avito.android.stats.StatsDConfig -import com.avito.bitbucket.AtlassianCredentials -import com.avito.bitbucket.BitbucketConfig import com.avito.instrumentation.configuration.InstrumentationConfiguration import com.avito.instrumentation.executing.ExecutionParameters import com.avito.instrumentation.report.FakeReport @@ -10,9 +7,7 @@ import com.avito.instrumentation.report.ReadReport import com.avito.instrumentation.report.Report import com.avito.instrumentation.suite.filter.ImpactAnalysisResult import com.avito.report.model.ReportCoordinates -import com.avito.report.model.Team import com.avito.report.model.createStubInstance -import com.avito.slack.model.SlackChannel import com.avito.utils.gradle.KubernetesCredentials import com.avito.utils.logging.CILogger import java.io.File @@ -45,15 +40,6 @@ fun InstrumentationTestsAction.Params.Companion.createStubInstance( reportViewerUrl: String = "https://reports", kubernetesRegistry: String = "", fileStorageUrl: String = "https://files", - pullRequestId: Int? = null, - bitbucketConfig: BitbucketConfig = BitbucketConfig( - baseUrl = "http://bitbucket", - credentials = AtlassianCredentials("xxx", "xxx"), - projectKey = "AA", - repositorySlug = "android" - ), - statsDConfig: StatsDConfig = StatsDConfig(false, "", "", 0, ""), - unitToChannelMapping: Map = emptyMap(), reportCoordinates: ReportCoordinates = ReportCoordinates.createStubInstance() ) = InstrumentationTestsAction.Params( @@ -78,10 +64,6 @@ fun InstrumentationTestsAction.Params.Companion.createStubInstance( sendStatistics = sendStatistics, slackToken = slackToken, fileStorageUrl = fileStorageUrl, - pullRequestId = pullRequestId, - bitbucketConfig = bitbucketConfig, - statsdConfig = statsDConfig, - unitToChannelMapping = unitToChannelMapping, reportViewerUrl = reportViewerUrl, registry = kubernetesRegistry, reportConfig = Report.Factory.Config.ReportViewerCoordinates( diff --git a/subprojects/gradle/instrumentation-tests/build.gradle.kts b/subprojects/gradle/instrumentation-tests/build.gradle.kts index 965b08f442..f60a1c8989 100644 --- a/subprojects/gradle/instrumentation-tests/build.gradle.kts +++ b/subprojects/gradle/instrumentation-tests/build.gradle.kts @@ -9,40 +9,36 @@ dependencies { api(project(":gradle:kubernetes")) api(project(":common:time")) + implementation(Dependencies.commonsIo) { + because("LogcatBuffer.Impl.tailer needs to consider Charset (https://issues.apache.org/jira/browse/IO-354)") + } + implementation(Dependencies.commonsText) implementation(Dependencies.coroutinesCore) - implementation(project(":gradle:instrumentation-test-impact-analysis")) - implementation(project(":gradle:runner:client")) - implementation(project(":gradle:utils")) - implementation(project(":gradle:ci-logger")) - implementation(project(":gradle:android")) - implementation(project(":gradle:teamcity")) - implementation(project(":gradle:statsd-config")) - implementation(project(":gradle:test-summary")) - implementation(project(":common:report-viewer")) - implementation(project(":gradle:kotlin-dsl-support")) - implementation(project(":gradle:git")) - implementation(project(":gradle:process")) - implementation(project(":gradle:files")) - implementation(project(":gradle:slack")) - implementation(project(":gradle:bitbucket")) + implementation(Dependencies.dexlib) + implementation(Dependencies.funktionaleTry) + implementation(Dependencies.gson) + implementation(Dependencies.kotson) + implementation(Dependencies.retrofit) + implementation(Dependencies.teamcityClient) + implementation(project(":common:composite-exception")) implementation(project(":common:file-storage")) - implementation(project(":common:sentry")) implementation(project(":common:logger")) + implementation(project(":common:report-viewer")) implementation(project(":common:retrace")) + implementation(project(":common:sentry")) implementation(project(":common:test-annotations")) - implementation(project(":common:composite-exception")) + implementation(project(":gradle:android")) + implementation(project(":gradle:ci-logger")) + implementation(project(":gradle:files")) + implementation(project(":gradle:git")) + implementation(project(":gradle:instrumentation-test-impact-analysis")) + implementation(project(":gradle:kotlin-dsl-support")) + implementation(project(":gradle:process")) + implementation(project(":gradle:runner:client")) + implementation(project(":gradle:teamcity")) implementation(project(":gradle:upload-cd-build-result")) + implementation(project(":gradle:utils")) implementation(project(":gradle:worker")) - implementation(Dependencies.dexlib) - implementation(Dependencies.gson) - implementation(Dependencies.teamcityClient) - implementation(Dependencies.commonsText) - implementation(Dependencies.retrofit) - implementation(Dependencies.kotson) - implementation(Dependencies.funktionaleTry) - implementation(Dependencies.commonsIo) { - because("LogcatBuffer.Impl.tailer needs to consider Charset (https://issues.apache.org/jira/browse/IO-354)") - } testImplementation(project(":gradle:test-project")) testImplementation(project(":gradle:logging-test-fixtures")) diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsAction.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsAction.kt index 78564288a1..75a155b60d 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsAction.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsAction.kt @@ -1,7 +1,5 @@ package com.avito.instrumentation -import com.avito.android.stats.StatsDConfig -import com.avito.bitbucket.BitbucketConfig import com.avito.instrumentation.configuration.InstrumentationConfiguration import com.avito.instrumentation.executing.ExecutionParameters import com.avito.instrumentation.finalizer.InstrumentationTestActionFinalizer @@ -9,8 +7,6 @@ import com.avito.instrumentation.report.Report import com.avito.instrumentation.scheduling.TestsScheduler import com.avito.instrumentation.suite.filter.ImpactAnalysisResult import com.avito.report.model.ReportCoordinates -import com.avito.report.model.Team -import com.avito.slack.model.SlackChannel import com.avito.utils.gradle.KubernetesCredentials import com.avito.utils.logging.CILogger import java.io.File @@ -58,7 +54,6 @@ class InstrumentationTestsAction( val executionParameters: ExecutionParameters, val buildId: String, val buildType: String, - val pullRequestId: Int?, val buildUrl: String, val currentBranch: String, val sourceCommitHash: String, @@ -73,9 +68,6 @@ class InstrumentationTestsAction( val slackToken: String, val reportViewerUrl: String, val fileStorageUrl: String, - val bitbucketConfig: BitbucketConfig, - val statsdConfig: StatsDConfig, - val unitToChannelMapping: Map, val registry: String, val reportFactory: Report.Factory, val reportConfig: Report.Factory.Config, diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsPlugin.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsPlugin.kt index 7f18230f16..d6574f53e6 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsPlugin.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsPlugin.kt @@ -117,7 +117,6 @@ class InstrumentationTestsPlugin : Plugin { this.reportViewerConfig.set(extensionData.reportViewer) } this.registry.set(extensionData.registry) - this.unitToChannelMapping.set(extensionData.unitToChannelMapping) this.kubernetesCredentials.set(project.kubernetesCredentials) } diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsPluginApi.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsPluginApi.kt index 0eba09906c..50273721dc 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsPluginApi.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsPluginApi.kt @@ -23,6 +23,13 @@ internal const val preInstrumentationTaskName: String = "preInstrumentation" fun TaskContainer.instrumentationTask(configuration: String): TaskProvider = typedNamed(instrumentationTaskName(configuration)) +@Suppress("UnstableApiUsage") +fun TaskProvider.extractReportCoordinates() = flatMap { task -> + task.instrumentationConfiguration.map { config -> + config.instrumentationParams.reportCoordinates() + } +} + fun TaskContainer.preInstrumentationTask(configuration: String): TaskProvider = typedNamed(preInstrumentationTaskName(configuration)) diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsTask.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsTask.kt index 1ae32b5f45..690cc53d48 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsTask.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/InstrumentationTestsTask.kt @@ -1,8 +1,5 @@ package com.avito.instrumentation -import com.avito.android.stats.statsdConfig -import com.avito.bitbucket.bitbucketConfig -import com.avito.bitbucket.pullRequestId import com.avito.cd.buildOutput import com.avito.gradle.worker.inMemoryWork import com.avito.instrumentation.configuration.ImpactAnalysisPolicy @@ -13,7 +10,6 @@ import com.avito.instrumentation.report.Report import com.avito.instrumentation.suite.filter.ImpactAnalysisResult import com.avito.report.model.ReportCoordinates import com.avito.report.model.Team -import com.avito.slack.model.SlackChannel import com.avito.utils.gradle.KubernetesCredentials import com.avito.utils.logging.ciLogger import org.gradle.api.DefaultTask @@ -26,7 +22,6 @@ import org.gradle.api.tasks.Internal import org.gradle.api.tasks.Optional import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.TaskAction -import org.gradle.kotlin.dsl.mapProperty import org.gradle.kotlin.dsl.property import org.gradle.workers.WorkerExecutor import javax.inject.Inject @@ -120,9 +115,6 @@ abstract class InstrumentationTestsTask @Inject constructor( @Internal val registry = objects.property() - @Internal - val unitToChannelMapping = objects.mapProperty() - @Internal val kubernetesCredentials = objects.property() @@ -172,10 +164,6 @@ abstract class InstrumentationTestsTask @Inject constructor( sendStatistics = sendStatistics.get(), slackToken = slackToken.get(), fileStorageUrl = getFileStorageUrl(), - pullRequestId = project.pullRequestId.orNull, - bitbucketConfig = project.bitbucketConfig.get(), - statsdConfig = project.statsdConfig.get(), - unitToChannelMapping = unitToChannelMapping.get(), reportViewerUrl = reportViewerConfig.orNull?.reportViewerUrl ?: "http://stub", // stub for inmemory report registry = registry.get(), diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/configuration/GradleInstrumentationPluginConfiguration.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/configuration/GradleInstrumentationPluginConfiguration.kt index 769ac8a222..5559aea263 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/configuration/GradleInstrumentationPluginConfiguration.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/configuration/GradleInstrumentationPluginConfiguration.kt @@ -1,7 +1,6 @@ package com.avito.instrumentation.configuration import com.avito.report.model.Team -import com.avito.slack.model.SlackChannel import com.google.common.annotations.VisibleForTesting import groovy.lang.Closure import org.gradle.api.Action @@ -141,9 +140,6 @@ object InstrumentationPluginConfiguration { reportViewer = reportViewer, registry = registry, slackToken = slackToken, - unitToChannelMapping = unitToChannelMap - .map { (k, v) -> Team(k) to SlackChannel(v) } - .toMap(), applicationProguardMapping = applicationProguardMapping, testProguardMapping = testProguardMapping ) @@ -159,7 +155,6 @@ object InstrumentationPluginConfiguration { val reportViewer: ReportViewer?, val registry: String, val slackToken: String, - val unitToChannelMapping: Map, val applicationProguardMapping: File?, val testProguardMapping: File? ) : Serializable { diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/configuration/InstrumentationConfiguration.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/configuration/InstrumentationConfiguration.kt index c54429a3cd..35ebc03d19 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/configuration/InstrumentationConfiguration.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/configuration/InstrumentationConfiguration.kt @@ -10,6 +10,7 @@ abstract class InstrumentationConfiguration(val name: String) { var instrumentationParams: Map = emptyMap() + @Deprecated("remove after 2020.23") var reportFlakyTests = false /** @@ -55,7 +56,6 @@ abstract class InstrumentationConfiguration(val name: String) { return Data( name = name, instrumentationParams = mergedInstrumentationParameters, - reportFlakyTests = reportFlakyTests, reportSkippedTests = reportSkippedTests, impactAnalysisPolicy = impactAnalysisPolicy, kubernetesNamespace = kubernetesNamespace, @@ -72,7 +72,6 @@ abstract class InstrumentationConfiguration(val name: String) { data class Data( val name: String, val instrumentationParams: InstrumentationParameters, - val reportFlakyTests: Boolean, val reportSkippedTests: Boolean, val impactAnalysisPolicy: ImpactAnalysisPolicy, val kubernetesNamespace: String, diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/finalizer/FinalizerFactory.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/finalizer/FinalizerFactory.kt index 0fe5d91cd0..af1a12b7d9 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/finalizer/FinalizerFactory.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/finalizer/FinalizerFactory.kt @@ -1,25 +1,11 @@ package com.avito.instrumentation.finalizer -import com.avito.android.stats.StatsDSender -import com.avito.bitbucket.Bitbucket import com.avito.instrumentation.InstrumentationTestsAction -import com.avito.instrumentation.report.FlakyTestReporterImpl import com.avito.instrumentation.report.HasFailedTestDeterminer import com.avito.instrumentation.report.HasNotReportedTestsDeterminer import com.avito.instrumentation.report.JUnitReportWriter import com.avito.instrumentation.report.Report -import com.avito.instrumentation.report.SendStatisticsActionImpl import com.avito.report.ReportViewer -import com.avito.slack.ConjunctionMessageUpdateCondition -import com.avito.slack.SameAuthorUpdateCondition -import com.avito.slack.SlackClient -import com.avito.slack.SlackConditionalSender -import com.avito.slack.SlackMessageUpdaterDirectlyToThread -import com.avito.slack.TodayMessageCondition -import com.avito.test.summary.GraphiteRunWriter -import com.avito.test.summary.TestSummarySenderImplementation -import com.avito.test.summary.summaryChannel -import com.avito.time.DefaultTimeProvider import com.avito.utils.BuildFailer import com.avito.utils.logging.CILogger import com.google.common.annotations.VisibleForTesting @@ -31,12 +17,9 @@ interface FinalizerFactory { fun create(): InstrumentationTestActionFinalizer class Impl : FinalizerFactory { - - private val params: InstrumentationTestsAction.Params private val sourceReport: Report private val gson: Gson - private val slackClient: SlackClient private val buildFailer: BuildFailer // todo Make generic. Need two realization for InMemory and ReportViewer @@ -48,13 +31,11 @@ interface FinalizerFactory { params: InstrumentationTestsAction.Params, sourceReport: Report, gson: Gson = GsonBuilder().setPrettyPrinting().create(), - buildFailer: BuildFailer, - slackClient: SlackClient + buildFailer: BuildFailer ) { this.params = params this.sourceReport = sourceReport this.gson = gson - this.slackClient = slackClient this.reportViewer = ReportViewer.Impl(params.reportViewerUrl) this.logger = params.logger this.buildFailer = buildFailer @@ -68,8 +49,7 @@ interface FinalizerFactory { params = params, sourceReport = sourceReport, gson = gson, - buildFailer = BuildFailer.RealFailer(), - slackClient = SlackClient.Impl(params.slackToken, workspace = "avito") + buildFailer = BuildFailer.RealFailer() ) override fun create(): InstrumentationTestActionFinalizer { @@ -84,67 +64,12 @@ interface FinalizerFactory { hasNotReportedTestsDeterminer = HasNotReportedTestsDeterminer.Impl(), sourceReport = sourceReport, params = params, - flakyTestReporter = createFlakyTestReporter(), reportViewer = reportViewer, gson = gson, jUnitReportWriter = JUnitReportWriter(reportViewer), buildFailer = buildFailer, - sendStatisticsAction = SendStatisticsActionImpl( - testSummarySender = TestSummarySenderImplementation( - slackClient = slackClient, - reportViewer = reportViewer, - buildUrl = params.buildUrl, - reportCoordinates = params.reportCoordinates, - unitToChannelMapping = params.unitToChannelMapping, - logger = logger - ), - report = sourceReport, - graphiteRunWriter = GraphiteRunWriter(createStatsDSender()), - ciLogger = logger - ), logger = logger ) } - - private fun createStatsDSender(): StatsDSender.Impl { - return StatsDSender.Impl( - config = params.statsdConfig, - logger = { message, error -> - if (error != null) logger.info( - message, - error - ) else logger.debug(message) - } - ) - } - - private fun createFlakyTestReporter(): FlakyTestReporterImpl { - return FlakyTestReporterImpl( - slackClient = SlackConditionalSender( - slackClient = slackClient, - updater = SlackMessageUpdaterDirectlyToThread(slackClient, logger), - condition = ConjunctionMessageUpdateCondition( - listOf( - SameAuthorUpdateCondition("Flaky Test Detector"), - TodayMessageCondition(DefaultTimeProvider()) - ) - ), - logger = logger - ), - summaryChannel = summaryChannel, - messageAuthor = "Flaky Test Detector", - bitbucket = Bitbucket.create( - bitbucketConfig = params.bitbucketConfig, - logger = logger, - pullRequestId = params.pullRequestId - ), - sourceCommitHash = params.sourceCommitHash, - reportViewer = reportViewer, - logger = logger, - buildUrl = params.buildUrl, - currentBranch = params.currentBranch, - reportCoordinates = params.reportCoordinates - ) - } } } diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/finalizer/InstrumentationTestActionFinalizer.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/finalizer/InstrumentationTestActionFinalizer.kt index 36675b3619..a73506c681 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/finalizer/InstrumentationTestActionFinalizer.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/finalizer/InstrumentationTestActionFinalizer.kt @@ -2,12 +2,10 @@ package com.avito.instrumentation.finalizer import com.avito.instrumentation.InstrumentationTestsAction import com.avito.instrumentation.TestRunResult -import com.avito.instrumentation.report.FlakyTestReporter import com.avito.instrumentation.report.HasFailedTestDeterminer import com.avito.instrumentation.report.HasNotReportedTestsDeterminer import com.avito.instrumentation.report.JUnitReportWriter import com.avito.instrumentation.report.Report -import com.avito.instrumentation.report.SendStatisticsAction import com.avito.instrumentation.scheduling.TestsScheduler import com.avito.report.ReportViewer import com.avito.utils.BuildFailer @@ -28,12 +26,10 @@ interface InstrumentationTestActionFinalizer { private val hasNotReportedTestsDeterminer: HasNotReportedTestsDeterminer, private val sourceReport: Report, private val params: InstrumentationTestsAction.Params, - private val flakyTestReporter: FlakyTestReporter, private val reportViewer: ReportViewer, private val jUnitReportWriter: JUnitReportWriter, private val buildFailer: BuildFailer, private val gson: Gson, - private val sendStatisticsAction: SendStatisticsAction, private val logger: CILogger ) : InstrumentationTestActionFinalizer { @@ -57,14 +53,6 @@ interface InstrumentationTestActionFinalizer { sourceReport.finish() - if (params.instrumentationConfiguration.reportFlakyTests) { - flakyTestReporter.reportSummary( - info = testsExecutionResults.flakyInfo - ).onFailure { logger.critical("Can't send flaky test report", it) } - } - - sendStatistics() - val reportViewerUrl = reportViewer.generateReportUrl( params.reportCoordinates, onlyFailures = testRunResult.failed !is HasFailedTestDeterminer.Result.NoFailed @@ -112,13 +100,5 @@ interface InstrumentationTestActionFinalizer { * teamcity XML report processing */ private fun junitFile(outputDir: File): File = File(outputDir, "junit-report.xml") - - private fun sendStatistics() { - if (params.sendStatistics) { - sendStatisticsAction.send() - } else { - logger.debug("Send statistics disabled") - } - } } } diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/ReadReport.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/ReadReport.kt index b3867c3497..bbea026ab8 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/ReadReport.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/ReadReport.kt @@ -16,7 +16,6 @@ interface ReadReport { override fun getTests(): Try> { return reportsFetchApi.getTestsForReportId(id) } - } class ReportCoordinates( @@ -27,6 +26,5 @@ interface ReadReport { override fun getTests(): Try> { return reportsFetchApi.getTestsForRunId(coordinates) } - } -} \ No newline at end of file +} diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/SendStatisticsActionImpl.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/SendStatisticsActionImpl.kt deleted file mode 100644 index d11722bdcc..0000000000 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/SendStatisticsActionImpl.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.avito.instrumentation.report - -import com.avito.test.summary.GraphiteRunWriter -import com.avito.test.summary.TestSummarySender -import com.avito.utils.logging.CILogger - -interface SendStatisticsAction { - fun send() -} - -class SendStatisticsActionImpl( - private val report: Report, - private val testSummarySender: TestSummarySender, - private val graphiteRunWriter: GraphiteRunWriter, - private val ciLogger: CILogger -) : SendStatisticsAction { - - override fun send() { - report.getCrossDeviceTestData().fold( - { suite -> - //todo return try - testSummarySender.send(suite, requireNotNull(report.tryGetId())) - - val request = graphiteRunWriter.write(suite) - request.onFailure { throwable -> - ciLogger.critical("Can't send test run data to graphite", throwable) - } - }, - { throwable -> ciLogger.critical("Can't get suite report", throwable) }) - } -} diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/scheduling/InstrumentationTestsScheduler.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/scheduling/InstrumentationTestsScheduler.kt index f035027423..9bdb0cbac6 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/scheduling/InstrumentationTestsScheduler.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/scheduling/InstrumentationTestsScheduler.kt @@ -2,7 +2,6 @@ package com.avito.instrumentation.scheduling import com.avito.instrumentation.InstrumentationTestsAction import com.avito.instrumentation.executing.TestExecutor -import com.avito.instrumentation.report.FlakyTestInfo import com.avito.instrumentation.report.Report import com.avito.instrumentation.suite.TestSuiteProvider import com.avito.instrumentation.suite.dex.TestSuiteLoader @@ -28,8 +27,6 @@ class InstrumentationTestsScheduler( override fun schedule(): TestsScheduler.Result { filterInfoWriter.writeFilterConfig(params.instrumentationConfiguration.filter) - val flakyTestInfo = FlakyTestInfo() - val testSuite = testSuiteProvider.getTestSuite( tests = testSuiteLoader.loadTestSuite(params.testApk, AllChecks()) ) @@ -48,12 +45,9 @@ class InstrumentationTestsScheduler( testsToRun = testSuite.testsToRun ) - flakyTestInfo.addReport(testsResult) - return TestsScheduler.Result( testSuite = testSuite, - testsResult = testsResult, - flakyInfo = flakyTestInfo.getInfo() + testsResult = testsResult ) } diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/scheduling/TestsScheduler.kt b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/scheduling/TestsScheduler.kt index d76b464b75..6006072c01 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/scheduling/TestsScheduler.kt +++ b/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/scheduling/TestsScheduler.kt @@ -1,6 +1,5 @@ package com.avito.instrumentation.scheduling -import com.avito.instrumentation.report.FlakyInfo import com.avito.instrumentation.suite.TestSuiteProvider import com.avito.report.model.SimpleRunTest import org.funktionale.tries.Try @@ -11,7 +10,6 @@ interface TestsScheduler { data class Result( val testSuite: TestSuiteProvider.TestSuite, - val testsResult: Try>, - val flakyInfo: List + val testsResult: Try> ) } diff --git a/subprojects/gradle/instrumentation-tests/src/test/kotlin/com/avito/instrumentation/InstrumentationTestsActionIntegrationTest.kt b/subprojects/gradle/instrumentation-tests/src/test/kotlin/com/avito/instrumentation/InstrumentationTestsActionIntegrationTest.kt index e89d6d94a2..ef7a78f02f 100644 --- a/subprojects/gradle/instrumentation-tests/src/test/kotlin/com/avito/instrumentation/InstrumentationTestsActionIntegrationTest.kt +++ b/subprojects/gradle/instrumentation-tests/src/test/kotlin/com/avito/instrumentation/InstrumentationTestsActionIntegrationTest.kt @@ -21,7 +21,6 @@ import com.avito.report.model.Report import com.avito.report.model.ReportCoordinates import com.avito.report.model.SimpleRunTest import com.avito.report.model.createStubInstance -import com.avito.slack.FakeSlackClient import com.avito.utils.FakeBuildFailer import com.avito.utils.logging.CILogger import com.avito.utils.logging.FakeCILogger @@ -170,7 +169,6 @@ internal class InstrumentationTestsActionIntegrationTest { finalizer = FinalizerFactory.Impl( params = params, sourceReport = Impl(reportsApi, logger, reportCoordinates, params.buildId), - slackClient = FakeSlackClient(), buildFailer = buildFailer ).create() ) diff --git a/subprojects/gradle/test-summary/build.gradle.kts b/subprojects/gradle/test-summary/build.gradle.kts index 067a819132..bdf675eab4 100644 --- a/subprojects/gradle/test-summary/build.gradle.kts +++ b/subprojects/gradle/test-summary/build.gradle.kts @@ -1,20 +1,29 @@ plugins { + id("java-gradle-plugin") id("kotlin") `maven-publish` id("com.jfrog.bintray") } dependencies { - implementation(project(":gradle:kotlin-dsl-support")) implementation(project(":common:report-viewer")) - implementation(project(":common:statsd")) - implementation(project(":gradle:utils")) + implementation(project(":common:time")) implementation(project(":gradle:ci-logger")) + implementation(project(":gradle:kotlin-dsl-support")) implementation(project(":gradle:slack")) - implementation(Dependencies.coroutinesCore) implementation(Dependencies.funktionaleTry) implementation(Dependencies.okhttp) testImplementation(project(":gradle:test-project")) testImplementation(project(":common:report-viewer-test-fixtures")) } + +gradlePlugin { + plugins { + create("testSummary") { + id = "com.avito.android.test-summary" + implementationClass = "com.avito.test.summary.TestSummaryPlugin" + displayName = "Instrumentation tests summary" + } + } +} diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyInfo.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyInfo.kt new file mode 100644 index 0000000000..06bacbd6bd --- /dev/null +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyInfo.kt @@ -0,0 +1,9 @@ +package com.avito.test.summary + +import com.avito.report.model.TestName + +internal data class FlakyInfo( + val testName: TestName, + val attempts: Int, + val wastedTimeEstimateInSec: Int +) diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyReportTask.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyReportTask.kt new file mode 100644 index 0000000000..4037380405 --- /dev/null +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyReportTask.kt @@ -0,0 +1,98 @@ +package com.avito.test.summary + +import com.avito.report.ReportViewer +import com.avito.report.ReportsApi +import com.avito.report.model.ReportCoordinates +import com.avito.slack.ConjunctionMessageUpdateCondition +import com.avito.slack.SameAuthorUpdateCondition +import com.avito.slack.SlackClient +import com.avito.slack.SlackConditionalSender +import com.avito.slack.SlackMessageUpdaterDirectlyToThread +import com.avito.slack.TodayMessageCondition +import com.avito.slack.model.SlackChannel +import com.avito.time.DefaultTimeProvider +import com.avito.time.TimeProvider +import com.avito.utils.logging.CILogger +import com.avito.utils.logging.ciLogger +import org.gradle.api.DefaultTask +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.TaskAction + +abstract class FlakyReportTask : DefaultTask() { + + @get:Input + abstract val reportCoordinates: Property + + @get:Input + abstract val summaryChannel: Property + + @get:Input + abstract val slackUsername: Property + + @get:Input + abstract val buildUrl: Property + + @get:Input + abstract val currentBranch: Property + + @get:Internal + abstract val timeProvider: Property + + @get:Internal + abstract val slackClient: Property + + @get:Internal + abstract val reportsApi: Property + + @get:Internal + abstract val reportViewer: Property + + @TaskAction + fun doWork() { + val flakyTestInfo = FlakyTestInfo() + + flakyTestInfo.addReport(reportsApi.get().getTestsForRunId(reportCoordinates.get())) + + createFlakyTestReporter( + summaryChannel = summaryChannel.get(), + slackUsername = slackUsername.get(), + reportCoordinates = reportCoordinates.get(), + reportViewer = reportViewer.get(), + buildUrl = buildUrl.get(), + currentBranch = currentBranch.get(), + logger = ciLogger + ).reportSummary(flakyTestInfo.getInfo()) + } + + private fun createFlakyTestReporter( + summaryChannel: SlackChannel, + slackUsername: String, + reportCoordinates: ReportCoordinates, + reportViewer: ReportViewer, + buildUrl: String, + currentBranch: String, + logger: CILogger + ): FlakyTestReporterImpl { + return FlakyTestReporterImpl( + slackClient = SlackConditionalSender( + slackClient = slackClient.get(), + updater = SlackMessageUpdaterDirectlyToThread(slackClient.get(), logger), + condition = ConjunctionMessageUpdateCondition( + listOf( + SameAuthorUpdateCondition(slackUsername), + TodayMessageCondition(DefaultTimeProvider()) + ) + ), + logger = logger + ), + summaryChannel = summaryChannel, + messageAuthor = slackUsername, + reportViewer = reportViewer, + buildUrl = buildUrl, + currentBranch = currentBranch, + reportCoordinates = reportCoordinates + ) + } +} diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/FlakyTestInfo.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyTestInfo.kt similarity index 90% rename from subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/FlakyTestInfo.kt rename to subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyTestInfo.kt index f5e8d3aa41..f49f4989c5 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/FlakyTestInfo.kt +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyTestInfo.kt @@ -1,10 +1,10 @@ -package com.avito.instrumentation.report +package com.avito.test.summary import com.avito.report.model.SimpleRunTest import com.avito.report.model.TestName import org.funktionale.tries.Try -class FlakyTestInfo { +internal class FlakyTestInfo { private val info: MutableList = mutableListOf() @@ -41,9 +41,3 @@ class FlakyTestInfo { } } } - -data class FlakyInfo( - val testName: TestName, - val attempts: Int, - val wastedTimeEstimateInSec: Int -) diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyTestReporter.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyTestReporter.kt new file mode 100644 index 0000000000..1b8a2cfc70 --- /dev/null +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyTestReporter.kt @@ -0,0 +1,9 @@ +package com.avito.test.summary + +import org.funktionale.tries.Try + +internal interface FlakyTestReporter { + fun reportSummary( + info: List + ): Try +} diff --git a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/FlakyTestReporterImpl.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyTestReporterImpl.kt similarity index 61% rename from subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/FlakyTestReporterImpl.kt rename to subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyTestReporterImpl.kt index ae31f149d6..ab1e9916d3 100644 --- a/subprojects/gradle/instrumentation-tests/src/main/kotlin/com/avito/instrumentation/report/FlakyTestReporterImpl.kt +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/FlakyTestReporterImpl.kt @@ -1,7 +1,5 @@ -package com.avito.instrumentation.report +package com.avito.test.summary -import com.avito.bitbucket.Bitbucket -import com.avito.bitbucket.InsightData import com.avito.report.ReportViewer import com.avito.report.model.ReportCoordinates import com.avito.report.model.Team @@ -9,33 +7,21 @@ import com.avito.slack.SlackMessageSender import com.avito.slack.model.SlackChannel import com.avito.slack.model.SlackMessage import com.avito.slack.model.SlackSendMessageRequest -import com.avito.utils.logging.CILogger import org.funktionale.tries.Try -interface FlakyTestReporter { - fun reportSummary( - info: List - ): Try -} - -class FlakyTestReporterImpl( +internal class FlakyTestReporterImpl( private val slackClient: SlackMessageSender, private val summaryChannel: SlackChannel, private val messageAuthor: String, - private val bitbucket: Bitbucket, - private val sourceCommitHash: String, private val reportViewer: ReportViewer, private val buildUrl: String, private val currentBranch: String, - private val reportCoordinates: ReportCoordinates, - private val logger: CILogger + private val reportCoordinates: ReportCoordinates ) : FlakyTestReporter { private val emoji = ":open-eye-laugh-crying:" - override fun reportSummary( - info: List - ): Try = Try { + override fun reportSummary(info: List): Try = Try { if (info.isNotEmpty()) { @@ -45,7 +31,7 @@ class FlakyTestReporterImpl( return@Try } - val slackMessage = sendMessage( + sendMessage( badTests = topBadTests, channel = summaryChannel, buildUrl = buildUrl, @@ -56,28 +42,6 @@ class FlakyTestReporterImpl( team = Team.UNDEFINED ).toString() ) - - slackMessage.map { message -> - bitbucket.addInsightReport( - sourceCommitHash = sourceCommitHash, - key = "flaky-test-reporter", - title = "Flaky tests report in slack", - details = "Билд шел дольше чем нужно из-за flaky тестов, отчет по ссылке", - link = message.link, - data = listOf( - InsightData.Number( - title = "Кол-во flaky тестов", - value = info.size - ), - InsightData.Number( - title = "Суммарное кол-во перезапусков", - value = info.sumBy { it.attempts }), - InsightData.Duration( - title = "Суммарное потраченное время в сек", - value = info.sumBy { it.wastedTimeEstimateInSec } * 1000L) - ) - ) - }.onFailure { logger.critical("Can't send flaky report", it) } } } diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/GraphiteRunWriter.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/GraphiteRunWriter.kt deleted file mode 100644 index 39602a2e99..0000000000 --- a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/GraphiteRunWriter.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.avito.test.summary - -import com.avito.android.stats.GaugeMetric -import com.avito.android.stats.StatsDSender -import com.avito.report.model.CrossDeviceSuite -import org.funktionale.tries.Try - -class GraphiteRunWriter(private val statsSender: StatsDSender) { - - private val prefix = "avito.test.instrumentation.run" - - fun write(testData: CrossDeviceSuite): Try = Try { - statsSender.send(prefix, GaugeMetric("success", testData.success)) - statsSender.send( - prefix, - GaugeMetric("failed", testData.failedOnAllDevicesCount + testData.failedOnSomeDevicesCount) - ) - statsSender.send(prefix, GaugeMetric("manual", testData.manualCount)) - statsSender.send(prefix, GaugeMetric("automated", testData.automatedCount)) - - statsSender.send(prefix, GaugeMetric("inconsistent", testData.inconsistentCount)) - - //todo довольно странная метрика в измерении всех девайсов, считали неверно - //statsSender.send(prefix, GaugeMetric("flaky", testData.success)) - //statsSender.send(prefix, GaugeMetric("stable", testData.success)) - - - //todo научится отправлять сначала в репорт - //statsSender.send(prefix, GaugeMetric("lost", testData.inconsistentCount)) - } -} diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/SlackEmojiProvider.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/SlackEmojiProvider.kt index 5bf5c37720..3d842b3a67 100644 --- a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/SlackEmojiProvider.kt +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/SlackEmojiProvider.kt @@ -1,6 +1,6 @@ package com.avito.test.summary -class SlackEmojiProvider { +internal class SlackEmojiProvider { fun emojiName(health: Int): String = when (health) { in 100..Int.MAX_VALUE -> ":stfgod0:" diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryExtension.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryExtension.kt new file mode 100644 index 0000000000..c5f0d2bfd8 --- /dev/null +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryExtension.kt @@ -0,0 +1,32 @@ +package com.avito.test.summary + +import com.avito.slack.model.SlackChannel +import org.gradle.api.model.ObjectFactory +import org.gradle.kotlin.dsl.mapProperty +import org.gradle.kotlin.dsl.property +import javax.inject.Inject + +open class TestSummaryExtension @Inject constructor(objects: ObjectFactory) { + + val slackToken = objects.property() + + val slackWorkspace = objects.property() + + val reportsHost = objects.property() + + val summaryChannel = objects.property() + + val buildUrl = objects.property() + + val currentBranch = objects.property() + + val reportViewerUrl = objects.property() + + val unitToChannelMapping = objects.mapProperty() + + val mentionOnFailures = objects.setProperty(String::class.java) + + val reserveSlackChannel = objects.property() + + val slackUserName = objects.property() +} diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryPlugin.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryPlugin.kt new file mode 100644 index 0000000000..12c8864411 --- /dev/null +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryPlugin.kt @@ -0,0 +1,90 @@ +package com.avito.test.summary + +import com.avito.logger.Logger +import com.avito.report.ReportViewer +import com.avito.report.ReportsApi +import com.avito.report.model.Team +import com.avito.slack.SlackClient +import com.avito.slack.model.SlackChannel +import com.avito.time.DefaultTimeProvider +import com.avito.time.TimeProvider +import com.avito.utils.logging.ciLogger +import com.avito.utils.logging.commonLogger +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.provider.Provider +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.register + +class TestSummaryPlugin : Plugin { + + override fun apply(target: Project) { + + val extension = target.extensions.create(testSummaryExtensionName) + + val logger = commonLogger(target.ciLogger) + + @Suppress("UnstableApiUsage") + val slackClient: Provider = + extension.slackToken.zip(extension.slackWorkspace) { token, workspace -> + createSlackClient(token, workspace) + } + + val reportsApi: Provider = extension.reportsHost.map { createReportsApi(it, logger) } + + val timeProvider: TimeProvider = DefaultTimeProvider() + + val reportViewer: Provider = extension.reportViewerUrl.map { createReportViewer(it) } + + // report coordinates provided in TestSummaryStep + // this plugin only works via steps for now + target.tasks.register(testSummaryTaskName) { + summaryChannel.set(extension.summaryChannel) + buildUrl.set(extension.buildUrl) + + @Suppress("UnstableApiUsage") + unitToChannelMapping.set(extension.unitToChannelMapping + .map { map -> map.map { (key, value) -> Team(key) to SlackChannel(value) }.toMap() }) + + mentionOnFailures.set(extension.mentionOnFailures + .map { set -> set.map { Team(it) }.toSet() }) + reserveSlackChannel.set(extension.reserveSlackChannel) + slackUserName.set(extension.slackUserName) + + this.slackClient.set(slackClient) + this.reportsApi.set(reportsApi) + this.reportViewer.set(reportViewer) + } + + target.tasks.register(flakyReportTaskName) { + summaryChannel.set(extension.summaryChannel) + slackUsername.set(extension.slackUserName) + buildUrl.set(extension.buildUrl) + currentBranch.set(extension.currentBranch) + + this.slackClient.set(slackClient) + this.timeProvider.set(timeProvider) + this.reportsApi.set(reportsApi) + this.reportViewer.set(reportViewer) + } + } + + private fun createReportViewer(reportViewerUrl: String): ReportViewer { + return ReportViewer.Impl(reportViewerUrl) + } + + private fun createSlackClient(slackToken: String, slackWorkspace: String): SlackClient { + return SlackClient.Impl( + token = slackToken, + workspace = slackWorkspace + ) + } + + private fun createReportsApi(reportsHost: String, logger: Logger): ReportsApi { + return ReportsApi.create( + host = reportsHost, + fallbackUrl = reportsHost, + logger = logger + ) + } +} diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryPluginApi.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryPluginApi.kt new file mode 100644 index 0000000000..9e986f0e39 --- /dev/null +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryPluginApi.kt @@ -0,0 +1,19 @@ +package com.avito.test.summary + +import com.avito.kotlin.dsl.typedNamed +import org.gradle.api.tasks.TaskContainer +import org.gradle.api.tasks.TaskProvider + +const val testSummaryPluginId = "com.avito.android.test-summary" + +const val testSummaryExtensionName = "testSummary" + +internal const val testSummaryTaskName = "testSummary" + +fun TaskContainer.testSummaryTask(): TaskProvider = + typedNamed(testSummaryTaskName) + +internal const val flakyReportTaskName = "flakyReport" + +fun TaskContainer.flakyReportTask(): TaskProvider = + typedNamed(flakyReportTaskName) diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummarySender.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummarySender.kt index c392001f01..ca020e1108 100644 --- a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummarySender.kt +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummarySender.kt @@ -1,7 +1,9 @@ package com.avito.test.summary import com.avito.report.ReportViewer +import com.avito.report.ReportsApi import com.avito.report.model.CrossDeviceSuite +import com.avito.report.model.GetReportResult import com.avito.report.model.ReportCoordinates import com.avito.report.model.Team import com.avito.slack.ConjunctionMessageUpdateCondition @@ -19,24 +21,26 @@ import com.avito.test.summary.compose.SlackSummaryComposer import com.avito.test.summary.compose.SlackSummaryComposerImpl import com.avito.utils.logging.CILogger -interface TestSummarySender { +internal interface TestSummarySender { - fun send(suite: CrossDeviceSuite, reportId: String) + fun send() } /** * @param reserveSlackChannel на случай ошибок, чтобы не терять репорты */ -class TestSummarySenderImplementation( +internal class TestSummarySenderImpl( slackClient: SlackClient, reportViewer: ReportViewer, + private val reportsApi: ReportsApi, private val logger: CILogger, private val buildUrl: String, private val reportCoordinates: ReportCoordinates, - private val globalSummaryChannel: SlackChannel = summaryChannel, + private val globalSummaryChannel: SlackChannel, private val unitToChannelMapping: Map, - private val mentionOnFailures: Set = setOf(Team("buyer-x")), //todo move to config - private val reserveSlackChannel: SlackChannel = SlackChannel("#speed-testing-team") //todo move to config + private val mentionOnFailures: Set, + private val reserveSlackChannel: SlackChannel, + private val slackUserName: String ) : TestSummarySender { private val slackSummaryComposer: SlackSummaryComposer = SlackSummaryComposerImpl(reportViewer) @@ -50,7 +54,7 @@ class TestSummarySenderImplementation( updater = slackMessageUpdater, condition = ConjunctionMessageUpdateCondition( listOf( - SameAuthorUpdateCondition(SLACK_USER_NAME), + SameAuthorUpdateCondition(slackUserName), TextContainsStringCondition(reportCoordinates.runId) ) ), @@ -63,7 +67,14 @@ class TestSummarySenderImplementation( private val slackEmojiProvider = SlackEmojiProvider() - override fun send(suite: CrossDeviceSuite, reportId: String) { + override fun send() { + reportsApi.getCrossDeviceTestData(reportCoordinates).fold( + { suite -> send(suite, requireNotNull(reportsApi.tryGetId(reportCoordinates))) }, + { throwable -> logger.critical("Can't get suite report", throwable) } + ) + } + + private fun send(suite: CrossDeviceSuite, reportId: String) { slackBulkSender.sendBulk { unitToChannelMapping.entries.map { (team, channel) -> val unitSuite = suite.filterTeam(team) @@ -81,7 +92,7 @@ class TestSummarySenderImplementation( SlackSendMessageRequest( channel = channel, text = message, - author = SLACK_USER_NAME, + author = slackUserName, emoji = slackEmojiProvider.emojiName(unitSuite.percentSuccessOfAutomated) ) ) @@ -106,20 +117,27 @@ class TestSummarySenderImplementation( SlackSendMessageRequest( channel = globalSummaryChannel, text = it, - author = SLACK_USER_NAME, + author = slackUserName, emoji = slackEmojiProvider.emojiName(suite.percentSuccessOfAutomated) ) ) }.onFailure { throwable -> - logger.critical( - "Can't compose slack message for summary: buildUrl=$buildUrl", - throwable - ) + logger.warn("Can't compose slack message for summary: buildUrl=$buildUrl", throwable) } } } -} - -val summaryChannel = SlackChannel("#android-test-summary") -private const val SLACK_USER_NAME = "Test Analyzer" + private fun ReportsApi.tryGetId(reportCoordinates: ReportCoordinates): String? { + return when (val result = getReport(reportCoordinates)) { + is GetReportResult.Found -> result.report.id + GetReportResult.NotFound -> { + logger.warn("Can't find report for runId=${reportCoordinates.runId}") + null + } + is GetReportResult.Error -> { + logger.warn("Can't find report for runId=${reportCoordinates.runId}", result.exception) + null + } + } + } +} diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryTask.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryTask.kt new file mode 100644 index 0000000000..53a470f6a6 --- /dev/null +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/TestSummaryTask.kt @@ -0,0 +1,69 @@ +package com.avito.test.summary + +import com.avito.report.ReportViewer +import com.avito.report.ReportsApi +import com.avito.report.model.ReportCoordinates +import com.avito.report.model.Team +import com.avito.slack.SlackClient +import com.avito.slack.model.SlackChannel +import com.avito.utils.logging.ciLogger +import org.gradle.api.DefaultTask +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property +import org.gradle.api.provider.SetProperty +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.TaskAction + +abstract class TestSummaryTask : DefaultTask() { + + @get:Input + abstract val reportCoordinates: Property + + @get:Input + abstract val summaryChannel: Property + + @get:Input + abstract val buildUrl: Property + + @Suppress("UnstableApiUsage") + @get:Input + abstract val unitToChannelMapping: MapProperty + + @get:Input + abstract val mentionOnFailures: SetProperty + + @get:Input + abstract val reserveSlackChannel: Property + + @get:Input + abstract val slackUserName: Property + + @get:Internal + abstract val slackClient: Property + + @get:Internal + abstract val reportsApi: Property + + @get:Internal + abstract val reportViewer: Property + + @TaskAction + fun doWork() { + val testSummarySender: TestSummarySender = TestSummarySenderImpl( + slackClient = slackClient.get(), + reportViewer = reportViewer.get(), + reportsApi = reportsApi.get(), + logger = ciLogger, + buildUrl = buildUrl.get(), + reportCoordinates = reportCoordinates.get(), + globalSummaryChannel = summaryChannel.get(), + unitToChannelMapping = unitToChannelMapping.get(), + mentionOnFailures = mentionOnFailures.get(), + reserveSlackChannel = reserveSlackChannel.get(), + slackUserName = slackUserName.get() + ) + + testSummarySender.send() + } +} diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/analysis/CrossDeviceSuteExtensions.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/analysis/CrossDeviceSuteExtensions.kt index 3c05fe3034..ae68a74023 100644 --- a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/analysis/CrossDeviceSuteExtensions.kt +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/analysis/CrossDeviceSuteExtensions.kt @@ -4,7 +4,7 @@ import com.avito.report.model.CrossDeviceSuite import com.avito.report.model.FailureOnDevice import com.avito.report.model.HasFailures -fun CrossDeviceSuite.analyzeFailures(): Map> { +internal fun CrossDeviceSuite.analyzeFailures(): Map> { return this.crossDeviceRuns .filter { it.status is HasFailures } .flatMap { (it.status as HasFailures).failures } @@ -12,18 +12,17 @@ fun CrossDeviceSuite.analyzeFailures(): Map> { .groupBy { it.failureMessage } } +//visible for testing +internal fun normalize(failureMessage: String): String { + return DEFAULT_FAILURE_MESSAGE_NORMALIZERS + .fold(failureMessage, { message, normalizer -> normalizer.normalize(message) }) +} private fun FailureOnDevice.normalized(): FailureOnDevice { val normalizedMessage = normalize(this.failureMessage) return FailureOnDevice(this.device, normalizedMessage) } -//visible for testing -fun normalize(failureMessage: String): String { - return DEFAULT_FAILURE_MESSAGE_NORMALIZERS - .fold(failureMessage, { message, normalizer -> normalizer.normalize(message) }) -} - private val DEFAULT_FAILURE_MESSAGE_NORMALIZERS = listOf( DuplicateFailureMessageNormalizer, RegexFailureMessageNormalizer(Regex("@[0-9a-f]{4,}")), diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/analysis/FailureMessageNormalizer.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/analysis/FailureMessageNormalizer.kt index 9371122e9c..fa55642644 100644 --- a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/analysis/FailureMessageNormalizer.kt +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/analysis/FailureMessageNormalizer.kt @@ -3,7 +3,7 @@ package com.avito.test.summary.analysis /** * Removes all changing data from failure messages to group it afterwards */ -interface FailureMessageNormalizer { +internal interface FailureMessageNormalizer { fun normalize(failureMessage: String): String } @@ -15,7 +15,7 @@ interface FailureMessageNormalizer { * was : LinearLayout$LayoutParams@1aeef385 * become: LinearLayout$LayoutParams */ -class RegexFailureMessageNormalizer( +internal class RegexFailureMessageNormalizer( private val regex: Regex, private val replacement: String = "" ) : FailureMessageNormalizer { @@ -26,7 +26,7 @@ class RegexFailureMessageNormalizer( /** * @paran pattern string with {1} {2} ... etc placeholders, will be replaced by [regex] matches one by one */ -class RegexToPatternMessageNormalizer( +internal class RegexToPatternMessageNormalizer( private val regex: Regex, private val pattern: String ) : FailureMessageNormalizer { @@ -45,7 +45,7 @@ class RegexToPatternMessageNormalizer( } } -object DuplicateFailureMessageNormalizer : FailureMessageNormalizer { +internal object DuplicateFailureMessageNormalizer : FailureMessageNormalizer { override fun normalize(failureMessage: String): String { val parts = failureMessage.split("\n\n") diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/compose/SlackSummaryComposer.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/compose/SlackSummaryComposer.kt index 646831e122..e598094e8d 100644 --- a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/compose/SlackSummaryComposer.kt +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/compose/SlackSummaryComposer.kt @@ -5,7 +5,7 @@ import com.avito.report.model.ReportCoordinates import com.avito.report.model.Team import org.funktionale.tries.Try -interface SlackSummaryComposer { +internal interface SlackSummaryComposer { fun composeMessage( testData: CrossDeviceSuite, diff --git a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/compose/SlackSummaryComposerImpl.kt b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/compose/SlackSummaryComposerImpl.kt index dc5d47c0c3..ebdfa26351 100644 --- a/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/compose/SlackSummaryComposerImpl.kt +++ b/subprojects/gradle/test-summary/src/main/kotlin/com/avito/test/summary/compose/SlackSummaryComposerImpl.kt @@ -9,7 +9,7 @@ import com.avito.slack.SlackStringFormat import com.avito.test.summary.analysis.analyzeFailures import org.funktionale.tries.Try -class SlackSummaryComposerImpl(private val reportViewer: ReportViewer) : SlackSummaryComposer { +internal class SlackSummaryComposerImpl(private val reportViewer: ReportViewer) : SlackSummaryComposer { private val insightLimitLength = 400 diff --git a/subprojects/gradle/instrumentation-tests/src/test/kotlin/com/avito/instrumentation/report/FlakyTestInfoTest.kt b/subprojects/gradle/test-summary/src/test/kotlin/com/avito/test/summary/FlakyTestInfoTest.kt similarity index 97% rename from subprojects/gradle/instrumentation-tests/src/test/kotlin/com/avito/instrumentation/report/FlakyTestInfoTest.kt rename to subprojects/gradle/test-summary/src/test/kotlin/com/avito/test/summary/FlakyTestInfoTest.kt index 8c9d549c94..475b19e095 100644 --- a/subprojects/gradle/instrumentation-tests/src/test/kotlin/com/avito/instrumentation/report/FlakyTestInfoTest.kt +++ b/subprojects/gradle/test-summary/src/test/kotlin/com/avito/test/summary/FlakyTestInfoTest.kt @@ -1,4 +1,4 @@ -package com.avito.instrumentation.report +package com.avito.test.summary import com.avito.report.model.SimpleRunTest import com.avito.report.model.Stability diff --git a/subprojects/gradle/tms/src/main/kotlin/com/avito/plugin/CthulhuPluginApi.kt b/subprojects/gradle/tms/src/main/kotlin/com/avito/plugin/TmsPluginApi.kt similarity index 100% rename from subprojects/gradle/tms/src/main/kotlin/com/avito/plugin/CthulhuPluginApi.kt rename to subprojects/gradle/tms/src/main/kotlin/com/avito/plugin/TmsPluginApi.kt