-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JPERF-941: Start testing the
release
task
Now JPERF-941 actually reproduces with the axion symptoms: ``` * What went wrong: A problem was found with the configuration of task ':verifyRelease' (type 'VerifyReleaseTask'). - In plugin 'pl.allegro.tech.build.axion-release' type 'pl.allegro.tech.build.axion.release.VerifyReleaseTask' property 'versionConfig' is missing an input or output annotation. Reason: A property without annotation isn't considered during up-to-date checking. Possible solutions: 1. Add an input or output annotation. 2. Mark it as @internal. Please refer to https://docs.gradle.org/7.6/userguide/validation_problems.html#missing_annotation for more details about this problem. ```
- Loading branch information
Showing
3 changed files
with
139 additions
and
90 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
src/test/kotlin/com/atlassian/performance/tools/license/Fixtures.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.atlassian.performance.tools.license | ||
|
||
import org.eclipse.jgit.api.Git | ||
import org.eclipse.jgit.transport.URIish | ||
import org.junit.rules.TemporaryFolder | ||
import java.io.File | ||
|
||
class Fixtures { | ||
|
||
class ProjectFixture( | ||
val root: File, | ||
val git: Git | ||
) | ||
|
||
internal fun configureProject( | ||
projectName: String, | ||
version: String | ||
): ProjectFixture { | ||
val buildFolder = TemporaryFolder() | ||
buildFolder.create() | ||
val git = Git.init().setDirectory(buildFolder.root).call() | ||
addInitialCommit(projectName, buildFolder, git) | ||
git.tag().setName("release-$version-alpha").call() | ||
addCode(buildFolder, git) | ||
return ProjectFixture(buildFolder.root, git) | ||
} | ||
|
||
private fun addInitialCommit( | ||
projectName: String, | ||
buildFolder: TemporaryFolder, | ||
git: Git | ||
) { | ||
buildFolder.newFile("build.gradle").writeText( | ||
""" | ||
plugins { | ||
id 'com.atlassian.performance.tools.gradle-release' | ||
id "org.jetbrains.kotlin.jvm" version "1.3.20" | ||
} | ||
dependencies { | ||
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: '1.3.20' | ||
} | ||
""".trimIndent() | ||
) | ||
buildFolder.newFile("settings.gradle").writeText( | ||
""" | ||
rootProject.name = "$projectName" | ||
""".trimIndent() | ||
) | ||
buildFolder.newFile(".gitignore").writeText( | ||
""" | ||
.gradle | ||
build | ||
""".trimIndent() | ||
) | ||
git | ||
.add() | ||
.addFilepattern(".gitignore") | ||
.addFilepattern("settings.gradle") | ||
.addFilepattern("build.gradle") | ||
.call() | ||
git | ||
.commit() | ||
.setMessage("Initial commit") | ||
.call() | ||
} | ||
|
||
private fun addCode( | ||
buildFolder: TemporaryFolder, | ||
git: Git | ||
) { | ||
val javaFolder = buildFolder.newFolder("src", "main", "kotlin") | ||
File(javaFolder, "Hello.kt").writeText( | ||
""" | ||
class Hello { | ||
} | ||
""".trimIndent() | ||
) | ||
git | ||
.add() | ||
.addFilepattern("src") | ||
.call() | ||
git | ||
.commit() | ||
.setMessage("Hello world") | ||
.call() | ||
} | ||
} | ||
|
||
internal fun Git.addRemote(uri: URIish) { | ||
remoteAdd() | ||
.apply { setName("origin") } | ||
.apply { setUri(uri) } | ||
.call() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/test/kotlin/com/atlassian/performance/tools/license/ReleaseTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.atlassian.performance.tools.license | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.eclipse.jgit.api.Git | ||
import org.eclipse.jgit.transport.URIish | ||
import org.gradle.testkit.runner.GradleRunner | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import org.junit.Test | ||
import org.junit.rules.TemporaryFolder | ||
|
||
class ReleaseTest { | ||
|
||
@Test | ||
fun shouldReleaseModule() { | ||
val projectName = "release-test" | ||
val version = "1.2.4" | ||
val project = Fixtures().configureProject(projectName, version) | ||
val safelyPushableRemote = TemporaryFolder() | ||
.also { it.create() } | ||
.root | ||
.also { Git.init().setDirectory(it) } | ||
.let {URIish("file://${it.absolutePath}")} | ||
project.git.addRemote(safelyPushableRemote) | ||
|
||
val releaseResult = GradleRunner.create() | ||
.withProjectDir(project.root) | ||
.withArguments("release", "--stacktrace") | ||
.withPluginClasspath() | ||
.forwardOutput() | ||
.withDebug(true) | ||
.build() | ||
|
||
val releaseTask = releaseResult.task(":release") | ||
assertThat(releaseTask?.outcome) | ||
.isEqualTo(TaskOutcome.SUCCESS) | ||
} | ||
} |