Skip to content

Commit

Permalink
[WIP] Add new test-runner.
Browse files Browse the repository at this point in the history
  • Loading branch information
TadeasKriz committed Apr 11, 2024
1 parent dab30e0 commit 30c597e
Show file tree
Hide file tree
Showing 76 changed files with 2,232 additions and 6 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/new-smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Smoke Tests [New]

# on:
# push:
# branches:
# - '**'

permissions:
contents: read
checks: write

jobs:
demo:
name: Demo Tests
runs-on: ${{ matrix.host }}
strategy:
fail-fast: false
matrix:
target: [ios_arm64, macos_arm64 ... ]
link_mode: [static, dynamic]
build_configuration: [debug, release]
kotlin: [1.8.0, 1.8.10, 1.8.20, 1.8.21, 1.8.22, 1.9.0, 1.9.10, 1.9.20, 1.9.21, 1.9.22]
k2enabled: [true, false]
xcode: ["15.0"]
host: [macos-14, macos-13, macos-12, ubuntu-latest, windows-latest]
include:
- host: green
- color: pink
animal: cat
- fruit: apple
shape: circle
- fruit: banana
- fruit: banana
animal: cat

steps:
- uses: touchlab/SKIE@tk/smoke-tests
with:
github-token: ${{ secrets.ACCEPTANCE_TESTS_TOKEN }}
gradle:
name: Gradle Tests
runs-on: self-hosted
steps:
- uses: touchlab/SKIE@tk/smoke-tests
with:
github-token: ${{ secrets.ACCEPTANCE_TESTS_TOKEN }}
acceptance:
name: Acceptance Tests
runs-on: self-hosted
steps:
- uses: touchlab/SKIE@tk/smoke-tests
with:
github-token: ${{ secrets.ACCEPTANCE_TESTS_TOKEN }}
type-mapping:
name: Type Mapping Tests
runs-on: self-hosted
steps:
- uses: touchlab/SKIE@tk/smoke-tests
with:
github-token: ${{ secrets.ACCEPTANCE_TESTS_TOKEN }}
libraries:
name: External Libraries Tests
runs-on: self-hosted
steps:
- uses: touchlab/SKIE@tk/smoke-tests
with:
github-token: ${{ secrets.ACCEPTANCE_TESTS_TOKEN }}
performance:
name: Performance Tests
runs-on: self-hosted
steps:
- uses: touchlab/SKIE@tk/smoke-tests
with:
github-token: ${{ secrets.ACCEPTANCE_TESTS_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ExternalSystemSettings>
<option name="env">
<map>
<entry key="acceptanceTest" value="tests/coroutines/suspend/type_params_copied" />
<entry key="acceptanceTest" value="tests/coroutines/suspend/objects" />
</map>
</option>
<option name="executionName" />
Expand All @@ -26,4 +26,4 @@
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ abstract class DevAcceptanceTests : Plugin<Project> {
attributes {
attribute(KotlinCompilerVersion.attribute, objects.named(target.kotlinToolingVersion.value))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.native)
attribute(KotlinNativeTarget.konanTargetAttribute, MacOsCpuArchitecture.getCurrent().konanTarget)
attributeProvider(KotlinNativeTarget.konanTargetAttribute, provider { MacOsCpuArchitecture.getCurrent().konanTarget })
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, KotlinUsages.KOTLIN_API))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,27 @@ abstract class SkiePublishable : Plugin<Project>, HasMavenPublishPlugin, HasSign

val extension = extensions.create<SkiePublishingExtension>("skiePublishing")

configureSmokeTestTmpRepository()
configureMetadata(extension)
configureKotlinJvmPublicationIfNeeded()
configureSourcesJar(extension)
configureJavadocJar()
}

private fun Project.configureSmokeTestTmpRepository() {
val smokeTestTmpRepositoryPath: String? by this
smokeTestTmpRepositoryPath?.let {
publishing {
repositories {
maven {
url = uri(it)
name = "smokeTestTmp"
}
}
}
}
}

