nimbus-eth2/ci/Jenkinsfile

141 lines
3.5 KiB
Groovy

pipeline {
/* This way we run the same Jenkinsfile on different platforms. */
agent { label params.AGENT_LABEL }
parameters {
string(
name: 'AGENT_LABEL',
description: 'Label for targetted CI slave host: linux/macos',
defaultValue: params.AGENT_LABEL ?: getAgentLabel(),
)
}
options {
timestamps()
ansiColor('xterm')
/* This also includes wait time in the queue. */
timeout(time: 24, unit: 'HOURS')
/* Limit builds retained. */
buildDiscarder(logRotator(
numToKeepStr: '5',
daysToKeepStr: '30',
artifactNumToKeepStr: '3',
))
/* Throttle number of concurrent builds. */
throttleJobProperty(
throttleEnabled: true,
throttleOption: 'category',
categories: ['nimbus-eth2'],
maxConcurrentPerNode: 1,
maxConcurrentTotal: 6
)
/* Abort old builds for non-main branches. */
disableConcurrentBuilds(
abortPrevious: !isMainBranch()
)
}
environment {
NPROC = Runtime.getRuntime().availableProcessors()
MAKEFLAGS = "-j${env.NPROC}"
}
stages {
stage('Deps') {
steps { timeout(20) {
/* To allow the following parallel stages. */
sh 'make QUICK_AND_DIRTY_COMPILER=1 update'
/* Allow the following parallel stages. */
sh 'make deps'
/* Download test vectors. */
sh './scripts/setup_scenarios.sh'
} }
}
stage('Build') {
steps { timeout(40) {
sh 'make LOG_LEVEL=TRACE'
} }
}
stage('Tests') {
parallel {
stage('General') {
steps { timeout(60) {
sh 'make DISABLE_TEST_FIXTURES_SCRIPT=1 test'
} }
}
stage('REST') {
steps { timeout(5) {
sh 'make restapi-test'
} }
}
}
}
stage('Finalizations') {
stages { /* parallel builds of minimal / mainnet not yet supported */
stage('minimal') {
steps { script { timeout(26) {
launchLocalTestnet('minimal')
} } }
}
stage('mainnet') {
steps { script { timeout(62) {
launchLocalTestnet('mainnet')
} } }
}
}
}
stage('Upload') {
steps { timeout(5) {
archiveArtifacts('*.tar.gz')
} }
}
}
post {
always {
cleanWs(
disableDeferredWipeout: true,
deleteDirs: true
)
}
}
}
def launchLocalTestnet(String name) {
/* We want to mark job as failed, but save the results. */
catchError(
message: "Local ${name} testnet finalization failure!",
buildResult: 'FAILURE',
stageResult: 'FAILURE'
) {
sh "make local-testnet-${name}"
}
/* Archive test results regardless of outcome. */
sh "tar cjf local-testnet-${name}.tar.gz local-testnet-${name}/*.txt"
}
def isMainBranch() {
return ['stable', 'testing', 'unstable'].contains(env.BRANCH_NAME)
}
/* 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 }
/* We extract the name of the job from currentThread because
* before an agent is picket env is not available. */
def tokens = Thread.currentThread().getName().split('/')
def labels = []
/* Check if the job path contains any of the valid labels. */
['linux', 'macos', 'x86_64', 'aarch64', 'arm64'].each {
if (tokens.contains(it)) { labels.add(it) }
}
return labels.join(' && ')
}