Skip to content

Commit d541363

Browse files
committed
Migrated deploy to camundala.
1 parent 4d9b9f9 commit d541363

File tree

5 files changed

+114
-34
lines changed

5 files changed

+114
-34
lines changed

00-documentation/src/docs/development/projectDev.md

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,61 @@ Files that contain the `DO NOT ADJUST` comment will be replaced.
2525
If you do adjust them, remove this comment.
2626
You will get a warning, but the file will not be replaced.
2727

28+
## publish
29+
30+
Creates a new Release for the BPMN project and publishes to the repository(e.g. Artifactory)
31+
32+
Usage:
33+
```
34+
./helper.scala publish <VERSION>
35+
```
36+
37+
Example:
38+
```
39+
./helper.scala publish 0.2.5
40+
```
41+
42+
The following steps are executed:
43+
- Check if there are no SNAPSHOTs as dependencies.
44+
- Release your dependencies first.
45+
- Check if the `CHANGELOG.md` is updated.
46+
- Check and adjust manually `CHANGELOG.md`.
47+
- Remove `//---DRAFT start` / `//---DRAFT end`.
48+
- Run the command again.
49+
- Push the `develop` branch.
50+
- Adjust the version in `ProjectDef.scala` and `ApiProjectCreator.scala`.
51+
- Run `ApiProjectCreator.scala`.
52+
- Publish the project to the repository.
53+
- Uploads the documentation to a WebDAV-webserver (optional).
54+
- Merge the branch (`develop`) into `master`.
55+
- Tag the GIT repository with the version.
56+
- Increase the version to the next minor _SNAPSHOT_ version.
57+
58+
59+
## deploy
60+
Deploys the BPMN project to the local Camunda server and runs the Simulation you're working on.
61+
62+
@:callout(info)
63+
**Be aware** that `CompanyDevHelper.deployConfig` must be defined.
64+
65+
At the moment, only deployment via _Postman Collection_ is supported (using Camunda REST API to deploy).
66+
@:@
67+
68+
Usage:
69+
```
70+
./helper.scala deploy [simulation]
71+
```
72+
73+
Example:
74+
```
75+
./helper.scala deploy MyProcessSimulation
76+
```
77+
78+
The following steps are executed:
79+
- Publishes Local (`sbt publishLocal`)
80+
- runs the _deploy-collection_ of _Postman_
81+
- runs a Simulation (optional)
82+
2883
## Generate Process/-Elements
2984
To handle name conventions and to avoid errors, we generate as much as possible.
3085

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

200-
## publish
201-
202-
Creates a new Release for the BPMN project and publishes to the repository(e.g. Artifactory)
203-
204-
Usage:
205-
```
206-
./helper.scala publish <VERSION>
207-
```
208-
209-
Example:
210-
```
211-
./helper.scala publish 0.2.5
212-
```
213-
214-
The following steps are executed:
215-
- Check if there are no SNAPSHOTs as dependencies.
216-
- Release your dependencies first.
217-
- Check if the `CHANGELOG.md` is updated.
218-
- Check and adjust manually `CHANGELOG.md`.
219-
- Remove `//---DRAFT start` / `//---DRAFT end`.
220-
- Run the command again.
221-
- Push the `develop` branch.
222-
- Adjust the version in `ProjectDef.scala` and `ApiProjectCreator.scala`.
223-
- Run `ApiProjectCreator.scala`.
224-
- Publish the project to the repository.
225-
- Uploads the documentation to a webserver.
226-
- Merge the branch (`develop`) into `master`.
227-
- Tag the GIT repository with the version.
228-
- Increase the version to the next minor _SNAPSHOT_ version.

04-helper/src/main/scala/camundala/helper/dev/DevHelper.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package camundala.helper.dev
22

33
import camundala.api.ApiConfig
4+
import camundala.helper.dev.deploy.DeployHelper
45
import camundala.helper.dev.publish.PublishHelper
5-
import camundala.helper.util.{DevConfig, PublishConfig}
6+
import camundala.helper.util.{DeployConfig, DevConfig, PublishConfig}
67
import camundala.helper.dev.update.*
78

