2021-06-24 08:20:50 +00:00
|
|
|
library 'status-jenkins-lib@v1.2.18'
|
|
|
|
|
|
|
|
pipeline {
|
2022-01-17 16:35:01 +00:00
|
|
|
agent { label "${getAgentLabel()} && x86_64" }
|
2021-06-24 08:20:50 +00:00
|
|
|
|
|
|
|
parameters {
|
|
|
|
string(
|
|
|
|
name: 'NIM_PARAMS',
|
|
|
|
description: 'Flags for Nim compilation.',
|
|
|
|
defaultValue: params.NIM_PARAMS ?: '-d:disableMarchNative -d:insecure --parallelBuild:6'
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'LOG_LEVEL',
|
|
|
|
description: 'Build logging level. (DEBUG, TRACE)',
|
|
|
|
defaultValue: params.LOG_LEVEL ?: 'DEBUG'
|
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'VERBOSITY',
|
|
|
|
description: 'Makefile verbosity level.(0-2)',
|
2021-11-25 16:01:45 +00:00
|
|
|
defaultValue: params.VERBOSITY ?: '1'
|
2021-06-24 08:20:50 +00:00
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'MAKEFLAGS',
|
|
|
|
description: 'Makefile flags.',
|
|
|
|
defaultValue: params.MAKEFLAGS ?: '-j6'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
timestamps()
|
|
|
|
/* manage how many builds we keep */
|
|
|
|
buildDiscarder(logRotator(
|
|
|
|
numToKeepStr: '3',
|
|
|
|
daysToKeepStr: '30',
|
|
|
|
artifactNumToKeepStr: '1',
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
|
|
|
TARGET = getAgentLabel()
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
2021-07-01 10:40:05 +00:00
|
|
|
stage('Deps') { steps { script {
|
|
|
|
/* Avoid checking multiple times. */
|
|
|
|
v1changed = versionWasChanged('v1')
|
|
|
|
v2changed = versionWasChanged('v2')
|
2022-04-19 10:51:27 +00:00
|
|
|
/* TODO: Re-add caching of Nim compiler. */
|
|
|
|
sh "make V=${params.VERBOSITY} update"
|
2021-06-24 08:20:50 +00:00
|
|
|
sh "make V=${params.VERBOSITY} deps"
|
2021-07-01 10:40:05 +00:00
|
|
|
} } }
|
2021-06-24 08:20:50 +00:00
|
|
|
|
|
|
|
stage('Binaries') {
|
|
|
|
parallel {
|
2021-07-01 10:40:05 +00:00
|
|
|
stage('V1') {
|
|
|
|
when { expression { v1changed } }
|
|
|
|
steps { sh "make V=${params.VERBOSITY} v1" }
|
|
|
|
}
|
|
|
|
stage('V2') {
|
|
|
|
when { expression { v2changed } }
|
|
|
|
steps { sh "make V=${params.VERBOSITY} v2" }
|
|
|
|
}
|
2021-06-24 08:20:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Run Tests') {
|
|
|
|
parallel {
|
2021-07-01 10:40:05 +00:00
|
|
|
stage('V1') {
|
|
|
|
when { expression { v1changed } }
|
|
|
|
steps { sh "make V=${params.VERBOSITY} test1" }
|
|
|
|
}
|
|
|
|
stage('V2') {
|
|
|
|
when { expression { v2changed } }
|
|
|
|
steps { sh "make V=${params.VERBOSITY} test2" }
|
|
|
|
}
|
2021-06-24 08:20:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-01 10:40:05 +00:00
|
|
|
stage('Upload') {
|
|
|
|
when { expression { v2changed } }
|
|
|
|
steps { script {
|
|
|
|
def out = genOutputFilename()
|
|
|
|
sh "mv build/wakunode2 ${out}"
|
|
|
|
env.PKG_URL = s3.uploadArtifact(out)
|
|
|
|
jenkins.setBuildDesc(Waku: env.PKG_URL)
|
|
|
|
} }
|
|
|
|
}
|
2021-06-24 08:20:50 +00:00
|
|
|
} // stages
|
|
|
|
post {
|
|
|
|
success { script { github.notifyPR(true) } }
|
|
|
|
failure { script { github.notifyPR(false) } }
|
2021-06-30 14:01:58 +00:00
|
|
|
always { cleanWs() }
|
2021-06-24 08:20:50 +00:00
|
|
|
} // post
|
|
|
|
} // pipeline
|
|
|
|
|
|
|
|
|
|
|
|
/* This allows us to use one Jenkinsfile and run
|
|
|
|
* jobs on different platforms based on job name. */
|
|
|
|
def getAgentLabel() {
|
|
|
|
if (params.AGENT_LABEL) {
|
|
|
|
return params.AGENT_LABEL
|
|
|
|
}
|
|
|
|
def tokens = env.JOB_NAME.split('/')
|
|
|
|
for (platform in ['linux', 'macos', 'windows']) {
|
|
|
|
if (tokens.contains(platform)) { return platform }
|
|
|
|
}
|
|
|
|
throw new Exception('No agent provided or found in job path!')
|
|
|
|
}
|
|
|
|
|
|
|
|
def genOutputFilename() {
|
|
|
|
return [
|
|
|
|
"wakunode2", utils.timestamp(), utils.gitCommit(), getAgentLabel()
|
|
|
|
].join('-') + (env.NODE_NAME.startsWith('windows') ? '.exe' : '.bin')
|
|
|
|
}
|
2021-07-01 10:40:05 +00:00
|
|
|
|
|
|
|
def versionWasChanged(version) {
|
|
|
|
def changes = sh(
|
|
|
|
script: "git diff --name-only origin/${env.CHANGE_TARGET}",
|
|
|
|
returnStdout: true
|
|
|
|
)
|
|
|
|
if (changes =~ "(?m)^(Makefile|waku.nimble|config.nims|vendor).*") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if (changes =~ "(?m)^(waku|tests|examples)/(${version}|common)/.*") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|