Skip to content

Commit

Permalink
ci: Enable RC versions for gradle (dependency update task) (#1210)
Browse files Browse the repository at this point in the history
* RC enabled for gradle

* Update docs
  • Loading branch information
pawelpasterz authored Oct 5, 2020
1 parent f0fc164 commit 563d155
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 13 deletions.
6 changes: 3 additions & 3 deletions docs/dependencies_update_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Process run commands and update files with defined versions in the provided file

## Usage

### Manually
0. Generate report using command `./gradlew dependencyUpdates -DoutputFormatter=json -DoutputDir=..`
### Manually (root directory)
0. Generate report using command `./gradlew dependencyUpdates -DoutputFormatter=json -DoutputDir=.`
0. Build flank scripts using script `./flank-scripts/bash/buildFlankScripts.sh`
0. Run `/flank-scripts/bash/flankScripts dependencies update`
0. Run `./flank-scripts/bash/flankScripts dependencies update`

### Github action
Run `Update dependencies` job using [Github action menu](https://github.com/Flank/flank/actions) by clicking `Run workflow` button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ val Dependency.versionToUpdate
?: availableVersion?.integration
?: version

fun GradleDependency.needsUpdate() = running.version != current.version
fun GradleDependency.needsUpdate() = (running.version != current.version) || (running.version != releaseCandidate.version)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ private fun updateGradleWrapper(gradleDependency: GradleDependency, gradleWrappe
findAllGradleWrapperPropertiesFiles(gradleWrapperPropertiesPath)
.forEach {
val from = gradleDependency.running.version
val to = gradleDependency.current.version
val to = if (gradleDependency.releaseCandidate.isUpdateAvailable)
gradleDependency.releaseCandidate.version
else
gradleDependency.current.version
println("Update gradle wrapper $from to $to in file ${it.path}")
it.updateGradleWrapperPropertiesFile(from, to)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,23 @@ class DependencyExtensionsTest {
releaseCandidate = GradleVersion("1.2rc", "test", false, false),
running = GradleVersion("1", "test", false, false),
)
val gradleWhichDoesNotNeedUpdate = GradleDependency(
val gradleWhichNeedsUpdateRc = GradleDependency(
current = GradleVersion("1.1", "test", false, false),
nightly = GradleVersion("1.3", "test", false, false),
releaseCandidate = GradleVersion("1.2rc", "test", false, false),
running = GradleVersion("1.1", "test", false, false),
)
val gradleWhichDoesNotNeedUpdate = GradleDependency(
current = GradleVersion("1.1", "test", false, false),
nightly = GradleVersion("1.3", "test", false, false),
releaseCandidate = GradleVersion("1.1", "test", false, false),
running = GradleVersion("1.1", "test", false, false),
)


// when - then
// when - then
assertTrue(gradleWhichNeedsUpdate.needsUpdate())
assertTrue(gradleWhichNeedsUpdateRc.needsUpdate())
assertFalse(gradleWhichDoesNotNeedUpdate.needsUpdate())
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,66 @@
package flank.scripts.dependencies.update

import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File

class UpdateGradleTest {
@get:Rule
val tempFolder = TemporaryFolder()

private val testReport = File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/report.json")
private val testGradleVersionFile = File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/test_gradle-wrapper.properties.test")
private val testGradleVersionFile =
File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/test_gradle-wrapper.properties.test")

@Test
fun `Should update gradle`() {
// given
val expectedVersions =
File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/expected_gradle-wrapper.properties.test")
val copyOfTestVersions =
testGradleVersionFile.copyTo(
File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/gradle-wrapper.properties")).apply { deleteOnExit() }
val copyOfTestVersions = tempFolder.newFile("gradle-wrapper.properties").apply {
writeText(testGradleVersionFile.readText())
}

// when
testReport.updateGradle(tempFolder.root.absolutePath)

// then
assertEquals(copyOfTestVersions.readText(), expectedVersions.readText())
}

@Test
fun `Should update RC version gradle`() {
val rcReportText = testReport.readText().replace(
"""
| "releaseCandidate": {
| "version": "6.7-rc-1",
| "reason": "",
| "isUpdateAvailable": false,
| "isFailure": false
| }
""".trimMargin(), """
| "releaseCandidate": {
| "version": "6.7-rc-1",
| "reason": "",
| "isUpdateAvailable": true,
| "isFailure": false
| }
""".trimMargin()
)

val rcReport = tempFolder.newFile("rcReport.json").apply { writeText(rcReportText) }

// given
val expectedVersions =
File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/expected_gradle-wrapper.properties_RC.test")
val copyOfTestVersions = tempFolder.newFile("gradle-wrapper.properties").apply {
writeText(testGradleVersionFile.readText())
}

// when
testReport.updateGradle("src/test/kotlin/flank/scripts/dependencies/update/testfiles/")
rcReport.updateGradle(tempFolder.root.absolutePath)

// then
assertEquals(copyOfTestVersions.readText(), expectedVersions.readText())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-rc-1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"releaseCandidate": {
"version": "6.7-rc-1",
"reason": "",
"isUpdateAvailable": true,
"isUpdateAvailable": false,
"isFailure": false
},
"running": {
Expand Down

0 comments on commit 563d155

Please sign in to comment.