89
import scala.util.{Failure, Success, Try}
@@ -11,6 +12,7 @@ trait DevHelper:
1112
def apiConfig: ApiConfig
1213
def devConfig: DevConfig
1314
def publishConfig: Option[PublishConfig]
15+
def deployConfig: Option[DeployConfig]
1416
given DevConfig = devConfig
1517
given ApiConfig = apiConfig
1618
given Option[PublishConfig] = publishConfig
@@ -31,6 +33,7 @@ trait DevHelper:
3133
command match
3234
case Command.update =>
3335
update
36+
// start code generation
3437
case Command.process =>
3538
args match
3639
case Seq(processName) =>
@@ -97,23 +100,26 @@ trait DevHelper:
97100
createTimerEvent(processName, bpmnName, version.toIntOption)
98101
case other =>
99102
printBadActivity(command, other)
103+
// finish code generation
100104
case Command.publish =>
101105
args match
102106
case Seq(version) =>
103107
PublishHelper().publish(version)
104108
case other =>
105109
println(s"Invalid arguments for command $command: $other")
106110
println(s"Usage: $command <version>")
107-
println(s"Example: $command 1.23.3")/*
111+
println(s"Example: $command 1.23.3")
108112

109113
case Command.deploy =>
110114
args match
111115
case Seq(simulation) =>
112-
DeployHelper().deploy(Some(simulation))
116+
deployConfig
117+
.map(DeployHelper(_).deploy(Some(simulation)))
118+
.getOrElse(println("deploy is not supported as there is no deployConfig"))
113119
case other =>
114120
println(s"Invalid arguments for command $command: $other")
115121
println(s"Usage: $command <simulation>")
116-
println(s"Example: $command OpenAccountSimulation")
122+
println(s"Example: $command OpenAccountSimulation") /*
117123
case Command.dockerUp =>
118124
args match
119125
case Seq(imageVersion) =>
@@ -124,7 +130,7 @@ trait DevHelper:
124130
DockerHelper().dockerStop()
125131
case Command.dockerDown =>
126132
DockerHelper().dockerDown()
127-
*/
133+
*/
128134
private def printBadActivity(command: Command, args: Seq[String]): Unit =
129135
println(s"Invalid arguments for command $command: $args")
130136
println(s"Usage: $command <processName> <bpmnName> [version: Int]")
@@ -206,4 +212,5 @@ trait DevHelper:
206212
name.head.toLower + name.tail
207213
def asElemName: String =
208214
name.head.toUpper + name.tail
215+
end extension
209216
end DevHelper

04-helper/src/main/scala/camundala/helper/dev/company/CompanyWrapperGenerator.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ case class CompanyWrapperGenerator()(using config: DevConfig):
147147
| .copy(subProjects = subProjects)
148148
|
149149
| lazy val publishConfig: Option[PublishConfig] = None //TODO If you have a webdav server to publish the docs, add the config here
150+
| lazy val deployConfig: Option[DeployConfig] = None //TODO If you have a Postman account, add the config here
150151
|""".stripMargin
151152
end helperWrapper
152153

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package camundala.helper.dev.deploy
2+
3+
import camundala.helper.util.{DeployConfig, Helpers}
4+
import os.proc
5+
6+
import java.util.Date
7+
8+
case class DeployHelper(deployConfig: DeployConfig) extends Helpers:
9+
10+
val collectionId = deployConfig.postmanCollectionId
11+
val envId = deployConfig.postmanLocalDevEnvId
12+
val postmanApiKey = sys.env(deployConfig.postmanEnvApiKey)
13+
14+
def deploy(integrationTest: Option[String] = None): Unit =
15+
println(s"Publishing Project locally")
16+
val time = new Date().getTime
17+
18+
os.proc("sbt", "publishLocal").callOnConsole()
19+
20+
os.proc(
21+
"newman",
22+
"run",
23+
s"https://api.getpostman.com/collections/$collectionId?apikey=$postmanApiKey",
24+
"-e",
25+
s"https://api.getpostman.com/environments/$envId?apikey=$postmanApiKey",
26+
"--folder",
27+
"deploy_manifest",
28+
"--global-var",
29+
s"developer=${System.getProperty("user.name").toUpperCase}"
30+
).callOnConsole()
31+
32+
integrationTest.map { test =>
33+
val testName = if test == "all" then "" else test
34+
os.proc("sbt", "-J-Xmx3G", s"simulation/testOnly *$testName").callOnConsole()
35+
}
36+
37+
println(s"Deploy and test finished in ${(new Date().getTime - time) / 1000} s")
38+
end deploy
39+
end DeployHelper
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package camundala.helper.util
2+
3+
case class DeployConfig(
4+
postmanCollectionId: String,
5+
postmanLocalDevEnvId: String,
6+
postmanEnvApiKey: String = "POSTMAN_API_KEY"
7+
)

0 commit comments

Comments
 (0)