Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit af16446

Browse files
authored
Merge pull request #1350 from hyperledger/develop
Hyperledger Iroha v1.0.0 beta-2
2 parents 9e0e190 + 21b0c8d commit af16446

File tree

366 files changed

+11306
-7398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

366 files changed

+11306
-7398
lines changed

.jenkinsci/artifacts.groovy

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env groovy
2+
3+
def uploadArtifacts(filePaths, uploadPath, artifactServers=['artifact.soramitsu.co.jp']) {
4+
def baseUploadPath = 'files'
5+
def filePathsConverted = []
6+
agentType = sh(script: 'uname', returnStdout: true).trim()
7+
uploadPath = baseUploadPath + uploadPath
8+
filePaths.each {
9+
fp = sh(script: "ls -d ${it} | tr '\n' ','", returnStdout: true).trim()
10+
filePathsConverted.addAll(fp.split(','))
11+
}
12+
def shaSumBinary = 'sha256sum'
13+
def md5SumBinary = 'md5sum'
14+
if (agentType == 'Darwin') {
15+
shaSumBinary = 'shasum -a 256'
16+
md5SumBinary = 'md5 -r'
17+
}
18+
sh "> \$(pwd)/batch.txt"
19+
filePathsConverted.each {
20+
sh "echo put ${it} $uploadPath >> \$(pwd)/batch.txt;"
21+
sh "$shaSumBinary ${it} | cut -d' ' -f1 > \$(pwd)/\$(basename ${it}).sha256"
22+
sh "$md5SumBinary ${it} | cut -d' ' -f1 > \$(pwd)/\$(basename ${it}).md5"
23+
sh "echo put \$(pwd)/\$(basename ${it}).sha256 $uploadPath >> \$(pwd)/batch.txt;"
24+
sh "echo put \$(pwd)/\$(basename ${it}).md5 $uploadPath >> \$(pwd)/batch.txt;"
25+
}
26+
// mkdirs recursively
27+
uploadPath = uploadPath.split('/')
28+
def p = ''
29+
sh "> \$(pwd)/mkdirs.txt"
30+
uploadPath.each {
31+
p += "/${it}"
32+
sh("echo -mkdir $p >> \$(pwd)/mkdirs.txt")
33+
}
34+
35+
sshagent(['jenkins-artifact']) {
36+
sh "ssh-agent"
37+
artifactServers.each {
38+
sh "sftp -b \$(pwd)/mkdirs.txt jenkins@${it} || true"
39+
sh "sftp -b \$(pwd)/batch.txt jenkins@${it}"
40+
}
41+
}
42+
}
43+
44+
return this

.jenkinsci/bindings.groovy

Lines changed: 63 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,74 @@
11
#!/usr/bin/env groovy
22

