Skip to content

Commit

Permalink
Migrated deploy to camundala.
Browse files Browse the repository at this point in the history
  • Loading branch information
pme123 committed Dec 12, 2024
1 parent 4d9b9f9 commit d541363
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 34 deletions.
84 changes: 55 additions & 29 deletions 00-documentation/src/docs/development/projectDev.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,61 @@ Files that contain the `DO NOT ADJUST` comment will be replaced.
If you do adjust them, remove this comment.
You will get a warning, but the file will not be replaced.

## publish

Creates a new Release for the BPMN project and publishes to the repository(e.g. Artifactory)

Usage:
```
./helper.scala publish <VERSION>
```

Example:
```
./helper.scala publish 0.2.5
```

The following steps are executed:
- Check if there are no SNAPSHOTs as dependencies.
- Release your dependencies first.
- Check if the `CHANGELOG.md` is updated.
- Check and adjust manually `CHANGELOG.md`.
- Remove `//---DRAFT start` / `//---DRAFT end`.
- Run the command again.
- Push the `develop` branch.
- Adjust the version in `ProjectDef.scala` and `ApiProjectCreator.scala`.
- Run `ApiProjectCreator.scala`.
- Publish the project to the repository.
- Uploads the documentation to a WebDAV-webserver (optional).
- Merge the branch (`develop`) into `master`.
- Tag the GIT repository with the version.
- Increase the version to the next minor _SNAPSHOT_ version.


## deploy
Deploys the BPMN project to the local Camunda server and runs the Simulation you're working on.

@:callout(info)
**Be aware** that `CompanyDevHelper.deployConfig` must be defined.

At the moment, only deployment via _Postman Collection_ is supported (using Camunda REST API to deploy).
@:@

Usage:
```
./helper.scala deploy [simulation]
```

Example:
```
./helper.scala deploy MyProcessSimulation
```

The following steps are executed:
- Publishes Local (`sbt publishLocal`)
- runs the _deploy-collection_ of _Postman_
- runs a Simulation (optional)

## Generate Process/-Elements
To handle name conventions and to avoid errors, we generate as much as possible.

Expand Down Expand Up @@ -197,32 +252,3 @@ This creates the following files:
02-bpmn - main -> mycompany.myproject.bpmn.myProcess.v1.MyTimerEvent
```

## publish

Creates a new Release for the BPMN project and publishes to the repository(e.g. Artifactory)

Usage:
```
./helper.scala publish <VERSION>
```

Example:
```
./helper.scala publish 0.2.5
```

The following steps are executed:
- Check if there are no SNAPSHOTs as dependencies.
- Release your dependencies first.
- Check if the `CHANGELOG.md` is updated.
- Check and adjust manually `CHANGELOG.md`.
- Remove `//---DRAFT start` / `//---DRAFT end`.
- Run the command again.
- Push the `develop` branch.
- Adjust the version in `ProjectDef.scala` and `ApiProjectCreator.scala`.
- Run `ApiProjectCreator.scala`.
- Publish the project to the repository.
- Uploads the documentation to a webserver.
- Merge the branch (`develop`) into `master`.
- Tag the GIT repository with the version.
- Increase the version to the next minor _SNAPSHOT_ version.
17 changes: 12 additions & 5 deletions 04-helper/src/main/scala/camundala/helper/dev/DevHelper.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package camundala.helper.dev

import camundala.api.ApiConfig
import camundala.helper.dev.deploy.DeployHelper
import camundala.helper.dev.publish.PublishHelper
import camundala.helper.util.{DevConfig, PublishConfig}
import camundala.helper.util.{DeployConfig, DevConfig, PublishConfig}
import camundala.helper.dev.update.*

import scala.util.{Failure, Success, Try}
Expand All @@ -11,6 +12,7 @@ trait DevHelper:
def apiConfig: ApiConfig
def devConfig: DevConfig
def publishConfig: Option[PublishConfig]
def deployConfig: Option[DeployConfig]
given DevConfig = devConfig
given ApiConfig = apiConfig
given Option[PublishConfig] = publishConfig
Expand All @@ -31,6 +33,7 @@ trait DevHelper:
command match
case Command.update =>
update
// start code generation
case Command.process =>
args match
case Seq(processName) =>
Expand Down Expand Up @@ -97,23 +100,26 @@ trait DevHelper:
createTimerEvent(processName, bpmnName, version.toIntOption)
case other =>
printBadActivity(command, other)
// finish code generation
case Command.publish =>
args match
case Seq(version) =>
PublishHelper().publish(version)
case other =>
println(s"Invalid arguments for command $command: $other")
println(s"Usage: $command <version>")
println(s"Example: $command 1.23.3")/*
println(s"Example: $command 1.23.3")

case Command.deploy =>
args match
case Seq(simulation) =>
DeployHelper().deploy(Some(simulation))
deployConfig
.map(DeployHelper(_).deploy(Some(simulation)))
.getOrElse(println("deploy is not supported as there is no deployConfig"))
case other =>
println(s"Invalid arguments for command $command: $other")
println(s"Usage: $command <simulation>")
println(s"Example: $command OpenAccountSimulation")
println(s"Example: $command OpenAccountSimulation") /*
case Command.dockerUp =>
args match
case Seq(imageVersion) =>
Expand All @@ -124,7 +130,7 @@ trait DevHelper:
DockerHelper().dockerStop()
case Command.dockerDown =>
DockerHelper().dockerDown()
*/
*/
private def printBadActivity(command: Command, args: Seq[String]): Unit =
println(s"Invalid arguments for command $command: $args")
println(s"Usage: $command <processName> <bpmnName> [version: Int]")
Expand Down Expand Up @@ -206,4 +212,5 @@ trait DevHelper:
name.head.toLower + name.tail
def asElemName: String =
name.head.toUpper + name.tail
end extension
end DevHelper
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
| .copy(subProjects = subProjects)
|
| lazy val publishConfig: Option[PublishConfig] = None //TODO If you have a webdav server to publish the docs, add the config here
| lazy val deployConfig: Option[DeployConfig] = None //TODO If you have a Postman account, add the config here
|""".stripMargin
end helperWrapper

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package camundala.helper.dev.deploy

import camundala.helper.util.{DeployConfig, Helpers}
import os.proc

import java.util.Date

case class DeployHelper(deployConfig: DeployConfig) extends Helpers:

val collectionId = deployConfig.postmanCollectionId
val envId = deployConfig.postmanLocalDevEnvId
val postmanApiKey = sys.env(deployConfig.postmanEnvApiKey)

def deploy(integrationTest: Option[String] = None): Unit =
println(s"Publishing Project locally")
val time = new Date().getTime

os.proc("sbt", "publishLocal").callOnConsole()

os.proc(
"newman",
"run",
s"https://api.getpostman.com/collections/$collectionId?apikey=$postmanApiKey",
"-e",
s"https://api.getpostman.com/environments/$envId?apikey=$postmanApiKey",
"--folder",
"deploy_manifest",
"--global-var",
s"developer=${System.getProperty("user.name").toUpperCase}"
).callOnConsole()

integrationTest.map { test =>
val testName = if test == "all" then "" else test
os.proc("sbt", "-J-Xmx3G", s"simulation/testOnly *$testName").callOnConsole()
}

println(s"Deploy and test finished in ${(new Date().getTime - time) / 1000} s")
end deploy
end DeployHelper
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package camundala.helper.util

case class DeployConfig(
postmanCollectionId: String,
postmanLocalDevEnvId: String,
postmanEnvApiKey: String = "POSTMAN_API_KEY"
)

0 comments on commit d541363

Please sign in to comment.