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

Commit 731d2c7

Browse files
authored
Merge pull request #2089 from hyperledger/develop
Hyperledger Iroha v1.0 Release Candidate 3
2 parents 7fc63c0 + 228c49c commit 731d2c7

File tree

461 files changed

+8476
-13150
lines changed

Some content is hidden

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

461 files changed

+8476
-13150
lines changed

.jenkinsci-new/artifacts.groovy

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env groovy
2+
/**
3+
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
//
8+
// Upload Artifacts to nexus
9+
//
10+
11+
def uploadArtifacts(filePaths, uploadPath, artifactServers=['nexus.iroha.tech']) {
12+
def filePathsConverted = []
13+
agentType = sh(script: 'uname', returnStdout: true).trim()
14+
filePaths.each {
15+
fp = sh(script: "ls -d ${it} | tr '\n' ','", returnStdout: true).trim()
16+
filePathsConverted.addAll(fp.split(','))
17+
}
18+
def shaSumBinary = 'sha256sum'
19+
def md5SumBinary = 'md5sum'
20+
def gpgKeyBinary = 'gpg --armor --detach-sign --no-tty --batch --yes --passphrase-fd 0'
21+
if (agentType == 'Darwin') {
22+
shaSumBinary = 'shasum -a 256'
23+
md5SumBinary = 'md5 -r'
24+
gpgKeyBinary = 'GPG_TTY=\$(tty) gpg --pinentry-mode loopback --armor --detach-sign --no-tty --batch --yes --passphrase-fd 0'
25+
}
26+
sh "> \$(pwd)/batch.txt"
27+
28+
withCredentials([file(credentialsId: 'ci_gpg_privkey', variable: 'CI_GPG_PRIVKEY'), string(credentialsId: 'ci_gpg_masterkey', variable: 'CI_GPG_MASTERKEY')]) {
29+
if (!agentType.contains('MSYS_NT')) {
30+
sh "gpg --yes --batch --no-tty --import ${CI_GPG_PRIVKEY} || true"
31+
}
32+
filePathsConverted.each {
33+
sh "echo ${it} >> \$(pwd)/batch.txt;"
34+
sh "$shaSumBinary ${it} | cut -d' ' -f1 > \$(pwd)/\$(basename ${it}).sha256"
35+
sh "$md5SumBinary ${it} | cut -d' ' -f1 > \$(pwd)/\$(basename ${it}).md5"
36+
if (!agentType.contains('MSYS_NT')) {
37+
sh "echo \"${CI_GPG_MASTERKEY}\" | $gpgKeyBinary -o \$(pwd)/\$(basename ${it}).ascfile ${it}"
38+
sh "echo \$(pwd)/\$(basename ${it}).ascfile >> \$(pwd)/batch.txt;"
39+
}
40+
sh "echo \$(pwd)/\$(basename ${it}).sha256 >> \$(pwd)/batch.txt;"
41+
sh "echo \$(pwd)/\$(basename ${it}).md5 >> \$(pwd)/batch.txt;"
42+
}
43+
}
44+
45+
withCredentials([usernamePassword(credentialsId: 'ci_nexus', passwordVariable: 'NEXUS_PASS', usernameVariable: 'NEXUS_USER')]) {
46+
artifactServers.each {
47+
sh(script: "while read line; do curl --http1.1 -u ${NEXUS_USER}:${NEXUS_PASS} --upload-file \$line https://${it}/repository/artifacts/${uploadPath}/ ; done < \$(pwd)/batch.txt")
48+
}
49+
}
50+
}
51+
52+
return this
53+

.jenkinsci-new/build.groovy

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env groovy
2+
/**
3+
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
//
8+
// functions we use when build iroha
9+
//
10+
11+
def cmakeConfigure(String buildDir, String cmakeOptions, String sourceTreeDir=".") {
12+
sh "cmake -H${sourceTreeDir} -B${buildDir} ${cmakeOptions}"
13+
}
14+
15+
def cmakeBuild(String buildDir, String cmakeOptions, int parallelism) {
16+
sh "cmake --build ${buildDir} ${cmakeOptions} -- -j${parallelism}"
17+
sh "ccache --show-stats"
18+
}
19+
20+
def cmakeBuildWindows(String buildDir, String cmakeOptions) {
21+
sh "cmake --build ${buildDir} ${cmakeOptions}"
22+
}
23+
24+
def cppCheck(String buildDir, int parallelism) {
25+
// github.com/jenkinsci/cppcheck-plugin/pull/36
26+
sh "cppcheck -j${parallelism} --enable=all -i${buildDir} --template='{file},,{line},,{severity},,{id},,{message}' . 2> cppcheck.txt"
27+
warnings (
28+
parserConfigurations: [[parserName: 'Cppcheck', pattern: "cppcheck.txt"]], categoriesPattern: '',
29+
defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: ''
30+
)
31+
}
32+
33+
def sonarScanner(scmVars, environment) {
34+
withEnv(environment) {
35+
withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN'), string(credentialsId: 'SORABOT_TOKEN', variable: 'SORABOT_TOKEN')]) {
36+
sonar_option = ""
37+
if (scmVars.CHANGE_ID != null)
38+
sonar_option = "-Dsonar.github.pullRequest=${scmVars.CHANGE_ID}"
39+
else
40+
print "************** Warning No 'CHANGE_ID' Present run sonar without org.sonar.plugins.github.PullRequestProjectBuilder *****************"
41+
42+
sh """
43+
sonar-scanner \
44+
-Dsonar.github.disableInlineComments \
45+
-Dsonar.github.repository='${env.DOCKER_REGISTRY_BASENAME}' \
46+
-Dsonar.analysis.mode=preview \
47+
-Dsonar.login=${SONAR_TOKEN} \
48+
-Dsonar.projectVersion=${BUILD_TAG} \
49+
-Dsonar.github.oauth=${SORABOT_TOKEN} ${sonar_option}
50+
"""
51+
}
52+
}
53+
}
54+
55+
def initialCoverage(String buildDir) {
56+
sh "cmake --build ${buildDir} --target coverage.init.info"
57+
}
58+
59+
def postCoverage(buildDir, String cobertura_bin) {
60+
sh "cmake --build ${buildDir} --target coverage.info"
61+
sh "python ${cobertura_bin} ${buildDir}/reports/coverage.info -o ${buildDir}/reports/coverage.xml"
62+
cobertura autoUpdateHealth: false, autoUpdateStability: false,
63+
coberturaReportFile: "**/${buildDir}/reports/coverage.xml", conditionalCoverageTargets: '75, 50, 0',
64+
failUnhealthy: false, failUnstable: false, lineCoverageTargets: '75, 50, 0', maxNumberOfBuilds: 50,
65+
methodCoverageTargets: '75, 50, 0', onlyStable: false, zoomCoverageChart: false
66+
}
67+
return this
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
#!/usr/bin/env groovy
2+
/**
3+
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
//
8+
// Linux Build steps
9+
//
10+
11+
def dockerManifestPush(dockerImageObj, String dockerTag, environment) {
12+
def manifest = load ".jenkinsci-new/utils/docker-manifest.groovy"
13+
withEnv(environment) {
14+
if (manifest.manifestSupportEnabled()) {
15+
manifest.manifestCreate("${env.DOCKER_REGISTRY_BASENAME}:${dockerTag}",
16+
["${env.DOCKER_REGISTRY_BASENAME}:x86_64-${dockerTag}"])
17+
manifest.manifestAnnotate("${env.DOCKER_REGISTRY_BASENAME}:${dockerTag}",
18+
[
19+
[manifest: "${env.DOCKER_REGISTRY_BASENAME}:x86_64-${dockerTag}",
20+
arch: 'amd64', os: 'linux', osfeatures: [], variant: ''],
21+
])
22+
withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials', usernameVariable: 'login', passwordVariable: 'password')]) {
23+
manifest.manifestPush("${env.DOCKER_REGISTRY_BASENAME}:${dockerTag}", login, password)
24+
}
25+
}
26+
else {
27+
echo('[WARNING] Docker CLI does not support manifest management features. Manifest will not be updated')
28+
}
29+
}
30+
}
31+
32+
def testSteps(String buildDir, List environment, String testList) {
33+
withEnv(environment) {
34+
sh "cd ${buildDir}; ctest --output-on-failure --no-compress-output --tests-regex '${testList}' --test-action Test || true"
35+
sh """ python .jenkinsci-new/helpers/platform_tag.py "Linux \$(uname -m)" \$(ls ${buildDir}/Testing/*/Test.xml) """
36+
// Mark build as UNSTABLE if there are any failed tests (threshold <100%)
37+
xunit testTimeMargin: '3000', thresholdMode: 2, thresholds: [passed(unstableThreshold: '100')], \
38+
tools: [CTest(deleteOutputFiles: true, failIfNotNew: false, \
39+
pattern: "${buildDir}/Testing/**/Test.xml", skipNoTestFiles: false, stopProcessingIfError: true)]
40+
}
41+
}
42+
43+
def buildSteps(int parallelism, List compilerVersions, String build_type, boolean specialBranch, boolean coverage,
44+
boolean testing, String testList, boolean cppcheck, boolean sonar, boolean docs, boolean packagebuild, boolean sanitize, boolean fuzzing, List environment) {
45+
withEnv(environment) {
46+
scmVars = checkout scm
47+
def build = load '.jenkinsci-new/build.groovy'
48+
def vars = load ".jenkinsci-new/utils/vars.groovy"
49+
def utils = load ".jenkinsci-new/utils/utils.groovy"
50+
def dockerUtils = load ".jenkinsci-new/utils/docker-pull-or-build.groovy"
51+
def doxygen = load ".jenkinsci-new/utils/doxygen.groovy"
52+
buildDir = 'build'
53+
compilers = vars.compilerMapping()
54+
cmakeBooleanOption = [ (true): 'ON', (false): 'OFF' ]
55+
platform = sh(script: 'uname -m', returnStdout: true).trim()
56+
cmakeBuildOptions = ""
57+
cmakeOptions = ""
58+
if (packagebuild){
59+
cmakeBuildOptions = " --target package "
60+
}
61+
if (sanitize){
62+
cmakeOptions += " -DSANITIZE='address;leak' "
63+
}
64+
65+
// Create postgres
66+
// enable prepared transactions so that 2 phase commit works
67+
// we set it to 100 as a safe value
68+
sh """#!/bin/bash -xe
69+
if [ ! "\$(docker ps -q -f name=${env.IROHA_POSTGRES_HOST})" ]; then
70+
docker network create ${env.IROHA_NETWORK}
71+
docker run -td -e POSTGRES_USER=${env.IROHA_POSTGRES_USER} \
72+
-e POSTGRES_PASSWORD=${env.IROHA_POSTGRES_PASSWORD} --name ${env.IROHA_POSTGRES_HOST} \
73+
--network=${env.IROHA_NETWORK} postgres:9.5 -c 'max_prepared_transactions=100'
74+
fi
75+
"""
76+
77+
iC = dockerUtils.dockerPullOrBuild("${platform}-develop-build",
78+
"${env.GIT_RAW_BASE_URL}/${scmVars.GIT_COMMIT}/docker/develop/Dockerfile",
79+
"${env.GIT_RAW_BASE_URL}/${utils.previousCommitOrCurrent(scmVars)}/docker/develop/Dockerfile",
80+
"${env.GIT_RAW_BASE_URL}/develop/docker/develop/Dockerfile",
81+
scmVars,
82+
environment,
83+
['PARALLELISM': parallelism])
84+
85+
iC.inside(""
86+
+ " -e IROHA_POSTGRES_HOST=${env.IROHA_POSTGRES_HOST}"
87+
+ " -e IROHA_POSTGRES_PORT=${env.IROHA_POSTGRES_PORT}"
88+
+ " -e IROHA_POSTGRES_USER=${env.IROHA_POSTGRES_USER}"
89+
+ " -e IROHA_POSTGRES_PASSWORD=${env.IROHA_POSTGRES_PASSWORD}"
90+
+ " --network=${env.IROHA_NETWORK}"
91+
+ " -v /var/jenkins/ccache:${env.CCACHE_DEBUG_DIR}") {
92+
utils.ccacheSetup(5)
93+
for (compiler in compilerVersions) {
94+
stage ("build ${compiler}"){
95+
build.cmakeConfigure(buildDir, "-DCMAKE_CXX_COMPILER=${compilers[compiler]['cxx_compiler']} \
96+
-DCMAKE_C_COMPILER=${compilers[compiler]['cc_compiler']} \
97+
-DCMAKE_BUILD_TYPE=${build_type} \
98+
-DCOVERAGE=${cmakeBooleanOption[coverage]} \
99+
-DTESTING=${cmakeBooleanOption[testing]} \
100+
-DFUZZING=${cmakeBooleanOption[fuzzing]} \
101+
-DPACKAGE_DEB=${cmakeBooleanOption[packagebuild]} \
102+
-DPACKAGE_TGZ=${cmakeBooleanOption[packagebuild]} ${cmakeOptions}")
103+
build.cmakeBuild(buildDir, cmakeBuildOptions, parallelism)
104+
}
105+
if (testing) {
106+
stage("Test ${compiler}") {
107+
coverage ? build.initialCoverage(buildDir) : echo('Skipping initial coverage...')
108+
testSteps(buildDir, environment, testList)
109+
coverage ? build.postCoverage(buildDir, '/tmp/lcov_cobertura.py') : echo('Skipping post coverage...')
110+
// We run coverage once, using the first compiler as it is enough
111+
coverage = false
112+
}
113+
} //end if
114+
} //end for
115+
stage("Analysis") {
116+
cppcheck ? build.cppCheck(buildDir, parallelism) : echo('Skipping Cppcheck...')
117+
sonar ? build.sonarScanner(scmVars, environment) : echo('Skipping Sonar Scanner...')
118+
}
119+
stage('Build docs'){
120+
docs ? doxygen.doDoxygen(specialBranch, scmVars.GIT_LOCAL_BRANCH) : echo("Skipping Doxygen...")
121+
}
122+
} // end iC.inside
123+
stage ('Docker ManifestPush'){
124+
if (specialBranch) {
125+
utils.dockerPush(iC, "${platform}-develop-build")
126+
dockerManifestPush(iC, "develop-build", environment)
127+
}
128+
}
129+
}
130+
}
131+
132+
def successPostSteps(scmVars, boolean packagePush, String dockerTag, List environment) {
133+
stage('Linux success PostSteps') {
134+
withEnv(environment) {
135+
if (packagePush) {
136+
def artifacts = load ".jenkinsci-new/artifacts.groovy"
137+
def utils = load ".jenkinsci-new/utils/utils.groovy"
138+
platform = sh(script: 'uname -m', returnStdout: true).trim()
139+
def commit = scmVars.GIT_COMMIT
140+
141+
// if we use several compilers only the last compiler, used for the build, will be used for iroha.deb and iroha.tar.gz archives
142+
sh """
143+
ls -lah ./build
144+
mv ./build/iroha-*.deb ./build/iroha.deb
145+
mv ./build/iroha-*.tar.gz ./build/iroha.tar.gz
146+
cp ./build/iroha.deb docker/release/iroha.deb
147+
mkdir -p build/artifacts
148+
mv ./build/iroha.deb ./build/iroha.tar.gz build/artifacts
149+
"""
150+
// publish docker
151+
iCRelease = docker.build("${env.DOCKER_REGISTRY_BASENAME}:${commit}-${env.BUILD_NUMBER}-release", "--no-cache -f docker/release/Dockerfile ${WORKSPACE}/docker/release")
152+
utils.dockerPush(iCRelease, "${platform}-${dockerTag}")
153+
dockerManifestPush(iCRelease, dockerTag, environment)
154+
sh "docker rmi ${iCRelease.id}"
155+
156+
// publish packages
157+
filePaths = [ './build/artifacts/iroha.deb', './build/artifacts/iroha.tar.gz' ]
158+
artifacts.uploadArtifacts(filePaths, sprintf('/iroha/linux/%4$s/%1$s-%2$s-%3$s', [scmVars.GIT_LOCAL_BRANCH, sh(script: 'date "+%Y%m%d"', returnStdout: true).trim(), commit.substring(0,6), platform]))
159+
} else {
160+
archiveArtifacts artifacts: 'build/iroha*.tar.gz', allowEmptyArchive: true
161+
archiveArtifacts artifacts: 'build/iroha*.deb', allowEmptyArchive: true
162+
}
163+
}
164+
}
165+
}
166+
167+
def alwaysPostSteps(List environment) {
168+
stage('Linux always PostSteps') {
169+
withEnv(environment) {
170+
sh "docker rm -f ${env.IROHA_POSTGRES_HOST} || true"
171+
sh "docker network rm ${env.IROHA_NETWORK}"
172+
cleanWs()
173+
}
174+
}
175+
}
176+
177+
return this

0 commit comments

Comments
 (0)