@@ -15,6 +15,8 @@ String srcVersion
1515gitHubUserCredId = env. GITHUB_BOT_USER ?: ' sovbot-github'
1616sovrinPackagingRepo = env. SOVRIN_PACKAGING_REPO ?: ' https://github.com/sovrin-foundation/sovrin-packaging'
1717sovrinPackagingBranch = env. SOVRIN_PACKAGING_BRANCH ?: ' master'
18+ LIBINDY_STREAM = " master"
19+ LIBINDY_VERSION = " 1.8.3-1099"
1820
1921def downloadPackagingUtils () {
2022 git branch : sovrinPackagingBranch, credentialsId : gitHubUserCredId, url : sovrinPackagingRepo
@@ -24,7 +26,8 @@ def downloadPackagingUtils() {
2426// TODO set proper labels
2527def nodeLabels = [
2628 codeBuild : env. LIBSOVTOKEN_CODEBUILD_NODE_LABEL ?: ' codebuild' ,
27- macos : env. LIBSOVTOKEN_MACOS_NODE_LABEL ?: ' macos' ,
29+ macos : env. LIBSOVTOKEN_MACOS_NODE_LABEL ?: ' macos' ,
30+ windows : env. LIBSOVTOKEN_WINDOWS_NODE_LABEL ?: ' win2016' ,
2831]
2932
3033def codeBuildPipelines = {
@@ -160,11 +163,11 @@ def codeBuildPipelines = {
160163 stage(' Set release parameters' ) {
161164 logger. info(" Finding Release version" )
162165// def releaseVersion = env.BRANCH_NAME == 'stable' ? '' : "${lastRevision ? lastRevision[0] + 1: 1}.$BUILD_NUMBER"
163- def releaseVersion = env. BRANCH_NAME == ' stable' ? ' ' : " $BUILD_NUMBER "
166+ def releaseVersion = env. BRANCH_NAME == ' stable' ? ' ' : " $BUILD_NUMBER "
164167 logger. info(" Release version for sovrin repo: $releaseVersion " )
165168
166169// debPVersion = utils.packageVersion('deb', srcVersion, releaseVersion, env.BRANCH_NAME == 'master')
167- debPVersion = env. BRANCH_NAME == ' stable' ? " $srcVersion " : " $srcVersion ~$releaseVersion "
170+ debPVersion = env. BRANCH_NAME == ' stable' ? " $srcVersion " : " $srcVersion ~$releaseVersion "
168171 logger. info(" Package version for sovrin repo: $debPVersion " )
169172
170173 // TODO crate and rpm
@@ -253,11 +256,11 @@ def codeBuildPipelines = {
253256 }
254257
255258 Map builds = [
256- xenial : xenialBuild,
257- android : [
258- build : androidBuild,
259- nodeLabel : " $nodeLabels . codeBuild "
260- ]
259+ xenial : xenialBuild,
260+ android : [
261+ build : androidBuild,
262+ nodeLabel : " $nodeLabels . codeBuild "
263+ ]
261264 ]
262265 builds. failFast = false
263266
@@ -277,21 +280,21 @@ def macOSPipeline = {
277280 echo " ===================== Checks for XCode and Rust environment ========================"
278281 INSTALLED_XCODE_VERSION = sh(script : ''' xcodebuild -version | head -1 | cut -d' ' -f2''' , returnStdout : true )
279282 echo " INSTALLED_XCODE_VERSION = ${ INSTALLED_XCODE_VERSION} and xcodeMinVersion = ${ xcodeMinVersion} "
280- if ( INSTALLED_XCODE_VERSION <= xcodeMinVersion ) {
283+ if (INSTALLED_XCODE_VERSION <= xcodeMinVersion) {
281284 msg = " The XCode version must be greater or equal ${ xcodeMinVersion} "
282285 echo " ${ msg} "
283286 error(msg)
284287 }
285288
286289 RUST_HOME_EXIST = sh(script : " test -d ${ RUST_PATH} && echo '1' || echo '0' " , returnStdout : true ). trim()
287- if ( RUST_HOME_EXIST == ' 0' ) {
290+ if (RUST_HOME_EXIST == ' 0' ) {
288291 msg = " Rust home dir does not exist. Make sure that rust is installed in the ${ RUST_PATH} ."
289292 echo " ${ msg} "
290293 error(msg)
291294 }
292295
293296 RUSTC_VERSION = sh(script : " ${ RUST_PATH} /rustc --version || echo '0' " , returnStdout : true ). trim()
294- if ( RUSTC_VERSION == ' 0' ) {
297+ if (RUSTC_VERSION == ' 0' ) {
295298 msg = " rustc does not exist. Make sure that rust is installed in the ${ RUST_PATH} ."
296299 echo " ${ msg} "
297300 error(msg)
@@ -354,18 +357,125 @@ def macosUpload = {
354357 }
355358}
356359
357- pipelineWrapper({
360+ def windowsOSPipeline = {
361+ stage(" Windows Testing" ) {
362+ def ws_path = " workspace/${ env.JOB_NAME} " . replace(' ' , ' _' )
363+ ws(ws_path) {
364+ try {
365+ stage(' Checkout sources from SCM' ) {
366+ checkout scm
367+ }
368+
369+ stage(' Setup dependencies' ) {
370+ setupRust()
371+
372+ bat ' wget -O prebuilt.zip "https://repo.sovrin.org/windows/libindy/deps/indy-sdk-deps.zip"'
373+ bat ' unzip prebuilt.zip -d prebuilt'
374+
375+ String mainVersion = LIBINDY_VERSION . split(' -' ). first()
376+ bat " wget -O indy.zip \" https://repo.sovrin.org/windows/libindy/$LIBINDY_STREAM /$LIBINDY_VERSION /libindy_${ mainVersion} .zip\" "
377+ bat ' unzip indy.zip -d indy'
378+ }
379+
380+ stage(' Run Indy pool' ) {
381+ bat " docker -H $INDY_SDK_SERVER_IP build --build-arg pool_ip=$INDY_SDK_SERVER_IP -f devops/indy-pool/Dockerfile -t indy_pool devops/indy-pool/"
382+ bat " docker -H $INDY_SDK_SERVER_IP run -d --network host --name indy_pool -p 9701-9708:9701-9708 indy_pool"
383+ }
384+
385+ stage(' Testing' ) {
386+ dir(' libsovtoken' ) {
387+ echo " Libsovtoken Testing: Build"
388+ withEnv([
389+ " OPENSSL_DIR=$WORKSPACE \\ prebuilt" ,
390+ " SODIUM_LIB_DIR=$WORKSPACE \\ prebuilt\\ lib" ,
391+ " LIBINDY_DIR=$WORKSPACE \\ indy\\ lib" ,
392+ " PATH=$WORKSPACE \\ prebuilt\\ lib;$WORKSPACE \\ indy\\ lib;$PATH " ,
393+ " RUST_BACKTRACE=1"
394+ ]) {
395+ bat " cargo build --release"
396+ bat " cargo test --release --no-run"
397+
398+ echo " Libsovtoken Testing: Run tests"
399+ withEnv([
400+ " RUST_TEST_THREADS=1" ,
401+ " RUST_LOG=debug" ,
402+ " TEST_POOL_IP=$INDY_SDK_SERVER_IP "
403+ ]) {
404+ bat " cargo test --release"
405+ }
406+ }
407+
408+ stash includes : ' target/release/*.dll,target/release/*.dll.lib' , name : ' windowsArtifact'
409+ }
410+ }
411+ } finally {
412+ try {
413+ bat " docker -H $INDY_SDK_SERVER_IP stop indy_pool"
414+ } catch (ignore) {
415+ }
416+ try {
417+ bat " docker -H $INDY_SDK_SERVER_IP rm indy_pool"
418+ } catch (ignore) {
419+ }
420+ cleanWs()
421+ }
422+ }
423+ cleanWs()
424+ }
425+ }
426+
427+ def windowsUpload = {
428+ stage(' Upload libsovtoken package to Sovrin repo' ) {
429+
430+ if (! srcVersion) {
431+ stage(' Resolve current source version' ) {
432+ srcVersion = utils. srcVersion(projectType : ' rust' )
433+ logger. info(" Current source version: $srcVersion " )
434+ }
435+ }
436+
437+ sh ' chmod -R 777 devops/windows'
438+
439+ unstash name : " windowsArtifact"
440+
441+ withCredentials([file(credentialsId : ' SovrinRepoSSHKey' , variable : ' repo_key' )]) {
442+ withEnv([
443+ " SOVRIN_REPO_HOST=$SOVRIN_REPO_HOST " ,
444+ ]) {
445+ def suffix = getSuffix()
446+ sh " devops/windows/win-zip-and-upload.sh $srcVersion '${ repo_key} ' $env . BRANCH_NAME $suffix "
447+ }
448+ }
449+ }
450+ }
451+
452+ def getSuffix () {
453+ if (env. BRANCH_NAME == ' master' ) {
454+ return " -$env . BUILD_NUMBER "
455+ } else if (env. BRANCH_NAME == ' stable' ) {
456+ return " "
457+ } else {
458+ error " Invalid branch ${ env.BRANCH_NAME} "
459+ }
460+ }
461+
462+
463+ pipelineWrapper({
358464 // put code build containers inside a vpc under our dev account
359465 env. USE_VPC_CONFIG = true
360466
361467 Map builds = [
362468 codeBuild : [
363- build : codeBuildPipelines,
469+ build : codeBuildPipelines,
364470 nodeLabel : " $nodeLabels . codeBuild "
365471 ],
366- macos : [
367- build : macOSPipeline,
472+ macos : [
473+ build : macOSPipeline,
368474 nodeLabel : " $nodeLabels . macos "
475+ ],
476+ windows : [
477+ build : windowsOSPipeline,
478+ nodeLabel : " $nodeLabels . windows "
369479 ]
370480 ]
371481 builds. failFast = false
@@ -375,13 +485,17 @@ pipelineWrapper({
375485 }
376486
377487 Map publish = [
378- macosPublish : [
379- build : macosUpload,
488+ macosPublish : [
489+ build : macosUpload,
490+ nodeLabel : " $nodeLabels . codeBuild "
491+ ],
492+ windowsPublish : [
493+ build : windowsUpload,
380494 nodeLabel : " $nodeLabels . codeBuild "
381495 ]
382496 ]
383497
384- stage (' Publish' ) {
498+ stage(' Publish' ) {
385499 utils. parallel publish
386500 }
387501}, { err ->
@@ -394,4 +508,8 @@ pipelineWrapper({
394508 notifier. email()
395509 }
396510 }
397- })
511+ })
512+
513+ def setupRust () {
514+ shell(" rustup default 1.32.0" )
515+ }
0 commit comments