From d636061c160b7c2d5a9b71bb3a261b112ce6793f Mon Sep 17 00:00:00 2001 From: Ivan Dyatlov Date: Wed, 18 Dec 2024 13:02:55 +0000 Subject: [PATCH] Update Allure, remove allure-environment-writer, try to fix attachments import to Allure TestOps from AllureReporter --- core/build.gradle.kts | 1 - .../marathon/report/allure/AllureReporter.kt | 28 +++++++++++-------- gradle/libs.versions.toml | 4 +-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 6a22dcdb2..e567f1b69 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -8,7 +8,6 @@ dependencies { implementation(project(":report:execution-timeline")) implementation(libs.allure.java.commons) - implementation(libs.allure.environment.writer) implementation(libs.apache.commons.collections) implementation(libs.apache.commons.io) implementation(libs.apache.commons.text) diff --git a/core/src/main/kotlin/com/malinskiy/marathon/report/allure/AllureReporter.kt b/core/src/main/kotlin/com/malinskiy/marathon/report/allure/AllureReporter.kt index 3f61d2a90..90b34e7f4 100644 --- a/core/src/main/kotlin/com/malinskiy/marathon/report/allure/AllureReporter.kt +++ b/core/src/main/kotlin/com/malinskiy/marathon/report/allure/AllureReporter.kt @@ -1,7 +1,5 @@ package com.malinskiy.marathon.report.allure -import com.github.automatedowl.tools.AllureEnvironmentWriter.allureEnvironmentWriter -import com.google.common.collect.ImmutableMap import com.malinskiy.marathon.analytics.internal.sub.ExecutionReport import com.malinskiy.marathon.device.DeviceInfo import com.malinskiy.marathon.execution.Configuration @@ -32,6 +30,7 @@ import io.qameta.allure.model.StatusDetails import io.qameta.allure.util.ResultsUtils import java.io.File import java.io.FileOutputStream +import java.nio.file.Files import java.util.Properties import java.util.UUID @@ -56,16 +55,12 @@ class AllureReporter( lifecycle.writeTestCase(uuid) } - val params = configuration.toMap() - val builder = ImmutableMap.builder() + val params = configuration.toMap().toMutableMap() params.forEach { - builder.put(it.key, it.value) + params[it.key] = it.value } - builder.put("platform", "Android") - - val environment = builder.build() - allureEnvironmentWriter(environment, outputDirectory.absolutePath + File.separator) - environment.saveToEnvironmentProperties() + params["platform"] = "Android" + params.saveToEnvironmentProperties() } private fun Map.saveToEnvironmentProperties() { @@ -111,12 +106,18 @@ class AllureReporter( .setSource(summaryFile.relativePathTo(outputDirectory)) .setType("text/plain") + testResult.attachments.forEach { + val linkFile = outputDirectory.resolve(it.file.name).toPath() + Files.deleteIfExists(linkFile) + Files.createSymbolicLink(linkFile, it.file.toPath()) + } + val testAttachments: List = testResult .attachments .map { Attachment() .setName(it.type.name.lowercase().replaceFirstChar(Char::titlecase)) - .setSource(it.file.relativePathTo(outputDirectory)) + .setSource(it.file.name) .setType(it.type.toMimeType()) } @@ -155,6 +156,7 @@ class AllureReporter( test.findValue(TmsLink::class.java.canonicalName)?.let { allureTestResult.links.add(ResultsUtils.createTmsLink(it)) } allureTestResult.labels.add(ResultsUtils.createLabel("layer", "UI")) allureTestResult.labels.add(ResultsUtils.createLabel("platform", "Android")) + allureTestResult.labels.addAll(ResultsUtils.getProvidedLabels()) allureTestResult.labels.addAll(test.getOptionalLabels()) return allureTestResult @@ -173,7 +175,9 @@ class AllureReporter( findValue(Owner::class.java.canonicalName)?.let { list.add(ResultsUtils.createOwnerLabel(it)) } findValue(Lead::class.java.canonicalName)?.let { list.add(ResultsUtils.createLabel(ResultsUtils.LEAD_LABEL_NAME, it)) } findValue("io.qameta.allure.junit4.Tag")?.let { list.add(ResultsUtils.createTagLabel(it)) } - findValue("io.qameta.allure.Layer")?.let { list.add(ResultsUtils.createLabel("layer", it)) } + findValue("io.qameta.allure.label.Layer")?.let { list.add(ResultsUtils.createLabel("layer", it)) } + findValue("io.qameta.allure.label.Team")?.let { list.add(ResultsUtils.createLabel("team", it)) } + findValue("io.qameta.allure.label.Component")?.let { list.add(ResultsUtils.createLabel("component", it)) } return list } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0030e8346..274db4e5a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,5 @@ [versions] -allure-java = "2.28.0" -allure-environment-writer = "1.0.0" +allure-java = "2.29.1" android-gradle-plugin = "8.7.3" android-tools = "31.7.3" apache-commons-collections = "4.4" @@ -26,7 +25,6 @@ testcontainers = "1.15.3" [libraries] allure-java-commons = { module = "io.qameta.allure:allure-java-commons", version.ref = "allure-java" } -allure-environment-writer = { module = "com.github.automatedowl:allure-environment-writer", version.ref = "allure-environment-writer" } android-gradle-api = { module = "com.android.tools.build:gradle-api", version.ref = "android-gradle-plugin" } android-tools-common = { module = "com.android.tools:common", version.ref = "android-tools" } android-tools-ddmlib = { module = "com.android.tools.ddms:ddmlib", version.ref = "android-tools" }