Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -160,6 +162,7 @@ steps:
propagate-environment: true
environment:
- BUILDKITE_ANALYTICS_TOKEN
- BUILDKITE_ANALYTICS_TAGS
- BUILDKITE_ANALYTICS_DEBUG_ENABLED

- label: ":android: Android"
Expand Down
8 changes: 7 additions & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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")
}
18 changes: 17 additions & 1 deletion android/bin/test
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pluginManagement {
repositories {
mavenLocal()
google()
mavenCentral()
gradlePluginPortal()
Expand All @@ -9,6 +10,7 @@ pluginManagement {
dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenLocal()
google()
mavenCentral()
}
Expand Down
14 changes: 0 additions & 14 deletions swift-xctest/Package.resolved

This file was deleted.

2 changes: 1 addition & 1 deletion swift-xctest/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions swift-xctest/Tests/ExampleLibTests/PassingTests.swift
Original file line number Diff line number Diff line change
@@ -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)
}

Expand Down