forked from finos/common-domain-model
-
Notifications
You must be signed in to change notification settings - Fork 7
/
codefresh.yml
350 lines (330 loc) · 15.9 KB
/
codefresh.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
version: '1.0'
stages:
- setup
- build
- distribute
- finalise
steps:
main_clone:
title: Cloning main repository...
stage: 'setup'
type: git-clone
git: github
repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}"
revision: "${{CF_REVISION}}"
SetProperties:
stage: 'setup'
title: Setup build
image: alpine/git
commands:
- cf_export MVN_DEPLOY_FLAGS="-s ${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}/settings.xml -Dmaven.repo.local=${{CF_VOLUME_PATH}}/.m2 -Denv.CI_DEPLOY_PASSWORD=${{CI_DEPLOY_PASSWORD}} -Denv.CI_DEPLOY_USERNAME=${{CI_DEPLOY_USERNAME}} -Denv.GPG_KEYNAME=${{GPG_KEYNAME}} -Denv.GPG_PASSPHRASE=${{GPG_PASSPHRASE}}" --mask
- cf_export MVN_BUILD_FLAGS="-Dmaven.repo.local=${{CF_VOLUME_PATH}}/.m2"
- cf_export GPG_IMPORT_COMMAND="cat <(echo -e '${{GPG_PRIVATE_KEY}}') | gpg --batch --import" --mask
- cf_export GEN_DEPLOY_POM_SCRIPT="${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}/rosetta-source/src/main/resources/build-resources/create-deploy-pom.sh"
- cf_export GEN_DEPLOY_POM_PY="${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}/rosetta-source/src/main/resources/build-resources/create-deploy-pom.py"
ReleaseProperties:
stage: 'setup'
title: Setup release build
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == true"
commands:
- cf_export RELEASE_NAME=${{TAG_NAME}}
- cf_export MAVEN_BUILD_PROFILES="daml,scala,typescript,golang,csharp8,csharp9,kotlin,python,full,gpg,excel,json-schema"
- cf_export MVN_DEPLOY_FILE_FLAGS="${{MVN_BUILD_FLAGS}} ${{MVN_DEPLOY_FLAGS}} -Durl=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2 -DrepositoryId=ossrh-distro -Dgpg.passphrase=${{GPG_PASSPHRASE}}" --mask
SnapshotProperties:
stage: 'setup'
title: Setup snapshot build
image: alpine/git
when:
condition:
all:
releaseNameNotDefined: "${{TAG_REPO}} == false"
commands:
- cf_export RELEASE_NAME=${{GLOBAL_RELEASE_VERSION}}.${{CF_BRANCH_TAG_NORMALIZED}}-SNAPSHOT
- cf_export MAVEN_BUILD_PROFILES="daml,scala,typescript,golang,csharp8,csharp9,kotlin,python,gpg,excel,json-schema"
- cf_export MVN_DEPLOY_FILE_FLAGS="${{MVN_BUILD_FLAGS}} ${{MVN_DEPLOY_FLAGS}} -Durl=https://s01.oss.sonatype.org/content/repositories/snapshots -DrepositoryId=ossrh -Dgpg.passphrase=${{GPG_PASSPHRASE}}" --mask
Build:
stage: 'build'
title: Maven build
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- mvn ${{MVN_BUILD_FLAGS}} versions:set -DnewVersion=${{RELEASE_NAME}} versions:update-child-modules -DallowSnapshots=true
- mvn ${{MVN_DEPLOY_FLAGS}} clean deploy -P "${{MAVEN_BUILD_PROFILES}}"
BuildParallelTasks:
stage: 'build'
type: parallel
steps:
BuildDaml:
stage: 'build'
title: DAML build
fail_fast: false
image: digitalasset/daml-sdk:1.3.0
working_directory: ./rosetta-source/
shell: bash
commands:
- daml build -o target/cdm-daml-${{RELEASE_NAME}}.dar
BuildScala:
stage: 'build'
title: Scala build
fail_fast: false
image: mozilla/sbt:8u292_1.5.7
working_directory: ./rosetta-source/target/classes/cdm/scala
shell: bash
commands:
- sbt compile
- sbt package
- sbt doc
- sbt packageDoc packageSrc
BuildCSharp8:
stage: 'build'
title: CSharp8 build
fail_fast: false
image: mcr.microsoft.com/dotnet/core/sdk:3.1
working_directory: ./rosetta-source/target/classes/cdm/csharp8/NetStandard.2.1
shell: bash
commands:
- dotnet build Cdm/Cdm.csproj
- dotnet test Test/Test.csproj
- dotnet publish Cdm/Cdm.csproj -c release -o ./app
BuildCSharp9:
stage: 'build'
title: CSharp9 build
fail_fast: false
image: mcr.microsoft.com/dotnet/sdk:5.0
working_directory: ./rosetta-source/target/classes/cdm/csharp9/Net.5.0
shell: bash
commands:
- dotnet build Cdm/Cdm.csproj
- dotnet test Test/Test.csproj
- dotnet publish Cdm/Cdm.csproj -c release -o ./app
BuildPython:
stage: 'build'
title: Python build
fail_fast: false
image: python:3.10-alpine
working_directory: ./
shell: sh
commands:
- export PYTHONDONTWRITEBYTECODE=1
- python3 -m pip install pydantic
- python3 -m pip install jsonpickle
- python3 -m pip install ./rosetta-source/target/classes/cdm/python/runtime/rosetta_runtime-2.1.0-py3-none-any.whl
- |-
python3 -m pip wheel --no-deps --only-binary :all: --wheel-dir ./rosetta-source/target/classes/cdm/python ./rosetta-source/target/classes/cdm/python
- python3 -m pip install ./rosetta-source/target/classes/cdm/python/python_cdm-*-py3-none-any.whl
- python3 -m pip install pytest
# - pytest -p no:cacheprovider ./cdm-python/test/
DeployDaml:
stage: 'build'
title: DAML deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd target
- tar -cvzf cdm-daml-${{RELEASE_NAME}}.tar.gz cdm-daml-${{RELEASE_NAME}}.dar
- ${{GEN_DEPLOY_POM_SCRIPT}} cdm-daml ${{RELEASE_NAME}} tar.gz
- mvn org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file ${{MVN_DEPLOY_FILE_FLAGS}} -Dfile=cdm-daml-${{RELEASE_NAME}}.tar.gz -DgroupId=org.finos.cdm -DartifactId=cdm-daml -Dversion=${{RELEASE_NAME}} -Dpackaging=tar.gz -DpomFile=cdm-daml-${{RELEASE_NAME}}.pom
DeployScala:
stage: 'build'
title: Scala deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd target/classes/cdm/scala/target/scala-2.12
- mv cdm-scala_2.12-0.0.0.snapshot.jar cdm-scala-${{RELEASE_NAME}}.jar
- mv cdm-scala_2.12-0.0.0.snapshot-sources.jar cdm-scala-${{RELEASE_NAME}}-sources.jar
- mv cdm-scala_2.12-0.0.0.snapshot-javadoc.jar cdm-scala-${{RELEASE_NAME}}-javadoc.jar
- ${{GEN_DEPLOY_POM_SCRIPT}} cdm-scala ${{RELEASE_NAME}} jar
- mvn org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file ${{MVN_DEPLOY_FILE_FLAGS}} -Dfile=cdm-scala-${{RELEASE_NAME}}.jar -DgroupId=org.finos.cdm -DartifactId=cdm-scala -Dversion=${{RELEASE_NAME}} -DpomFile=cdm-scala-${{RELEASE_NAME}}.pom -Dsources=cdm-scala-${{RELEASE_NAME}}-sources.jar -Djavadoc=cdm-scala-${{RELEASE_NAME}}-javadoc.jar
DeployCSharp8:
stage: 'build'
title: CSharp8 deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd target/classes/cdm/csharp8/NetStandard.2.1
- tar -cvzf cdm-csharp8-${{RELEASE_NAME}}.tar.gz app
- ${{GEN_DEPLOY_POM_SCRIPT}} cdm-csharp8 ${{RELEASE_NAME}} tar.gz
- mvn org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file ${{MVN_DEPLOY_FILE_FLAGS}} -Dfile=cdm-csharp8-${{RELEASE_NAME}}.tar.gz -DgroupId=org.finos.cdm -DartifactId=cdm-csharp8 -Dversion=${{RELEASE_NAME}} -Dpackaging=tar.gz -DpomFile=cdm-csharp8-${{RELEASE_NAME}}.pom
DeployCSharp9:
stage: 'build'
title: CSharp9 deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd target/classes/cdm/csharp9/Net.5.0
- tar -cvzf cdm-csharp9-${{RELEASE_NAME}}.tar.gz app
- ${{GEN_DEPLOY_POM_SCRIPT}} cdm-csharp9 ${{RELEASE_NAME}} tar.gz
- mvn org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file ${{MVN_DEPLOY_FILE_FLAGS}} -Dfile=cdm-csharp9-${{RELEASE_NAME}}.tar.gz -DgroupId=org.finos.cdm -DartifactId=cdm-csharp9 -Dversion=${{RELEASE_NAME}} -Dpackaging=tar.gz -DpomFile=cdm-csharp9-${{RELEASE_NAME}}.pom
DeployTypeScript:
stage: 'build'
title: TypeScript deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd target/classes/cdm
- tar -cvzf cdm-typescript-${{RELEASE_NAME}}.zip typescript
- ${{GEN_DEPLOY_POM_SCRIPT}} cdm-typescript ${{RELEASE_NAME}} zip
- mvn org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file ${{MVN_DEPLOY_FILE_FLAGS}} -Dfile=cdm-typescript-${{RELEASE_NAME}}.zip -DgroupId=org.finos.cdm -DartifactId=cdm-typescript -Dversion=${{RELEASE_NAME}} -DpomFile=cdm-typescript-${{RELEASE_NAME}}.pom
DeployGo:
stage: 'build'
title: Go deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd target/classes/cdm
- tar -cvzf cdm-golang-${{RELEASE_NAME}}.tar.gz golang
- ${{GEN_DEPLOY_POM_SCRIPT}} cdm-golang ${{RELEASE_NAME}} tar.gz
- mvn org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file ${{MVN_DEPLOY_FILE_FLAGS}} -Dfile=cdm-golang-${{RELEASE_NAME}}.tar.gz -DgroupId=org.finos.cdm -DartifactId=cdm-golang -Dversion=${{RELEASE_NAME}} -Dpackaging=tar.gz -DpomFile=cdm-golang-${{RELEASE_NAME}}.pom
DeployKotlin:
stage: 'build'
title: Kotlin deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd target/classes/cdm/kotlin
- mvn -f kotlin-build-pom.xml ${{MVN_BUILD_FLAGS}} versions:set -DnewVersion=${{RELEASE_NAME}} -DallowSnapshots=true
- mvn -f kotlin-build-pom.xml ${{MVN_DEPLOY_FLAGS}} clean deploy -P gpg
DeployPython:
stage: 'build'
title: Python deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd target/classes/cdm/python
- tar -cvzf cdm-python-${{RELEASE_NAME}}.tar.gz python_cdm-*-py3-none-any.whl runtime/rosetta_runtime-*-py3-none-any.whl
- python3 ${{GEN_DEPLOY_POM_PY}} cdm-python ${{RELEASE_NAME}} tar.gz ${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}/rosetta-source/src/main/resources/build-resources/python/python-developer.txt
- mvn org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file ${{MVN_DEPLOY_FILE_FLAGS}} -Dfile=cdm-python-${{RELEASE_NAME}}.tar.gz -DgroupId=org.finos.cdm -DartifactId=cdm-python -Dversion=${{RELEASE_NAME}} -Dpackaging=tar.gz -DpomFile=cdm-python-${{RELEASE_NAME}}.pom
DeployExcel:
stage: 'build'
title: Excel deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd src/generated/excel
- mv model.xlsx encoded.model.xlsx
- base64 -d encoded.model.xlsx > cdm-excel-${{RELEASE_NAME}}.xlsx
- rm encoded.model.xlsx
- ${{GEN_DEPLOY_POM_SCRIPT}} cdm-excel ${{RELEASE_NAME}} xlsx
- mvn org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file ${{MVN_DEPLOY_FILE_FLAGS}} -Dfile=cdm-excel-${{RELEASE_NAME}}.xlsx -DgroupId=org.finos.cdm -DartifactId=cdm-excel -Dversion=${{RELEASE_NAME}} -DpomFile=cdm-excel-${{RELEASE_NAME}}.pom
DeployJsonSchema:
stage: 'build'
title: JSON Schema deploy
fail_fast: false
image: maven:3.8.2-jdk-11
working_directory: ./rosetta-source/
shell: bash
commands:
- bash -c "${{GPG_IMPORT_COMMAND}}"
- cd src/generated
- tar -cvzf cdm-json-schema-${{RELEASE_NAME}}.zip jsonschema
- ${{GEN_DEPLOY_POM_SCRIPT}} cdm-json-schema ${{RELEASE_NAME}} zip
- mvn org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file ${{MVN_DEPLOY_FILE_FLAGS}} -Dfile=cdm-json-schema-${{RELEASE_NAME}}.zip -DgroupId=org.finos.cdm -DartifactId=cdm-json-schema -Dversion=${{RELEASE_NAME}} -DpomFile=cdm-json-schema-${{RELEASE_NAME}}.pom
NotifySlackOnFail:
stage: 'finalise'
title: Trigger Slack dev channel notification if master build failed
image: codefresh/cli
when:
branch:
only:
- master
condition:
any:
mvnBuildFailed: steps.Build.result == 'error'
buildDamlFailed: steps.BuildDaml.result == 'error'
buildScalaFailed: steps.BuildScala.result == 'error'
buildCSharp8Failed: steps.BuildCSharp8.result == 'error'
buildCSharp9Failed: steps.BuildCSharp9.result == 'error'
buildPythonFailed: steps.BuildPython.result == 'error'
deployDamlFailed: steps.DeployDaml.result == 'error'
deployScalaFailed: steps.DeployScala.result == 'error'
deployTypeScriptFailed: steps.DeployTypeScript.result == 'error'
deployCSharp8Failed: steps.DeployCSharp8.result == 'error'
deployCSharp9Failed: steps.DeployCSharp9.result == 'error'
deployGoFailed: steps.DeployGo.result == 'error'
deployKotlinFailed: steps.DeployKotlin.result == 'error'
deployPythonFailed: steps.DeployPython.result == 'error'
deployExcelFailed: steps.DeployExcel.result == 'error'
deployJsonSchemaFailed: steps.DeployJsonSchema.result == 'error'
commands:
- export SAFE_COMMIT_AUTHOR='${{CF_COMMIT_AUTHOR}}'
- export COMMIT_AUTHOR=${SAFE_COMMIT_AUTHOR:-MissingAuthor}
- export SAFE_REPO_NAME='${{CF_REPO_NAME}}'
- export REPO_NAME=${SAFE_REPO_NAME:-NoRepo}
- export SAFE_COMMIT_MESSAGE='${{CF_COMMIT_MESSAGE}}'
- export COMMIT_MESSAGE=${SAFE_COMMIT_MESSAGE:-NoCommitMsg}
- echo Author is $SAFE_COMMIT_AUTHOR and commit msg is $SAFE_COMMIT_MESSAGE and repo is $SAFE_REPO_NAME
- echo After substitution author is $COMMIT_AUTHOR and commit msg is $COMMIT_MESSAGE and repo is $REPO_NAME
- codefresh run slack-notifier -v REPO_NAME="${REPO_NAME}" -v COMMIT_AUTHOR="${COMMIT_AUTHOR}" -v COMMIT_MESSAGE="${COMMIT_MESSAGE}" --detach
FailPipeline:
stage: 'finalise'
title: Fail pipeline if the Maven build failed
image: codefresh/cli
when:
condition:
any:
mvnBuildFailure: steps.Build.result == 'failure'
damlBuildFailure: steps.BuildDaml.result == 'failure'
scalaBuildFailure: steps.BuildScala.result == 'failure'
cSharp8BuildFailure: steps.BuildCSharp8.result == 'failure'
cSharp9BuildFailure: steps.BuildCSharp9.result == 'failure'
pythonBuildFailure: steps.BuildPython.result == 'failure'
damlDeployFailure: steps.DeployDaml.result == 'failure'
scalaDeployFailure: steps.DeployScala.result == 'failure'
typeScriptDeployFailure: steps.DeployTypeScript.result == 'failure'
cSharp8DeployFailure: steps.DeployCSharp8.result == 'failure'
cSharp9DeployFailure: steps.DeployCSharp9.result == 'failure'
goDeployFailure: steps.DeployGo.result == 'failure'
kotlinDeployFailure: steps.DeployKotlin.result == 'failure'
pythonDeployFailure: steps.DeployPython.result == 'failure'
excelDeployFailure: steps.DeployExcel.result == 'failure'
jsonSchemaDeployFailure: steps.DeployJsonSchema.result == 'failure'
commands:
- exit 1
TagRepo:
stage: 'finalise'
title: Tag git repo with release name
image: alpine/git
when:
condition:
all:
buildPassed: steps.Build.result == 'success'
isRelease: "${{TAG_REPO}}"
commands:
- echo This is a release build, tag repos with release name [${{RELEASE_NAME}}]
- git fetch --prune https://${{REGNOSYS_OPS}}:${{REGNOSYS_OPS_TOKEN}}@github.com/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}.git "+refs/tags/*:refs/tags/*"
- git tag ${{RELEASE_NAME}}
- git push https://${{REGNOSYS_OPS}}:${{REGNOSYS_OPS_TOKEN}}@github.com/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}.git ${{RELEASE_NAME}}