3-
def doBindings() {
4-
def cmake_options = ""
5-
if (params.JavaBindings) {
6-
cmake_options += " -DSWIG_JAVA=ON "
7-
}
8-
if (params.PythonBindings) {
9-
cmake_options += " -DSWIG_PYTHON=ON "
10-
}
11-
// In case language specific options were not set,
12-
// build for each language
13-
if (!params.JavaBindings && !params.PythonBindings) {
14-
cmake_options += " -DSWIG_JAVA=ON -DSWIG_PYTHON=ON "
15-
}
3+
def doJavaBindings(buildType=Release) {
4+
def currentPath = sh(script: "pwd", returnStdout: true).trim()
5+
def commit = env.GIT_COMMIT
6+
def artifactsPath = sprintf('%1$s/java-bindings-%2$s-%3$s-%4$s.zip',
7+
[currentPath, buildType, sh(script: 'date "+%Y%m%d"', returnStdout: true).trim(), commit.substring(0,6)])
168
sh """
179
cmake \
1810
-H. \
1911
-Bbuild \
20-
-DCMAKE_BUILD_TYPE=Release \
21-
${cmake_options}
12+
-DCMAKE_BUILD_TYPE=$buildType \
13+
-DSWIG_JAVA=ON
14+
"""
15+
sh "cd build; make -j${params.PARALLELISM} irohajava"
16+
sh "zip -j $artifactsPath build/shared_model/bindings/*.java build/shared_model/bindings/libirohajava.so"
17+
sh "cp $artifactsPath /tmp/bindings-artifact"
18+
return artifactsPath
19+
}
20+
21+
def doPythonBindings(buildType=Release) {
22+
def currentPath = sh(script: "pwd", returnStdout: true).trim()
23+
def commit = env.GIT_COMMIT
24+
def supportPython2 = "OFF"
25+
def artifactsPath = sprintf('%1$s/python-bindings-%2$s-%3$s-%4$s-%5$s.zip',
26+
[currentPath, env.PBVersion, buildType, sh(script: 'date "+%Y%m%d"', returnStdout: true).trim(), commit.substring(0,6)])
27+
// do not use preinstalled libed25519
28+
sh "rm -rf /usr/local/include/ed25519*; unlink /usr/local/lib/libed25519.so; rm -f /usr/local/lib/libed25519.so.1.2.2"
29+
if (env.PBVersion == "python2") { supportPython2 = "ON" }
30+
sh """
31+
cmake \
32+
-H. \
33+
-Bbuild \
34+
-DCMAKE_BUILD_TYPE=$buildType \
35+
-DSWIG_PYTHON=ON \
36+
-DSUPPORT_PYTHON2=$supportPython2
2237
"""
2338
sh "cmake --build build --target python_tests"
24-
sh "cd build; make -j${params.PARALLELISM} irohajava irohapy"
39+
sh "cd build; make -j${params.PARALLELISM} irohapy"
40+
sh "protoc --proto_path=schema --python_out=build/shared_model/bindings block.proto primitive.proto commands.proto queries.proto responses.proto endpoint.proto"
41+
sh "${env.PBVersion} -m grpc_tools.protoc --proto_path=schema --python_out=build/shared_model/bindings --grpc_python_out=build/shared_model/bindings endpoint.proto yac.proto ordering.proto loader.proto"
42+
sh "zip -j $artifactsPath build/shared_model/bindings/*.py build/shared_model/bindings/*.so"
43+
sh "cp $artifactsPath /tmp/bindings-artifact"
44+
return artifactsPath
45+
}
46+
47+
def doAndroidBindings(abiVersion) {
48+
def currentPath = sh(script: "pwd", returnStdout: true).trim()
49+
def commit = env.GIT_COMMIT
50+
def artifactsPath = sprintf('%1$s/android-bindings-%2$s-%3$s-%4$s-%5$s-%6$s.zip',
51+
[currentPath, "\$PLATFORM", abiVersion, "\$BUILD_TYPE_A", sh(script: 'date "+%Y%m%d"', returnStdout: true).trim(), commit.substring(0,6)])
52+
sh """
53+
(cd /iroha; git init; git remote add origin https://github.com/hyperledger/iroha.git; \
54+
git fetch --depth 1 origin develop; git checkout -t origin/develop)
55+
"""
56+
sh """
57+
. /entrypoint.sh; \
58+
sed -i.bak "s~find_package(JNI REQUIRED)~SET(CMAKE_SWIG_FLAGS \\\${CMAKE_SWIG_FLAGS} -package \${PACKAGE})~" /iroha/shared_model/bindings/CMakeLists.txt; \
59+
# TODO: might not be needed in the future
60+
sed -i.bak "/target_include_directories(\\\${SWIG_MODULE_irohajava_REAL_NAME} PUBLIC/,+3d" /iroha/shared_model/bindings/CMakeLists.txt; \
61+
sed -i.bak "s~swig_link_libraries(irohajava~swig_link_libraries(irohajava \"/protobuf/.build/lib\${PROTOBUF_LIB_NAME}.a\" \"\${NDK_PATH}/platforms/android-$abiVersion/\${ARCH}/usr/\${LIBP}/liblog.so\"~" /iroha/shared_model/bindings/CMakeLists.txt; \
62+
sed -i.bak "s~find_library(protobuf_LIBRARY protobuf)~find_library(protobuf_LIBRARY \${PROTOBUF_LIB_NAME})~" /iroha/cmake/Modules/Findprotobuf.cmake; \
63+
sed -i.bak "s~find_program(protoc_EXECUTABLE protoc~set(protoc_EXECUTABLE \"/protobuf/host_build/protoc\"~" /iroha/cmake/Modules/Findprotobuf.cmake; \
64+
cmake -H/iroha/shared_model -B/iroha/shared_model/build -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=$abiVersion -DCMAKE_ANDROID_ARCH_ABI=\$PLATFORM \
65+
-DANDROID_NDK=\$NDK_PATH -DCMAKE_ANDROID_STL_TYPE=c++_static -DCMAKE_BUILD_TYPE=\$BUILD_TYPE_A -DTESTING=OFF \
66+
-DSHARED_MODEL_DISABLE_COMPATIBILITY=ON -DSWIG_JAVA=ON -DCMAKE_PREFIX_PATH=\$DEPS_DIR
67+
"""
68+
sh "cmake --build /iroha/shared_model/build --target irohajava -- -j${params.PARALLELISM}"
69+
sh "zip -j $artifactsPath /iroha/shared_model/build/bindings/*.java /iroha/shared_model/build/bindings/libirohajava.so"
70+
sh "cp $artifactsPath /tmp/bindings-artifact"
71+
return artifactsPath
2572
}
2673

2774
return this

.jenkinsci/debug-build.groovy

Lines changed: 91 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,115 @@
11
#!/usr/bin/env groovy
22

33
def doDebugBuild(coverageEnabled=false) {
4+
def dPullOrBuild = load ".jenkinsci/docker-pull-or-build.groovy"
5+
def manifest = load ".jenkinsci/docker-manifest.groovy"
6+
def pCommit = load ".jenkinsci/previous-commit.groovy"
47
def parallelism = params.PARALLELISM
8+
def platform = sh(script: 'uname -m', returnStdout: true).trim()
9+
def previousCommit = pCommit.previousCommitOrCurrent()
510
// params are always null unless job is started
611
// this is the case for the FIRST build only.
712
// So just set this to same value as default.
813
// This is a known bug. See https://issues.jenkins-ci.org/browse/JENKINS-41929
9-
if (parallelism == null) {
14+
if (!parallelism) {
1015
parallelism = 4
1116
}
12-
if ("arm7" in env.NODE_NAME) {
17+
if (env.NODE_NAME.contains('arm7')) {
1318
parallelism = 1
1419
}
1520
sh "docker network create ${env.IROHA_NETWORK}"
21+
def iC = dPullOrBuild.dockerPullOrUpdate("${platform}-develop-build",
22+
"${env.GIT_RAW_BASE_URL}/${env.GIT_COMMIT}/docker/develop/Dockerfile",
23+
"${env.GIT_RAW_BASE_URL}/${previousCommit}/docker/develop/Dockerfile",
24+
"${env.GIT_RAW_BASE_URL}/develop/docker/develop/Dockerfile",
25+
['PARALLELISM': parallelism])
1626

17-
docker.image('postgres:9.5').run(""
27+
if (GIT_LOCAL_BRANCH == 'develop' && manifest.manifestSupportEnabled()) {
28+
manifest.manifestCreate("${DOCKER_REGISTRY_BASENAME}:develop-build",
29+
["${DOCKER_REGISTRY_BASENAME}:x86_64-develop-build",
30+
"${DOCKER_REGISTRY_BASENAME}:armv7l-develop-build",
31+
"${DOCKER_REGISTRY_BASENAME}:aarch64-develop-build"])
32+
manifest.manifestAnnotate("${DOCKER_REGISTRY_BASENAME}:develop-build",
33+
[
34+
[manifest: "${DOCKER_REGISTRY_BASENAME}:x86_64-develop-build",
35+
arch: 'amd64', os: 'linux', osfeatures: [], variant: ''],
36+
[manifest: "${DOCKER_REGISTRY_BASENAME}:armv7l-develop-build",
37+
arch: 'arm', os: 'linux', osfeatures: [], variant: 'v7'],
38+
[manifest: "${DOCKER_REGISTRY_BASENAME}:aarch64-develop-build",
39+
arch: 'arm64', os: 'linux', osfeatures: [], variant: '']
40+
])
41+
withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials', usernameVariable: 'login', passwordVariable: 'password')]) {
42+
manifest.manifestPush("${DOCKER_REGISTRY_BASENAME}:develop-build", login, password)
43+
}
44+
}
45+
docker.image('postgres:9.5').withRun(""
1846
+ " -e POSTGRES_USER=${env.IROHA_POSTGRES_USER}"
1947
+ " -e POSTGRES_PASSWORD=${env.IROHA_POSTGRES_PASSWORD}"
2048
+ " --name ${env.IROHA_POSTGRES_HOST}"
21-
+ " --network=${env.IROHA_NETWORK}")
22-
23-
def platform = sh(script: 'uname -m', returnStdout: true).trim()
24-
sh "curl -L -o /tmp/${env.GIT_COMMIT}/Dockerfile --create-dirs https://raw.githubusercontent.com/hyperledger/iroha/${env.GIT_COMMIT}/docker/develop/${platform}/Dockerfile"
25-
// pull docker image in case we don't have one
26-
// speeds up consequent image builds as we simply tag them
27-
sh "docker pull ${DOCKER_BASE_IMAGE_DEVELOP}"
28-
if (env.BRANCH_NAME == 'develop') {
29-
iC = docker.build("hyperledger/iroha:${GIT_COMMIT}-${BUILD_NUMBER}", "--build-arg PARALLELISM=${parallelism} -f /tmp/${env.GIT_COMMIT}/Dockerfile /tmp/${env.GIT_COMMIT}")
30-
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
31-
iC.push("${platform}-develop")
32-
}
33-
}
34-
else {
35-
iC = docker.build("hyperledger/iroha-workflow:${GIT_COMMIT}-${BUILD_NUMBER}", "-f /tmp/${env.GIT_COMMIT}/Dockerfile /tmp/${env.GIT_COMMIT} --build-arg PARALLELISM=${parallelism}")
36-
}
37-
iC.inside(""
38-
+ " -e IROHA_POSTGRES_HOST=${env.IROHA_POSTGRES_HOST}"
39-
+ " -e IROHA_POSTGRES_PORT=${env.IROHA_POSTGRES_PORT}"
40-
+ " -e IROHA_POSTGRES_USER=${env.IROHA_POSTGRES_USER}"
41-
+ " -e IROHA_POSTGRES_PASSWORD=${env.IROHA_POSTGRES_PASSWORD}"
42-
+ " --network=${env.IROHA_NETWORK}"
43-
+ " -v /var/jenkins/ccache:${CCACHE_DIR}") {
44-
45-
def scmVars = checkout scm
46-
def cmakeOptions = ""
47-
if ( coverageEnabled ) {
48-
cmakeOptions = " -DCOVERAGE=ON "
49-
}
50-
env.IROHA_VERSION = "0x${scmVars.GIT_COMMIT}"
51-
env.IROHA_HOME = "/opt/iroha"
52-
env.IROHA_BUILD = "${env.IROHA_HOME}/build"
49+
+ " --network=${env.IROHA_NETWORK}") {
50+
iC.inside(""
51+
+ " -e IROHA_POSTGRES_HOST=${env.IROHA_POSTGRES_HOST}"
52+
+ " -e IROHA_POSTGRES_PORT=${env.IROHA_POSTGRES_PORT}"
53+
+ " -e IROHA_POSTGRES_USER=${env.IROHA_POSTGRES_USER}"
54+
+ " -e IROHA_POSTGRES_PASSWORD=${env.IROHA_POSTGRES_PASSWORD}"
55+
+ " --network=${env.IROHA_NETWORK}"
56+
+ " -v /var/jenkins/ccache:${CCACHE_DIR}"
57+
+ " -v /tmp/${GIT_COMMIT}-${BUILD_NUMBER}:/tmp/${GIT_COMMIT}") {
5358

54-
sh """
55-
ccache --version
56-
ccache --show-stats
57-
ccache --zero-stats
58-
ccache --max-size=5G
59-
"""
60-
sh """
61-
cmake \
62-
-DTESTING=ON \
63-
-H. \
64-
-Bbuild \
65-
-DCMAKE_BUILD_TYPE=Debug \
66-
-DIROHA_VERSION=${env.IROHA_VERSION} \
67-
${cmakeOptions}
68-
"""
69-
sh "cmake --build build -- -j${parallelism}"
70-
sh "ccache --show-stats"
71-
if ( coverageEnabled ) {
72-
sh "cmake --build build --target coverage.init.info"
73-
}
74-
def testExitCode = sh(script: 'cmake --build build --target test', returnStatus: true)
75-
if (testExitCode != 0) {
76-
currentBuild.result = "UNSTABLE"
77-
}
78-
if ( coverageEnabled ) {
79-
sh "cmake --build build --target cppcheck"
80-
// Sonar
81-
if (env.CHANGE_ID != null) {
82-
sh """
83-
sonar-scanner \
84-
-Dsonar.github.disableInlineComments \
85-
-Dsonar.github.repository='hyperledger/iroha' \
86-
-Dsonar.analysis.mode=preview \
87-
-Dsonar.login=${SONAR_TOKEN} \
88-
-Dsonar.projectVersion=${BUILD_TAG} \
89-
-Dsonar.github.oauth=${SORABOT_TOKEN} \
90-
-Dsonar.github.pullRequest=${CHANGE_ID}
91-
"""
59+
def scmVars = checkout scm
60+
def cmakeOptions = ""
61+
if ( coverageEnabled ) {
62+
cmakeOptions = " -DCOVERAGE=ON "
9263
}
64+
env.IROHA_VERSION = "0x${scmVars.GIT_COMMIT}"
65+
env.IROHA_HOME = "/opt/iroha"
66+
env.IROHA_BUILD = "${env.IROHA_HOME}/build"
9367

94-
sh "cmake --build build --target coverage.info"
95-
sh "python /tmp/lcov_cobertura.py build/reports/coverage.info -o build/reports/coverage.xml"
96-
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/build/reports/coverage.xml', conditionalCoverageTargets: '75, 50, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '75, 50, 0', maxNumberOfBuilds: 50, methodCoverageTargets: '75, 50, 0', onlyStable: false, zoomCoverageChart: false
97-
}
98-
99-
// TODO: replace with upload to artifactory server
100-
// develop branch only
101-
if ( env.BRANCH_NAME == "develop" ) {
102-
//archive(includes: 'build/bin/,compile_commands.json')
68+
sh """
69+
ccache --version
70+
ccache --show-stats
71+
ccache --zero-stats
72+
ccache --max-size=5G
73+
"""
74+
sh """
75+
cmake \
76+
-DTESTING=ON \
77+
-H. \
78+
-Bbuild \
79+
-DCMAKE_BUILD_TYPE=Debug \
80+
-DIROHA_VERSION=${env.IROHA_VERSION} \
81+
${cmakeOptions}
82+
"""
83+
sh "cmake --build build -- -j${parallelism}"
84+
sh "ccache --show-stats"
85+
if ( coverageEnabled ) {
86+
sh "cmake --build build --target coverage.init.info"
87+
}
88+
def testExitCode = sh(script: 'CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test', returnStatus: true)
89+
if (testExitCode != 0) {
90+
currentBuild.result = "UNSTABLE"
91+
}
92+
if ( coverageEnabled ) {
93+
sh "cmake --build build --target cppcheck"
94+
// Sonar
95+
if (env.CHANGE_ID != null) {
96+
sh """
97+
sonar-scanner \
98+
-Dsonar.github.disableInlineComments \
99+
-Dsonar.github.repository='${DOCKER_REGISTRY_BASENAME}' \
100+
-Dsonar.analysis.mode=preview \
101+
-Dsonar.login=${SONAR_TOKEN} \
102+
-Dsonar.projectVersion=${BUILD_TAG} \
103+
-Dsonar.github.oauth=${SORABOT_TOKEN} \
104+
-Dsonar.github.pullRequest=${CHANGE_ID}
105+
"""
106+
}
107+
sh "cmake --build build --target coverage.info"
108+
sh "python /tmp/lcov_cobertura.py build/reports/coverage.info -o build/reports/coverage.xml"
109+
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/build/reports/coverage.xml', conditionalCoverageTargets: '75, 50, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '75, 50, 0', maxNumberOfBuilds: 50, methodCoverageTargets: '75, 50, 0', onlyStable: false, zoomCoverageChart: false
110+
}
103111
}
104112
}
105113
}
114+
106115
return this

.jenkinsci/docker-manifest.groovy

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env groovy
2+
3+
def manifestSupportEnabled() {
4+
def dockerVersion = sh(script: "docker -v", returnStdout: true).trim()
5+
def experimentalEnabled = sh(script: "grep -i experimental ~/.docker/config.json", returnStatus: true)
6+
return experimentalEnabled == 0 && dockerVersion ==~ /^Docker version 18.*$/
7+
8+
}
9+
10+
def manifestCreate(manifestListName, manifests) {
11+
sh "docker manifest create ${manifestListName} ${manifests.join(' ')}"
12+
}
13+
14+
def manifestAnnotate(manifestListName, manifestsWithFeatures) {
15+
manifestsWithFeatures.each {
16+
sh """
17+
docker manifest annotate ${manifestListName} ${it['manifest']} --arch "${it['arch']}" \
18+
--os "${it['os']}" --os-features "${it['osfeatures'].join(',')}" --variant "${it['variant']}"
19+
"""
20+
}
21+
}
22+
23+
def manifestPush(manifestListName, dockerRegistryLogin, dockerRegistryPassword) {
24+
sh "docker login -u '${dockerRegistryLogin}' -p '${dockerRegistryPassword}'"
25+
sh "docker manifest push --purge ${manifestListName}"
26+
}
27+
28+
return this

0 commit comments

Comments
 (0)