diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 0092b49..7be5365 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -151,6 +151,8 @@ steps: - label: ":swift: Swift: XCTest (test-collector-swift)" command: "cd swift-xctest && bin/test" soft_fail: true + env: + BUILDKITE_ANALYTICS_TAGS: '{"test.framework.name":"xctest","language.name":"swift","custom.tag.from":"upload"}' plugins: - cluster-secrets#v1.0.0: variables: @@ -160,6 +162,7 @@ steps: propagate-environment: true environment: - BUILDKITE_ANALYTICS_TOKEN + - BUILDKITE_ANALYTICS_TAGS - BUILDKITE_ANALYTICS_DEBUG_ENABLED - label: ":android: Android" diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index e4b68ab..62b5140 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -1,7 +1,7 @@ plugins { id("com.android.application") id("org.jetbrains.kotlin.android") - id("com.buildkite.test-collector-android.unit-test-collector-plugin") version "0.3.0" + id("com.buildkite.test-collector-android.unit-test-collector-plugin") version "0.4.0-SNAPSHOT" } android { @@ -26,6 +26,12 @@ android { } } +buildkiteTestAnalytics { + tags["test.framework.name"] = "junit" + tags["language.name"] = "kotlin" + tags["custom.tag.from"] = "upload" +} + dependencies { testImplementation("junit:junit:4.13.2") } diff --git a/android/bin/test b/android/bin/test index f49f53b..4ce796a 100755 --- a/android/bin/test +++ b/android/bin/test @@ -1,8 +1,24 @@ #!/usr/bin/env bash set -euo pipefail +# Clone the test-collector-android PR branch and publish to Maven Local +# so we can use the unreleased tagging support. +# This can be reverted once the PR is merged and a new version is released. +COLLECTOR_DIR="/tmp/test-collector-android" +if [ ! -d "$COLLECTOR_DIR" ]; then + git clone --branch pda/add-tagging-support --depth 1 \ + https://github.com/buildkite/test-collector-android.git "$COLLECTOR_DIR" +fi +# The collector's build-logic uses kotlin-dsl which auto-detects JVM target from the +# running JDK. JDK 21 + Kotlin 1.8.22 = "Unknown Kotlin JVM target: 21" error. +# Install JDK 17 and use it for the collector build. +if ! find /usr/lib/jvm -maxdepth 1 -name '*17*' -type d 2>/dev/null | grep -q .; then + apt-get update -qq && apt-get install -y -qq openjdk-17-jdk-headless > /dev/null 2>&1 +fi +COLLECTOR_JAVA_HOME="$(find /usr/lib/jvm -maxdepth 1 -name '*17*' -type d | head -1)" +(cd "$COLLECTOR_DIR" && JAVA_HOME="$COLLECTOR_JAVA_HOME" ./gradlew --no-daemon publishToMavenLocal -x test) + # Run Android unit tests # The test-collector-android Gradle plugin uploads results to Test Engine automatically. # No bktec client is needed for this example. - ./gradlew --no-daemon :app:testDebugUnitTest diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index 61527ea..1c703ab 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -1,5 +1,6 @@ pluginManagement { repositories { + mavenLocal() google() mavenCentral() gradlePluginPortal() @@ -9,6 +10,7 @@ pluginManagement { dependencyResolutionManagement { @Suppress("UnstableApiUsage") repositories { + mavenLocal() google() mavenCentral() } diff --git a/swift-xctest/Package.resolved b/swift-xctest/Package.resolved deleted file mode 100644 index a3016fb..0000000 --- a/swift-xctest/Package.resolved +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pins" : [ - { - "identity" : "test-collector-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/buildkite/test-collector-swift", - "state" : { - "revision" : "261b2feaafd601e5b35edb68f402d34ad8210967", - "version" : "0.5.0" - } - } - ], - "version" : 2 -} diff --git a/swift-xctest/Package.swift b/swift-xctest/Package.swift index fe1740f..d6bc8d7 100644 --- a/swift-xctest/Package.swift +++ b/swift-xctest/Package.swift @@ -10,7 +10,7 @@ let package = Package( .library(name: "ExampleLib", targets: ["ExampleLib"]) ], dependencies: [ - .package(url: "https://github.com/buildkite/test-collector-swift", from: "0.5.0") + .package(url: "https://github.com/buildkite/test-collector-swift", branch: "pda/add-tagging-support") ], targets: [ .target( diff --git a/swift-xctest/Tests/ExampleLibTests/PassingTests.swift b/swift-xctest/Tests/ExampleLibTests/PassingTests.swift index 3a81fc0..c111e93 100644 --- a/swift-xctest/Tests/ExampleLibTests/PassingTests.swift +++ b/swift-xctest/Tests/ExampleLibTests/PassingTests.swift @@ -1,8 +1,10 @@ +import Core import XCTest @testable import ExampleLib final class PassingTests: XCTestCase { func testAdd() throws { + self.tagExecution("custom.tag.from", "execution") XCTAssertEqual(ExampleLib().add(1, 2), 3) }