Skip to content

Commit

Permalink
Rip out non essentials
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Oct 19, 2023
1 parent 3c70ac2 commit 467fb3b
Show file tree
Hide file tree
Showing 45 changed files with 1 addition and 3,864 deletions.
79 changes: 0 additions & 79 deletions dokka-runners/gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@

@file:Suppress("UnstableApiUsage") // jvm test suites & test report aggregation are incubating

import buildsrc.utils.buildDir_
import buildsrc.utils.skipTestFixturesPublications

plugins {
buildsrc.conventions.`kotlin-gradle-plugin`
kotlin("plugin.serialization")

buildsrc.conventions.`maven-publishing`

`java-test-fixtures`
`jvm-test-suite`
`test-report-aggregation`
buildsrc.conventions.`maven-publish-test`
}

description = "Generates documentation for Kotlin projects (using Dokka)"
Expand Down Expand Up @@ -114,83 +110,8 @@ kotlin {
}
}

testing.suites {
withType<JvmTestSuite>().configureEach {
useJUnitJupiter()

dependencies {
implementation(project.dependencies.gradleTestKit())

implementation(project.dependencies.testFixtures(project()))

implementation(project.dependencies.platform(libs.kotlinx.serialization.bom))
implementation(libs.kotlinx.serialization.json)
}

targets.configureEach {
testTask.configure {
val projectTestTempDirPath = "$buildDir_/test-temp-dir"
inputs.property("projectTestTempDir", projectTestTempDirPath)
systemProperty("projectTestTempDir", projectTestTempDirPath)

when (testType.get()) {
TestSuiteType.FUNCTIONAL_TEST,
TestSuiteType.INTEGRATION_TEST -> {
dependsOn(tasks.matching { it.name == "publishAllPublicationsToTestRepository" })

systemProperties(
"testMavenRepoDir" to file(mavenPublishTest.testMavenRepo).canonicalPath,
)

// depend on the test-publication task, but not the test-maven repo
// (otherwise this task will never be up-to-date)
dependsOn(tasks.publishToTestMavenRepo)
}
}
}
}
}


/** Unit tests suite */
val test by getting(JvmTestSuite::class) {
description = "Standard unit tests"
}


/** Functional tests suite */
val testFunctional by registering(JvmTestSuite::class) {
description = "Tests that use Gradle TestKit to test functionality"
testType.set(TestSuiteType.FUNCTIONAL_TEST)

targets.all {
testTask.configure {
shouldRunAfter(test)
}
}
}

tasks.check { dependsOn(test, testFunctional) }
}

skipTestFixturesPublications()

val aggregateTestReports by tasks.registering(TestReport::class) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
destinationDirectory.set(layout.buildDirectory.dir("reports/tests/aggregated"))

dependsOn(tasks.withType<AbstractTestTask>())

// hardcoded dirs is a bit of a hack, but a fileTree just didn't work
testResults.from("$buildDir_/test-results/test/binary")
testResults.from("$buildDir_/test-results/testFunctional/binary")
testResults.from("$buildDir_/test-results/testIntegration/binary")

doLast {
logger.lifecycle("Aggregated test report: file://${destinationDirectory.asFile.get()}/index.html")
}
}

val dokkatooVersion = provider { project.version.toString() }

val dokkatooConstantsProperties = objects.mapProperty<String, String>().apply {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

package buildsrc.conventions

import java.time.Duration
import org.gradle.api.tasks.testing.logging.TestLogEvent

/**
* A convention plugin that sets up common config and sensible defaults for all subprojects.
*/
Expand All @@ -26,134 +23,6 @@ tasks.withType<AbstractArchiveTask>().configureEach {
isReproducibleFileOrder = true
}

tasks.withType<AbstractTestTask>().configureEach {
timeout.set(Duration.ofMinutes(60))

testLogging {
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
events(
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STARTED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT,
)
}
}

tasks.withType<AbstractCopyTask>().configureEach {
includeEmptyDirs = false
}

val updateTestReportCss by tasks.registering {
description = "Hack so the Gradle test reports have dark mode"
// the CSS is based on https://github.com/gradle/gradle/pull/12177

mustRunAfter(tasks.withType<Test>())
mustRunAfter(tasks.withType<TestReport>())

val cssFiles = layout.buildDirectory.asFileTree.matching {
include("reports/**/css/base-style.css")
include("reports/**/css/style.css")
}

outputs.files(cssFiles.files)

doLast {
cssFiles.forEach { cssFile ->
val fileContent = cssFile.readText()

if ("/* Dark mode */" in fileContent) {
return@forEach
} else {
when (cssFile.name) {
"base-style.css" -> cssFile.writeText(
fileContent + """
/* Dark mode */
@media (prefers-color-scheme: dark) {
html {
background: black;
}
body, a, a:visited {
color: #E7E7E7FF;
}
#footer, #footer a {
color: #cacaca;
}
ul.tabLinks li {
border: solid 1px #cacaca;
background-color: #151515;
}
ul.tabLinks li:hover {
background-color: #383838;
}
ul.tabLinks li.selected {
background-color: #002d32;
border-color: #007987;
}
div.tab th, div.tab table {
border-bottom: solid #d0d0d0 1px;
}
span.code pre {
background-color: #0a0a0a;
border: solid 1px #5f5f5f;
}
}
""".trimIndent()
)

"style.css" -> cssFile.writeText(
fileContent + """
/* Dark mode */
@media (prefers-color-scheme: dark) {
.breadcrumbs, .breadcrumbs a {
color: #9b9b9b;
}
#successRate, .summaryGroup {
border: solid 2px #d0d0d0;
}
.success, .success a {
color: #7fff7f;
}
div.success, #successRate.success {
background-color: #001c00;
border-color: #7fff7f;
}
.failures, .failures a {
color: #a30000;
}
.skipped, .skipped a {
color: #a26d13;
}
div.failures, #successRate.failures {
background-color: #170000;
border-color: #a30000;
}
}
""".trimIndent()
)
}
}
}
}
}

tasks.withType<Test>().configureEach {
finalizedBy(updateTestReportCss)
}

tasks.withType<TestReport>().configureEach {
finalizedBy(updateTestReportCss)
}

tasks.matching { it.name == "validatePlugins" }.configureEach {
// prevent warning
// Task ':validatePlugins' uses this output of task ':updateTestReportCss' without declaring an explicit or implicit dependency.
mustRunAfter(updateTestReportCss)
}
Loading

0 comments on commit 467fb3b

Please sign in to comment.