-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build scripts updated and refactored #225
Changes from all commits
1ab85be
4d12002
9a87db2
9ed5c25
c2ec95a
322c89e
a15c201
7ea96c9
585be11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,15 +6,16 @@ repositories { | |
mavenLocal() | ||
jcenter() | ||
gradlePluginPortal() | ||
maven { url = uri("https://plugins.gradle.org/m2") } | ||
maven { url = uri("http://dl.bintray.com/cognifide/maven-public") } | ||
maven { url = uri("https://dl.bintray.com/neva-dev/maven-public") } | ||
maven { | ||
url = uri("https://plugins.gradle.org/m2") | ||
url = uri("http://dl.bintray.com/cognifide/maven-public") | ||
url = uri("https://dl.bintray.com/neva-dev/maven-public") | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("com.moowork.gradle:gradle-node-plugin:1.2.0") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updating node causes a lot of problems... i left it un-updated |
||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31") | ||
implementation("com.bmuschko:gradle-docker-plugin:4.10.0") | ||
implementation("net.researchgate:gradle-release:2.6.0") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
implementation("io.knotx:knotx-gradle-plugins:0.1.2") | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61") | ||
implementation("com.bmuschko:gradle-docker-plugin:6.1.2") | ||
implementation("io.knotx:knotx-gradle-plugins:0.1.4") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ class BoardsAndWidgetsController : AbstractVerticle() { | |
|
||
private fun prepareConfig() = mapOf<String, (JsonObject) -> String>( | ||
"update" to { body -> update(body) }, | ||
"get" to { body -> boardsConfigService.loadBoardsConfig().toString() } | ||
"get" to { _ -> boardsConfigService.loadBoardsConfig().toString() } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Detekt fix |
||
) | ||
|
||
private fun update(body: JsonObject): String { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,16 @@ | |
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage | ||
import com.bmuschko.gradle.docker.tasks.image.DockerRemoveImage | ||
|
||
val projectDir = rootProject.projectDir.absolutePath.replace("\\", "/"); | ||
val dockerImageRef = "$buildDir/.docker/buildImage-imageId.txt" | ||
val dockerContainerName = project.property("docker.app.container.name")?.toString() ?: "cogboard" | ||
val dockerImageName = project.property("docker.app.image.name")?.toString() ?: "cogboard/cogboard-app" | ||
val mountDir = "${rootProject.projectDir.absolutePath.replace("\\", "/")}/mnt" | ||
val cypressContentPath = "${rootProject.projectDir.absolutePath.replace("\\", "/")}/cogboard-app/src/main/resources/cypressData/config.json" | ||
val defaultCypressTestsDir = "${rootProject.projectDir.absolutePath.replace("\\", "/")}/functional/cypress-tests" | ||
val functionalTestsPath = System.getProperty("functionalTestPath")?:defaultCypressTestsDir | ||
val cypressEnvCode = System.getProperty("cypressEnv")?:"local" | ||
val cypressConfigPath = "cypress/config/" + cypressEnvCode + ".json" | ||
val mountDir = "$projectDir/mnt" | ||
val cypressContentPath = "$projectDir/cogboard-app/src/main/resources/cypressData/config.json" | ||
val defaultCypressTestsDir = "$projectDir/functional/cypress-tests" | ||
val functionalTestsPath = System.getProperty("functionalTestPath") ?: defaultCypressTestsDir | ||
val cypressEnvCode = System.getProperty("cypressEnv") ?: "local" | ||
val cypressConfigPath = "cypress/config/$cypressEnvCode.json" | ||
val network = "${project.name}-local_cognet" | ||
val wsPort = project.property("ws.port") | ||
val appPort = project.property("app.port") | ||
|
@@ -33,106 +34,105 @@ logger.lifecycle(">> dockerContainerName: $dockerContainerName") | |
logger.lifecycle(">> dockerImageName: $dockerImageName") | ||
logger.lifecycle(">> mountDir: $mountDir") | ||
logger.lifecycle(">> functionalTestsPath: $functionalTestsPath") | ||
logger.lifecycle(">> cypressConfigPath: $cypressConfigPath") | ||
|
||
tasks { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. task registration is now grouped in |
||
|
||
task("cogboard-is-running") { | ||
dependsOn("build") | ||
doLast { | ||
logger.lifecycle("Running docker image") | ||
exec { | ||
commandLine( | ||
"docker", "run", "--rm", | ||
"-p$appPort:8092", // main app port | ||
"-p1$appPort:18092", // remote debug port | ||
"-p$wsPort:$wsPort", // web socket port | ||
"--name", dockerContainerName, | ||
"-v", "$mountDir:/data", // docker volume | ||
dockerImageName | ||
) | ||
register<DockerRemoveImage>("removeImage") { | ||
group = "docker" | ||
|
||
onlyIf { File(dockerImageRef).exists() } | ||
|
||
targetImageId(if (File(dockerImageRef).exists()) File(dockerImageRef).readText() else "") | ||
onError { | ||
if (!this.message!!.contains("No such image")) | ||
throw this | ||
} | ||
} | ||
} | ||
|
||
tasks.register<DockerRemoveImage>("removeImage") { | ||
group = "docker" | ||
|
||
onlyIf { File(dockerImageRef).exists() } | ||
register<DockerBuildImage>("buildImage") { | ||
group = "docker" | ||
|
||
targetImageId(if (File(dockerImageRef).exists()) File(dockerImageRef).readText() else "") | ||
onError { | ||
if (!this.message!!.contains("No such image")) | ||
throw this | ||
inputDir.set(file("$buildDir")) | ||
images.add("$dockerImageName:$version") | ||
dependsOn("prepareDocker", "build") | ||
} | ||
} | ||
|
||
tasks.register<DockerBuildImage> ("buildImage") { | ||
group = "docker" | ||
inputDir.set(file("$buildDir")) | ||
tags.add("$dockerImageName:$version") | ||
dependsOn("prepareDocker", "build") | ||
} | ||
|
||
tasks.register<Exec>("updateLocal") { | ||
group = "docker" | ||
commandLine = listOf("docker", "service", "update", "--force", "${project.name}-local_cogboard") | ||
} | ||
register<Exec>("updateLocal") { | ||
group = "docker" | ||
commandLine = listOf("docker", "service", "update", "--force", "${project.name}-local_cogboard") | ||
} | ||
|
||
tasks.register<Exec>("updateMocks") { | ||
group = "docker" | ||
commandLine = listOf("docker", "service", "update", "--force", "${project.name}-local_api-mocks") | ||
} | ||
register<Exec>("updateMocks") { | ||
group = "docker" | ||
commandLine = listOf("docker", "service", "update", "--force", "${project.name}-local_api-mocks") | ||
} | ||
|
||
tasks.register<Exec>("initSwarm") { | ||
group = "swarm" | ||
commandLine = listOf("docker", "swarm", "init") | ||
isIgnoreExitValue = true | ||
} | ||
register<Exec>("initSwarm") { | ||
group = "swarm" | ||
commandLine = listOf("docker", "swarm", "init") | ||
isIgnoreExitValue = true | ||
} | ||
|
||
tasks.register<Exec>("awaitLocalStackUndeployed") { | ||
commandLine = listOf("docker", "network", "inspect", network) | ||
isIgnoreExitValue = true | ||
errorOutput = java.io.ByteArrayOutputStream() | ||
doLast { | ||
if (errorOutput.toString().contains("Error: No such network")) { | ||
//we are happy, since this network is down we can proceed | ||
} else { | ||
Thread.sleep(15 * 1000) // let's wait for better times | ||
register<Exec>("awaitLocalStackUndeployed") { | ||
commandLine = listOf("docker", "network", "inspect", network) | ||
isIgnoreExitValue = true | ||
errorOutput = java.io.ByteArrayOutputStream() | ||
doLast { | ||
if (errorOutput.toString().contains("Error: No such network")) { | ||
//we are happy, since this network is down we can proceed | ||
} else { | ||
Thread.sleep(15 * 1000) // let's wait for better times | ||
} | ||
} | ||
mustRunAfter("build") | ||
} | ||
mustRunAfter("build") | ||
} | ||
|
||
tasks.register<Exec>("deployLocal") { | ||
environment = mapOf("COGBOARD_VERSION" to version) | ||
group = "swarm" | ||
commandLine = listOf("docker", "stack", "deploy", "-c", "${project.name}-local-compose.yml", "${project.name}-local") | ||
dependsOn("initSwarm", "buildImage", "awaitLocalStackUndeployed") | ||
mustRunAfter("undeployLocal") | ||
} | ||
|
||
tasks.register<Exec>("undeployLocal") { | ||
group = "swarm" | ||
commandLine = listOf("docker", "stack", "rm", "${project.name}-local") | ||
dependsOn("initSwarm") | ||
} | ||
register<Exec>("deployLocal") { | ||
environment = mapOf("COGBOARD_VERSION" to version) | ||
group = "swarm" | ||
commandLine = listOf("docker", "stack", "deploy", "-c", "${project.name}-local-compose.yml", "${project.name}-local") | ||
dependsOn("initSwarm", "buildImage", "awaitLocalStackUndeployed") | ||
mustRunAfter("undeployLocal") | ||
} | ||
|
||
tasks.register("redeployLocal") { | ||
group = "swarm" | ||
dependsOn("undeployLocal", "deployLocal") | ||
} | ||
register<Exec>("undeployLocal") { | ||
group = "swarm" | ||
commandLine = listOf("docker", "stack", "rm", "${project.name}-local") | ||
dependsOn("initSwarm") | ||
} | ||
|
||
tasks.register<Exec>("functionalTests") { | ||
group = "docker-functional-tests" | ||
commandLine = listOf("docker", "run", "-v","$functionalTestsPath:/e2e","-w","/e2e","--network=$network", "cypress/included:3.8.0", "--browser", "chrome", "--config-file", "$cypressConfigPath") | ||
register("redeployLocal") { | ||
group = "swarm" | ||
dependsOn("undeployLocal", "deployLocal") | ||
} | ||
|
||
dependsOn("redeployLocal", "copyCypressContent" ) | ||
doFirst { | ||
logger.lifecycle("Running functional tests from $functionalTestsPath with base network: $network") | ||
register<Exec>("functionalTests") { | ||
group = "Docker Functional Tests" | ||
commandLine = listOf( | ||
"docker", "run", | ||
"-v", "$functionalTestsPath:/e2e", | ||
"-w", "/e2e", | ||
"--network=$network", | ||
"cypress/included:3.8.0", | ||
"--browser", "chrome", | ||
"--config-file", cypressConfigPath | ||
) | ||
|
||
dependsOn("redeployLocal", "copyCypressContent") | ||
doFirst { | ||
logger.lifecycle("Running functional tests from $functionalTestsPath with base network: $network") | ||
} | ||
} | ||
} | ||
|
||
tasks.register<Exec>("copyCypressContent") { | ||
group = "docker-functional-tests" | ||
commandLine = listOf("sh", "scripts/copyCypressContent.sh", "$cypressContentPath", "$mountDir") | ||
mustRunAfter("redeployLocal") | ||
Comment on lines
-134
to
-137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @staszke - We have better approach for copying files - lets use the old way without unnecessary script that will not work when you don't have shell |
||
register<Copy>("copyCypressContent") { | ||
group = "Docker Functional Tests" | ||
|
||
from(cypressContentPath) | ||
into(mountDir) | ||
doLast { | ||
logger.lifecycle(">> Automated testing data has been successfully copied") | ||
} | ||
mustRunAfter("redeployLocal") | ||
} | ||
} |
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-5.4.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets group them together