Skip to content

Commit

Permalink
Make publication validator part of the project (#1820)
Browse files Browse the repository at this point in the history
Before, publication validator was just lying nearby, in these
files, and built and run separately. Now, it is compiled
alongside the main project (in the `test` gradle configuration), so
its breakage will be detected during normal usage. Still, it is
only run when a special gradle property, `DeployVersion`, is
defined.
  • Loading branch information
dkhalanskyjb committed Feb 21, 2020
1 parent 6d1a6e3 commit 3651276
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 301 deletions.
7 changes: 3 additions & 4 deletions build.gradle
Expand Up @@ -8,8 +8,8 @@ apply from: rootProject.file("gradle/experimental.gradle")
def rootModule = "kotlinx.coroutines"
def coreModule = "kotlinx-coroutines-core"
// Not applicable for Kotlin plugin
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom']
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs']
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'publication-validator']
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs', 'publication-validator']
// Not published
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']

Expand Down Expand Up @@ -133,8 +133,7 @@ allprojects {

apply plugin: "binary-compatibility-validator"
apiValidation {
ignoredProjects += ["stdlib-stubs", "benchmarks", "site",
"kotlinx-coroutines-bom", "android-unit-tests", "js-stub"]
ignoredProjects += unpublished + ["kotlinx-coroutines-bom"]
ignoredPackages += "kotlinx.coroutines.internal"
}

Expand Down
12 changes: 8 additions & 4 deletions publication-validator/README.md
@@ -1,9 +1,13 @@
# Publication validator

This is a supplementary subproject of kotlinx.coroutines to test its publication correctness.
This is a supplementary subproject of kotlinx.coroutines that provides a new
task, `testPublishing`, to test its publication correctness.

It is used as part of "Dependency validation" build chain on TeamCity:
* kotlinx.corotoutines are built with `publishToMavenLocal`
* kotlinx.coroutines are built with `npmPublish -PdryRun=true` to have a packed publication
The tests are the following:
* `NpmPublicationValidator` tests that version of NPM artifact is correct and that it has neither source nor package dependencies on atomicfu
* `MavenPublicationValidator` depends on the published artifacts and tests artifacts binary content and absence of atomicfu in the classpath

To test publication, one needs to run gradle with `-PdryRun=true`, and the
task that actually does the testing is `publication-validator:test`.
`-PdryRun` affects `npmPublish` so that it only provides a packed publication
and does not in fact attempt to send the build for publication.
34 changes: 18 additions & 16 deletions publication-validator/build.gradle
Expand Up @@ -2,34 +2,36 @@
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.30'
}

def deployVersion = properties['DeployVersion']
ext.coroutines_version = deployVersion
println "Checking coroutines version $coroutines_version"

group 'org.jetbrains.kotlinx'
version '1.0-SNAPSHOT'
apply from: rootProject.file("gradle/compile-jvm.gradle")

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testCompile 'junit:junit:4.12'
testCompile 'org.apache.commons:commons-compress:1.18'
testCompile 'com.google.code.gson:gson:2.8.5'
testCompile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
testCompile "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
testCompile project(':kotlinx-coroutines-core')
testCompile project(':kotlinx-coroutines-android')
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

def dryRunNpm = properties['dryRun']

test {
onlyIf { dryRunNpm == "true" } // so that we don't accidentally publish anything, especially before the test
doFirst { println "Verifying publishing version $version" } // all modules share the same version
environment "projectRoot", project.rootDir
environment "deployVersion", version
if (dryRunNpm == "true") { // `onlyIf` only affects execution of the task, not the dependency subtree
dependsOn(project(':').getTasksByName("publishNpm", true) +
project(':').getTasksByName("publishToMavenLocal", true))
dependsOn.remove(project(':').getTasksByName("dokka", true))
}
}
5 changes: 0 additions & 5 deletions publication-validator/gradle.properties

This file was deleted.

Binary file not shown.

This file was deleted.

172 changes: 0 additions & 172 deletions publication-validator/gradlew

This file was deleted.

84 changes: 0 additions & 84 deletions publication-validator/gradlew.bat

This file was deleted.

8 changes: 0 additions & 8 deletions publication-validator/settings.gradle

This file was deleted.

Expand Up @@ -12,8 +12,8 @@ import java.util.zip.*
import org.junit.Assert.*

class NpmPublicationValidator {
private val VERSION = System.getenv("DeployVersion")
private val BUILD_DIR = System.getenv("teamcity.build.checkoutDir")
private val VERSION = System.getenv("deployVersion")!!
private val BUILD_DIR = System.getenv("projectRoot")!!
private val NPM_ARTIFACT = "$BUILD_DIR/kotlinx-coroutines-core/build/npm/kotlinx-coroutines-core-$VERSION.tgz"

@Test
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Expand Up @@ -40,3 +40,5 @@ module('ui/kotlinx-coroutines-swing')

module('js/js-stub')
module('js/example-frontend-js')

module('publication-validator')

0 comments on commit 3651276

Please sign in to comment.