-
Notifications
You must be signed in to change notification settings - Fork 295
Conversation
.jenkinsci/debug-build.groovy
Outdated
// This is a known bug. See https://issues.jenkins-ci.org/browse/JENKINS-41929 | ||
if (!parallelism) { | ||
if (parallelism == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, revert to !parallelism
as it was fixed in previous commits. You have not merged properly, I suppose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've not rebased properly. It will be fixed in the next commit
@@ -19,7 +19,13 @@ def buildOptionsString(options) { | |||
|
|||
def dockerPullOrUpdate(imageName, currentDockerfileURL, previousDockerfileURL, referenceDockerfileURL, buildOptions=null) { | |||
buildOptions = buildOptionsString(buildOptions) | |||
// GIT_PREVIOUS_COMMIT is null for first PR build | |||
if (!previousDockerfileURL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition always returns true
.jenkinsci/debug-build.groovy
Outdated
@@ -53,62 +112,49 @@ def doDebugBuild(coverageEnabled=false) { | |||
+ " -e IROHA_POSTGRES_USER=${env.IROHA_POSTGRES_USER}" | |||
+ " -e IROHA_POSTGRES_PASSWORD=${env.IROHA_POSTGRES_PASSWORD}" | |||
+ " --network=${env.IROHA_NETWORK}" | |||
+ " -v /var/jenkins/ccache:${CCACHE_DIR}" | |||
+ " -v ${CCACHE_DIR}:${CCACHE_DIR}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CCache here has no effect. It does not speed up tests
.jenkinsci/debug-build.groovy
Outdated
@@ -53,62 +112,49 @@ def doDebugBuild(coverageEnabled=false) { | |||
+ " -e IROHA_POSTGRES_USER=${env.IROHA_POSTGRES_USER}" | |||
+ " -e IROHA_POSTGRES_PASSWORD=${env.IROHA_POSTGRES_PASSWORD}" | |||
+ " --network=${env.IROHA_NETWORK}" | |||
+ " -v /var/jenkins/ccache:${CCACHE_DIR}" | |||
+ " -v ${CCACHE_DIR}:${CCACHE_DIR}" | |||
+ " -v /tmp/${GIT_COMMIT}-${BUILD_NUMBER}:/tmp/${GIT_COMMIT}") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to mount artifacts folder for tests stage
.jenkinsci/debug-build.groovy
Outdated
if ( env.NODE_NAME.contains('x86_64') ) { | ||
sh "docker load -i ${JENKINS_DOCKER_IMAGE_DIR}/${dockerImageFile}" | ||
} | ||
def iC = docker.image("${dockerAgentImage}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is only assigned if NODE_NAME
contains x86_64
. Thus, will not work on other agents. Review also other functions
Jenkinsfile
Outdated
if ( params.BUILD_TYPE == 'Debug' || params.Merge_PR ) { | ||
def debugBuild = load ".jenkinsci/debug-build.groovy" | ||
def coverage = load ".jenkinsci/selected-branches-coverage.groovy" | ||
if ( params.Merge_PR ) { debugBuild.doDebugBuild(true) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would coverage be collected twice: first on PR open and then on actual merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for master
branch --> yes, it is according to the docs. Conditions are fixed in the next commit
Jenkinsfile
Outdated
anyOf { | ||
allOf { | ||
expression { return env.CHANGE_ID != null } | ||
not { expression { return env.GIT_PREVIOUS_COMMIT != null } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double negation can be replaced with
{ expression { return ! env.GIT_PREVIOUS_COMMIT }
Also, seems that GIT_PREVIOUS_COMMIT
variable value is not set on a newer versions of Jenkins' Git plugin on PR open. See Jenkins docs: older version vs newer version
Jenkinsfile
Outdated
when { | ||
expression { params.BUILD_TYPE == 'Release' } | ||
beforeAgent true | ||
anyOf { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be omitted
Jenkinsfile
Outdated
steps { | ||
script { | ||
def cov_platform = '' | ||
if (params.Linux) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe implement this platform selection as a separate function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implemented in the .jenkinsci/choose-platform.groovy
Jenkinsfile
Outdated
allOf { | ||
expression { return env.CHANGE_ID != null} | ||
expression { return env.GIT_PREVIOUS_COMMIT != null } | ||
expression { return params.Merge_PR } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expression { return env.CHANGE_TARGET ==~ /(master|develop|trunk)/ }
is not required here, why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually we can remove the whole section when
in parallel stages in Post-coverage
as it is needless after when
in Post-coverage
3e808bd
to
429fd96
Compare
.jenkinsci/debug-build.groovy
Outdated
// params are always null unless job is started | ||
// this is the case for the FIRST build only. | ||
// So just set this to same value as default. | ||
// So just set this to same value as default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant space.
.jenkinsci/choose-platform.groovy
Outdated
|
||
def choosePlatform() { | ||
if (params.Merge_PR) { | ||
return 'x86_64_aws_cov' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of string literals better to use enums. This change improves readability and reduces type errors based on the type system.
.jenkinsci/choose-platform.groovy
Outdated
#!/usr/bin/env groovy | ||
|
||
def choosePlatform() { | ||
if (params.Merge_PR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bakhtin fixed
@@ -19,65 +19,59 @@ def buildOptionsString(options) { | |||
|
|||
def dockerPullOrUpdate(imageName, currentDockerfileURL, previousDockerfileURL, referenceDockerfileURL, buildOptions=null) { | |||
buildOptions = buildOptionsString(buildOptions) | |||
def uploadExitCode = 0 | |||
// GIT_PREVIOUS_COMMIT is null for first PR build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think you can simply remove this block. You should check whether previousDockerfileURL
is null
. Otherwise, you end up querying URL with literal null
string in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bakhtin I think we can as previousDockerfileURL
passed to the dockerPullOrBuild()
method is built from pCommit
variable, which cannot be null
, otherwise it's out of scope of method dockerPullOrBuild()
and should be fixed in the .jenkinsci/previous-commit.groovy
previousCommitOrCurrent()
method
sh "echo 'Reference image ${DOCKER_REGISTRY_BASENAME}:${imageName} doesn't exist on the EFS" | ||
} | ||
} | ||
def pullExitCode = sh(script: "docker pull ${DOCKER_REGISTRY_BASENAME}:${imageName}", returnStatus: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker.image
in the last else
block makes implicit pull. No need to call it earlier explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bakhtin no, it doesn't actually. No other docker pull
commands are used inside dockerPullOrBuild()
method
.jenkinsci/linux-post-step.groovy
Outdated
} | ||
cleanWs() | ||
} | ||
// def linuxPostStep() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented out lines if they're not needed anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bakhtin removed in the next commit
.jenkinsci/github-api.groovy
Outdated
@@ -0,0 +1,113 @@ | |||
#!/usr/bin/env groovy | |||
|
|||
def mergePullRequest() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls, add some description of methods because now it is not so obvious what really this method does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv added
.jenkinsci/github-api.groovy
Outdated
} | ||
} | ||
|
||
def checkMergeAcceptance() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, pls, add a description of the current method and for methods below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv added
.jenkinsci/github-api.groovy
Outdated
jsonResponseReview = slurper.parseText(jsonResponseReview) | ||
if (jsonResponseReview.size() > 0) { | ||
jsonResponseReview.each { | ||
if ("${it.state}" == "APPROVED") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we must forbid merge when someone "request changes" for the pull request.
Generally, we require 2 approves and zero "request changes" for pull requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv good point, I will add this feature at the next commit
.jenkinsci/github-api.groovy
Outdated
|
||
def getMergeMethod() { | ||
if ( env.CHANGE_TARGET == 'master') { | ||
return "merge" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, better to use enums for performing business logic instead of string literals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv fixed
def slurper = new groovy.json.JsonSlurperClassic() | ||
def jsonResponseComment = sh(script: """ | ||
curl -H "Authorization: token ${sorabot}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to make a separate function that will call Github API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv no, as each API call is different:
GET
,PUT
,POST
query- with or w/o token
.jenkinsci/linux-post-step.groovy
Outdated
// } | ||
// } | ||
|
||
def postStep() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add documentation for methods here.
.jenkinsci/mac-debug-build.groovy
Outdated
def doDebugBuild(coverageEnabled=false) { | ||
def parallelism = params.PARALLELISM | ||
if (!parallelism) { | ||
parallelism = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code looks suspicious. What is the point to make 4 threads in the non-parallel build?
Also, better to pass a number of threads in the function and create another one for calculating a number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv now unique method in the file.jenkinsci/choose-platform.groovy
called setParallelism
is created. It is a silver bullet
for the whole pipeline execution branches
.jenkinsci/mac-debug-build.groovy
Outdated
} | ||
} | ||
|
||
def doPostCoverageCoberturaStep() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point to duplicate code here and in debug-build
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in debug-build.groovy
the post-coverage is launched inside a docker-container. in mac-debug-build.groovy
the post-coverage is launched on the host OS with the same logic.
Thus, in debug-build.groovy
I can call doPostCoverageCoberturaStep
from mac-debug-build.groovy
to keep DRY. Will be changed in the next commit
.jenkinsci/mac-release-build.groovy
Outdated
@@ -1,6 +1,10 @@ | |||
#!/usr/bin/env groovy | |||
|
|||
def doReleaseBuild(coverageEnabled=false) { | |||
def parallelism = params.PARALLELISM | |||
if (!parallelism) { | |||
parallelism = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about threads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv fixed
.jenkinsci/test-launcher.groovy
Outdated
def chooseTestType() { | ||
if (params.Merge_PR) { | ||
if (env.NODE_NAME.contains('x86_64')) { | ||
return "(module|integration|system|cmake|regression)*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, better to write direct types in enums and operate on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv fixed in the next commit
.jenkinsci/test-launcher.groovy
Outdated
def printRange(start, end) { | ||
def output = "" | ||
for (type in start..end) { | ||
output = [output, (type.name() != start.toString() ? "|" : ""), type.name()].join('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
join()
already implements the logic of not putting delimeter after the last element in the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bakhtin join()
cannot work with enum
. So we can either do as I proposed in the commit, either transform enum
to string collection/tuple
and use join()
which is even more complex
.jenkinsci/test-launcher.groovy
Outdated
} | ||
} | ||
return "module*" | ||
// just choose module tests | ||
return printRange(TestTypes.module, TestTypes.module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A typo? Should be just return printRange(TestTypes.module)
?
.jenkinsci/docker-cleanup.groovy
Outdated
# Check whether the image is the last-standing man | ||
# i.e., no other tags exist for this image | ||
docker rmi \$(docker images --no-trunc --format '{{.Repository}}:{{.Tag}}\\t{{.ID}}' | grep \$(docker images --no-trunc --format '{{.ID}}' ${iC.id}) | head -n -1 | cut -f 1) || true | ||
sleep 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of sleep? Can we rework it with the synchronous check of rmi
?
Maybe rework it in separate PR, if it is, pls add a task for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv this is a required delay for docker engine to proceed the image removal. Actually, it's a kind of legacy from previous pipeline and left untouched
.jenkinsci/enums.groovy
Outdated
@@ -0,0 +1,10 @@ | |||
enum TestTypes { | |||
module, integration, system, cmake, regression, benchmark, framework |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add explanation of types here.
.jenkinsci/enums.groovy
Outdated
} | ||
|
||
enum CoveragePlatforms { | ||
x86_64_aws_cov, mac, armv8, armv7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add explanation of types here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv done
.jenkinsci/github-api.groovy
Outdated
@@ -1,5 +1,16 @@ | |||
#!/usr/bin/env groovy | |||
|
|||
enum GithubPRStatus { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a documentation for this enum and enums below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv done
.jenkinsci/choose-platform.groovy
Outdated
if (params.Merge_PR) { | ||
return 'x86_64_aws_cov' | ||
if (params.Merge_PR) { | ||
return CoveragePlatforms.x86_64_aws_cov.toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of type erasure (return a string) instead of returning an enum value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv agent label is a string
type, thus, we need to return string
.jenkinsci/github-api.groovy
Outdated
@@ -84,14 +103,15 @@ def getPullRequestReviewers() { | |||
jsonResponseReview = slurper.parseText(jsonResponseReview) | |||
if (jsonResponseReview.size() > 0) { | |||
jsonResponseReview.each { | |||
if ("${it.state}" == "APPROVED") { | |||
if ("${it.state}" == GithubPRStatus.APPROVED.toString() || "${it.state}" == GithubPRStatus.CHANGES_REQUESTED.toString()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to clean up like this:
if( "${it.state}" in [GithubPRStatus.APPROVED.toString(), GithubPRStatus.CHANGES_REQUESTED.toString()])
e73340e
to
5ede358
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to see the changes based on this review before another round of review, because it should reduce the code.
.jenkinsci/choose-platform.groovy
Outdated
return CoveragePlatforms.x86_64_aws_cov.toString() | ||
} | ||
if (!params.Linux && params.MacOS) { | ||
return CoveragePlatforms.mac.toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirement is to collect coverage only on gcc/Linux, so maybe mac, armv8, and armv7 can be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lebdron according to the requirements, this file is not needed anymore. It's removed in the next commit
.jenkinsci/debug-build.groovy
Outdated
} | ||
def iC = docker.image("${DOCKER_AGENT_IMAGE}") | ||
iC.inside() { | ||
def step = load ".jenkinsci/mac-debug-build.groovy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for coverage, I don't think any other platform besides gcc/Linux is required.
.jenkinsci/enums.groovy
Outdated
|
||
// list of agent labels (build platforms) to count coverage (the choice depends on the build parameters) | ||
enum CoveragePlatforms { | ||
x86_64_aws_cov, mac, armv8, armv7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for coverage, just leave x86_64_aws_cov
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lebdron removed. good point
.jenkinsci/mac-debug-build.groovy
Outdated
@@ -0,0 +1,70 @@ | |||
def doDebugBuild(coverageEnabled=false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flag should not be required ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lebdron also fixed in the next commit
.jenkinsci/mac-debug-build.groovy
Outdated
} | ||
|
||
def doPostCoverageSonarStep() { | ||
sh "cmake --build build --target cppcheck" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for cppcheck, the code analysis output should be the same if sent from mac os or Linux, so it should be only run in gcc/Linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All methods related to coverage are removed from the mac-debug-build.groovy
file.
Jenkinsfile
Outdated
booleanParam(defaultValue: false, description: '', name: 'ARMv7'), | ||
booleanParam(defaultValue: false, description: '', name: 'ARMv8'), | ||
booleanParam(defaultValue: false, description: '', name: 'MacOS'), | ||
booleanParam(defaultValue: false, description: 'Whether it is a triggered build', name: 'Nightly'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove "whether" from titles, because the switches themselves imply this word, so it does not add any information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
Jenkinsfile
Outdated
if ( params.BUILD_TYPE == 'Debug' || params.Merge_PR ) { | ||
def debugBuild = load ".jenkinsci/debug-build.groovy" | ||
def coverage = load ".jenkinsci/selected-branches-coverage.groovy" | ||
debugBuild.doDebugBuild( (!params.Linux && !params.MacOS || !params.Merge_PR) ? coverage.selectedBranchesCoverage() : false ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conditional could be removed because of reasons above, same for calls for mac
, armv7
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, now we can get rid of these complex conditions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GBTPR (God bless this PR)
.jenkinsci/docker-cleanup.groovy
Outdated
""" | ||
// cleanup docker images which weren't used for more that 20 days and image for this PR in case of successful PR | ||
def doStaleDockerImagesCleanup() { | ||
sh "find ${JENKINS_DOCKER_IMAGE_DIR} -type f -mtime +20 -exec rm -f {}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails with an error on Ubuntu 16.04. Did you check this really works? I think it should end with \;
after curly braces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bakhtin Thanks for the report, I've missed \;
. I've just checked it on the real files (AWS EFS) and it WORKS!
agent { label 'master' } | ||
steps { | ||
script { | ||
load ".jenkinsci/enums.groovy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Output of load
is not used, consider removing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lebdron no, this is required to load static variable of enum. Output shouldn't be used here
Jenkinsfile
Outdated
expression { return params.armv7_linux } | ||
anyOf { | ||
expression { return params.ARMv7 } | ||
// allOf { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a TODO to fix issues and uncomment, with Jira task id. Same for ARMv8 below.
Jenkinsfile
Outdated
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 | ||
if ( params.BUILD_TYPE == 'Debug' || params.Merge_PR ) { | ||
def macDebugBuild = load ".jenkinsci/mac-debug-build.groovy" | ||
def coverage = load ".jenkinsci/selected-branches-coverage.groovy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coverage
is unused, please remove.
.jenkinsci/linux-post-step.groovy
Outdated
} | ||
|
||
// upload artifacts in release builds (for mac) | ||
def macPostStep() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File name is confusing (linux, but also contains mac methods), maybe rename the file or move the methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lebdron I've fixed the filename
Jenkinsfile
Outdated
} | ||
finally { | ||
sh "rm -rf /tmp/${env.GIT_COMMIT}" | ||
// cleanWs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove if it is not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lebdron it was commented out by an accident
if (PRCoverage) { | ||
return env.GIT_LOCAL_BRANCH in branches || env.CHANGE_ID != null | ||
def pCommit = load ".jenkinsci/previous-commit.groovy" | ||
def prevCommit = pCommit.previousCommitOrCurrent() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PREVIOUS_COMMIT
environment variable defined in Jenkinsfile can be used intstead.
Jenkinsfile
Outdated
else { | ||
if ( params.BUILD_TYPE == 'Debug' || params.Merge_PR ) { | ||
def debugBuild = load ".jenkinsci/debug-build.groovy" | ||
def coverage = load ".jenkinsci/selected-branches-coverage.groovy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove because it is unused.
Jenkinsfile
Outdated
expression { return !env.GIT_PREVIOUS_COMMIT } | ||
} | ||
allOf { | ||
expression { return env.CHANGE_ID != null } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussion with @tyvision we decided to move these complex conditions to separate variables as SOME_VAR = [[ env.CHANGE_ID != null && env.CHANGE_TARGET ==~ /(master|develop|trunk)/ ]]
, and then use them here. These variables will have documentation where they are defined, and the logic will not be duplicated in different stages.
05c1810
to
d4a43e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very scared about this PR, but I don't have critical issues. I hope we will not revert this pr in develop branch.
if (!defaultParameter) { | ||
return 4 | ||
} | ||
if (env.NODE_NAME.contains('arm7')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like here is possible to use the enum with machine types
// return tests list regex that will be launched by ctest | ||
def chooseTestType() { | ||
if (params.merge_pr) { | ||
if (env.NODE_NAME.contains('x86_64')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same about enums
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muratovv My concern is to leave this update for the next PR on CI (not as major as this one)
expression { return params.armv7_linux } | ||
anyOf { | ||
expression { return params.armv7_linux } | ||
// expression { return MERGE_CONDITIONS_SATISFIED == "true" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is disabled because current armv7 builds fail due to insufficient memory. Builds should be possible with cross-compilation, so this can serve as a reminder.
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
e4acb38
to
ffdf15c
Compare
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: Anatoly <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: tyvision <[email protected]>
Signed-off-by: Anatoly <[email protected]>
Signed-off-by: tyvision <[email protected]>
Description of the Change
This PR is created to finally make our CI satisfy proposed requirements by our developers team.
1 Major changes
1.1 Pipeline stages
Since now, the Pipeline consists of 6 stages. You can see the ascii-art pipeline version in the
Jenkinsfile
develop
)ARMv7
,ARMv8
,x86_64
,MacOS
are present)iroha
This division is made to improve visibility of the CI build process.
Stage separation is implemented in Jenkinsfile. All stage methods are implemented in
.jenkinsci/debug-build.groovy
,.jenkinsci/release-build.groovy
,.jenkinsci/mac-debug-build.groovy
,.jenkinsci/mac-release-build.groovy
(note thatMacOS
build goes on the physical machine, not in the docker container, that's why there's another file forMacOS
platform)1.2 On-demand Jenkins agents
Since now
x86_64
agents are moved to AWS EC2. There are 4 different labels added to the pipeline (note that it could be easily modified in Jenkins configuration):x86_64_aws_build
-- general purpose instance with 8 CPU, 32 Gb RAM (x86_64 builds in 8 threads)x86_64_aws_test
-- general purpose instance with 1 CPU, 2 Gb RAM for running testsx86_64_aws_cov
-- general purpose instance with 1 CPU, 2 Gb RAM for running coveragex86_64_aws_sonar
-- general purpose instance with 1 CPU, 2 Gb RAM for runningsonarscanner
Now, the amount of
x86_64
agents will be float, as their amount is managed by Jenkins.On-demand agent start-up process
Before freshly created and launched new AWS instance becomes the Jenkins agent, init script is executed. It mounts 4 folders via NFS share (AWS EFS - Amazon Elastic Filesystem).
/var/jenkins
)cmake
build cache (/opt/.ccache
)cmake
release build cache (/opt/.ccache-release
)/tmp/docker
)On-demand agent pipeline lifecycle
In case the build occures on the
x86_64*
agent, the created docker image (stageBuild
) is saved to AWS EFS (Amazon Elastic Filesystem) usingdocker save -o
command with file name/tmp/docker/<branch_name_sha1>
. (see file.jenkinsci/docker-pull-or-build.groovy
, methoddockerPullOrUpdate()
). When going to the next stage, newx86_64*
agent is created, docker image is loaded from the file/tmp/docker/<branch_name_sha1>
usingdocker load
command.After the stage finishes, the docker container is stopped and removed, results are saved to the Jenkins workspace (and to the AWS EFS respectively), thus, none of the data is lost.
1.3 Merge availability
To make CI available to perform automatic merge process the list of features should be implemented:
Merge requirements set in
hyperledger/iroha
repository:APPROVED
reviewsarmv7
,armv8
are turned off in case ofMergePR
is chosen)sign-off
Merge strategy regarding the branches:
trunk
+develop
--squash & merge
master
-- mergeAll checks are made using Github API. To see the implementation, go to
.jenkinsci/github-api.groovy
file.1.4 CI notifications
Build result notifications were added. Table below describes the notification scenario:
trunk
develop
master
Notification e-mail contains compressed log in attachmens + build status.
see
.jenkinsci/notifications.groovy
,Jenkinsfile
(cleanup post-step at the end of the file)1.5 Tests launch separation
This feature is implemented as a method that returns regex string (file
.jenkinsci/test-launcher.groovy
)This method is called in the
Jenkinsfile
stageTests
and its return string is passed as a parameter to thedoTestStep()
method. More detailed description of test types execution according to the build strategy is provided in the next section (1.6)1.6 Default order of execution
Table contains requirements for order of pipeline execution.
module
testsx86_64 gcc-5.4
,MacOS
buildx86_64
module
x86_64 gcc-5.4
module
trunk
module
for all platforms. forx86_64 gcc-5.4
runintegration
,system
,cmake
,regression
testsdevelop
module
for all platforms. forx86_64 gcc-5.4
runintegration
,system
,cmake
,regression
testsmaster
x86_64 gcc-5.4
module
for all platforms. forx86_64 gcc-5.4
runintegration
,system
,cmake
,regression
testsx86_64 gcc-5.4
integration
,system
,cmake
,regression
tests. forx86_64 gcc-5.4
run all tests*.deb
,*.tar
2 Minor changes
--output-on-failure
flag onMacOS
tests.linuxPostStep()
method fromjenkinsci/linux-post-step.groovy
intopostStep()
andcleanUp()
methods.postStep()
method is authoritative for uploading artifacts after release build, whencleanUp()
removes folders created during buildsdoDockerCleanup()
. Now this method been called only from the pipeline's cleanup post-step, atarmv7
,armv8
agents.Benefits
Usage Examples or Tests [optional]