private fun Project.configureSigningIfNeeded() {
val isRelease = !version.toString().endsWith("SNAPSHOT")
val isPublishing = gradle.startParameter.taskNames.contains("publishToSonatype")
Expand Down
6 changes: 6 additions & 0 deletions common-gradle/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ touchlab.key=ABCDEFGHIJKLMNOPQRSTUVWXYZ
skieRuntimeVariantFallback=true

kotlinNativeCompilerEmbeddableFromHome=false

#org.gradle.configuration-cache=true

#junit.jupiter.execution.parallel.enabled = true
#junit.jupiter.execution.parallel.mode.default = concurrent
#junit.jupiter.execution.parallel.mode.classes.default = concurrent
6 changes: 4 additions & 2 deletions common-gradle/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
java = "11"
kotlin = "1.8.21"
pluginPublish = "1.2.0"
kotest = "5.4.0"
kotest = "5.8.0"
buildconfig = "4.1.1"
ktor = "2.2.3"
nexusPublish = "2.0.0-rc-1"
Expand Down Expand Up @@ -33,7 +33,7 @@ kotlinx-serialization-yaml = { module = "com.charleskorn.kaml:kaml", version = "
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-coroutines-jvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version.ref = "coroutines" }
jackson-databind = { module = " com.fasterxml.jackson.core:jackson-databind", version = "2.14.2" }
kotlinPoet = { module = "com.squareup:kotlinpoet", version = "1.12.0" }
kotlinPoet = { module = "com.squareup:kotlinpoet", version = "1.15.1" }
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
apache-compress = { module = "org.apache.commons:commons-compress", version = "1.22" }
logback = { module = "ch.qos.logback:logback-classic", version = "1.4.14" }
Expand All @@ -45,13 +45,15 @@ kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotl
kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5-jvm", version.ref = "kotest" }
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core-jvm", version.ref = "kotest" }
kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest-jvm", version.ref = "kotest" }
kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" }
mockk = { module = "io.mockk:mockk", version = "1.12.5" }

[bundles]
kotest = [
"kotest-runner-junit5",
"kotest-assertions-core",
"kotest-framework-datatest",
"kotest-property",
]
testing-jvm = [
"kotlin-test",
Expand Down
2 changes: 1 addition & 1 deletion common-gradle/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
70 changes: 70 additions & 0 deletions test-runner/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import co.touchlab.skie.PublishSkieToTempMavenTask
import org.gradle.tooling.GradleConnector

plugins {
kotlin("jvm") version "1.9.22"
}

dependencies {
implementation(kotlin("test"))
implementation(gradleTestKit())
implementation(libs.kotlinPoet)
implementation(libs.bundles.kotest)
}

println("Start: ${gradle.startParameter}")

val smokeTestRepository = layout.buildDirectory.dir("smokeTestRepo")


val publishSkieToTempMaven by tasks.registering(PublishSkieToTempMavenTask::class) {
skieSources = rootDir.resolve("../SKIE")
tempRepository = smokeTestRepository
}

testing {
suites {
val test by getting(JvmTestSuite::class) {
useJUnitJupiter("5.10.1")

dependencies {
implementation("org.junit.platform:junit-platform-suite:1.10.2")
implementation("org.junit.platform:junit-platform-reporting:1.10.2")
}

targets.all {
testTask.configure {
minHeapSize = "1024m"
maxHeapSize = "4024m"
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)

dependsOn(publishSkieToTempMaven)

systemProperty("smokeTestRepository", smokeTestRepository.get().asFile.absolutePath)
systemProperty("junit.platform.reporting.open.xml.enabled", "true")
systemProperty("junit.platform.reporting.output.dir", reports.junitXml.outputLocation.get().asFile.absolutePath.also {
println("Junitxml: ${it}")
})

listOf(
"testLevel",
"testTypes",
"matrix.targets",
"matrix.configurations",
"matrix.linkModes",
"matrix.kotlinVersions",
"matrix.gradleVersions",
).forEach { property ->
val propertyValue = findProperty(property) ?: return@forEach
systemProperty(property, propertyValue)
}

testLogging {
events("passed", "skipped", "failed")
showStandardStreams = true
}
}
}
}
}
}
7 changes: 7 additions & 0 deletions test-runner/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package co.touchlab.skie

import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.model.ObjectFactory
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.tooling.GradleConnector
import javax.inject.Inject

abstract class PublishSkieToTempMavenTask @Inject constructor(objects: ObjectFactory): DefaultTask() {
// This is @Internal because we only want `.kt` files to be considered as inputs, which we do in `init { }`
@get:Internal
val skieSources: DirectoryProperty = objects.directoryProperty()

@get:OutputDirectory
val tempRepository: DirectoryProperty = objects.directoryProperty()

init {
inputs.files(skieSources.map { it.asFileTree.matching { this.include { it.file.extension == "kt" } }.also { println(it.files.joinToString("\n") { it.absolutePath }) } })
}

@TaskAction
fun publish() {
GradleConnector.newConnector()
.forProjectDirectory(skieSources.get().asFile)
.connect()
.use { projectConnection ->
projectConnection.newBuild()
.forTasks("publishAllPublicationsToSmokeTestTmpRepository")
.setStandardInput(System.`in`)
.setStandardOutput(System.out)
.setStandardError(System.err)
.addArguments("-PsmokeTestTmpRepositoryPath=${tempRepository.get().asFile.absolutePath}")
.run()
}
}
}
1 change: 1 addition & 0 deletions test-runner/gradle
1 change: 1 addition & 0 deletions test-runner/gradle.properties
1 change: 1 addition & 0 deletions test-runner/gradlew
1 change: 1 addition & 0 deletions test-runner/gradlew.bat
14 changes: 14 additions & 0 deletions test-runner/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pluginManagement {
repositories {
mavenCentral()
google()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositories {
mavenCentral()
google()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package co.touchlab.skie.test.annotation

import co.touchlab.skie.test.runner.SkieTestRunner
import co.touchlab.skie.test.runner.condition.SmokeTestCondition
import org.junit.jupiter.api.TestTemplate
import org.junit.jupiter.api.extension.ExtendWith

@TestTemplate
@ExtendWith(SkieTestRunner::class)
@ExtendWith(SmokeTestCondition::class)
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
annotation class MatrixTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package co.touchlab.skie.test.annotation.filter

import org.intellij.lang.annotations.Language

@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@Repeatable
annotation class Exclude(
@Language("RegExp")
val targets: String = ".*",
@Language("RegExp")
val configurations: String = ".*",
@Language("RegExp")
val linkModes: String = ".*",
@Language("RegExp")
val kotlinVersions: String = ".*"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package co.touchlab.skie.test.annotation.filter

@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
annotation class Filter(

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package co.touchlab.skie.test.annotation.filter

import org.intellij.lang.annotations.Language

@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@Repeatable
annotation class Include(
@Language("RegExp")
val targets: String = ".*",
@Language("RegExp")
val configurations: String = ".*",
@Language("RegExp")
val linkModes: String = ".*",
@Language("RegExp")
val kotlinVersions: String = ".*"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package co.touchlab.skie.test.annotation.filter

import co.touchlab.skie.test.runner.BuildConfiguration

@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@OnlyFor(configurations = [BuildConfiguration.Debug])
annotation class OnlyDebug
Loading

0 comments on commit 30c597e

Please sign in to comment.