2022-10-03 11:23:42 +00:00
|
|
|
library 'status-jenkins-lib@v1.6.0'
|
2021-06-24 08:20:50 +00:00
|
|
|
|
|
|
|
pipeline {
|
2022-01-17 16:35:01 +00:00
|
|
|
agent { label "${getAgentLabel()} && x86_64" }
|
2021-06-24 08:20:50 +00:00
|
|
|
|
|
|
|
parameters {
|
|
|
|
string(
|
2022-05-17 19:11:07 +00:00
|
|
|
name: 'NIMFLAGS',
|
2021-06-24 08:20:50 +00:00
|
|
|
description: 'Flags for Nim compilation.',
|
2022-07-22 11:45:47 +00:00
|
|
|
defaultValue: params.NIMFLAGS ?: [
|
|
|
|
'--colors:off',
|
|
|
|
'-d:insecure',
|
|
|
|
'-d:disableMarchNative',
|
|
|
|
'--parallelBuild:6',
|
2023-09-26 08:11:38 +00:00
|
|
|
'-d:postgres',
|
2022-07-22 11:45:47 +00:00
|
|
|
].join(' ')
|
2021-06-24 08:20:50 +00:00
|
|
|
)
|
|
|
|
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()
|
2022-06-08 11:48:30 +00:00
|
|
|
/* Prevent Jenkins jobs from running forever */
|
|
|
|
timeout(time: 30, unit: 'MINUTES')
|
|
|
|
/* Limit builds retained. */
|
2021-06-24 08:20:50 +00:00
|
|
|
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. */
|
|
|
|
v2changed = versionWasChanged('v2')
|
2022-04-19 10:51:27 +00:00
|
|
|
/* TODO: Re-add caching of Nim compiler. */
|
2022-10-25 14:58:52 +00:00
|
|
|
nix.shell("make ${params.MAKEFLAGS} V=${params.VERBOSITY} update", pure: false)
|
|
|
|
nix.shell("make ${params.MAKEFLAGS} V=${params.VERBOSITY} deps", pure: false)
|
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('V2') {
|
|
|
|
when { expression { v2changed } }
|
2022-10-03 11:23:42 +00:00
|
|
|
steps { script {
|
2023-09-11 06:32:31 +00:00
|
|
|
nix.shell("make ${params.MAKEFLAGS} NIMFLAGS=\"${params.NIMFLAGS}\" V=${params.VERBOSITY} all")
|
2022-10-03 11:23:42 +00:00
|
|
|
} }
|
2021-07-01 10:40:05 +00:00
|
|
|
}
|
2021-06-24 08:20:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Run Tests') {
|
|
|
|
parallel {
|
2021-07-01 10:40:05 +00:00
|
|
|
stage('V2') {
|
|
|
|
when { expression { v2changed } }
|
2022-10-03 11:23:42 +00:00
|
|
|
steps { script {
|
2023-09-11 06:32:31 +00:00
|
|
|
nix.shell("make ${params.MAKEFLAGS} NIMFLAGS=\"${params.NIMFLAGS}\" V=${params.VERBOSITY} test")
|
2022-10-03 11:23:42 +00:00
|
|
|
} }
|
2021-07-01 10:40:05 +00:00
|
|
|
}
|
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
|
|
|
|
)
|
2022-10-04 10:59:08 +00:00
|
|
|
if (changes =~ "(?m)^(Makefile|waku.nimble|config.nims|vendor|ci|shell.nix).*") {
|
2021-07-01 10:40:05 +00:00
|
|
|
return true
|
|
|
|
}
|
2022-10-20 16:44:22 +00:00
|
|
|
if (version == 'v2' && changes =~ "(?m)^(apps|tools)/.*") {
|
|
|
|
return true
|
|
|
|
}
|
2021-07-01 10:40:05 +00:00
|
|
|
if (changes =~ "(?m)^(waku|tests|examples)/(${version}|common)/.*") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|