Skip to content
Snippets Groups Projects
Commit eb9fdb60 authored by Yannik Stradmann's avatar Yannik Stradmann Committed by Yannik Stradmann
Browse files

Add Jenkinsfile for CI on DLSv{2,3}

Change-Id: I71c285a1284f19e04d40f2ad19eec92b18069c28
parent a1b1ce9b
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env groovy
node {
try {
cleanWs()
stage('checkout') {
dir('libnux') {
checkout scm // for CI files
}
try {
run_with_modules("waf setup " +
"--project libnux " +
"--project hicann-dls-scripts " +
"--clone-depth 1 " +
"--gerrit-changes=${GERRIT_CHANGE_NUMBER} " +
"--gerrit-url=ssh://hudson@$GERRIT_HOST:$GERRIT_PORT" as String)
GERRIT_BUILD = true
} catch (MissingPropertyException ignored) { // Jenkinsfile not called via Gerrit
run_with_modules("waf setup " +
"--project libnux " +
"--project hicann-dls-scripts " +
"--clone-depth 1 " as String)
GERRIT_BUILD = false
}
}
stage("Build") {
srun_jenkins("waf configure install --test-execnone")
}
stage("Hardware Tests") {
run_ppu_tests("07", ".*/test_.*\\.binary")
}
} catch (Exception e) {
post_error_build_action()
throw e as java.lang.Throwable
} finally {
post_all_build_action()
}
// Some Jenkins steps fail a build without raising (e.g. archiveArtifacts)
if (currentBuild.currentResult != "SUCCESS") {
post_error_build_action()
}
}
/*
/* HELPER FUNCTIONS
*/
void run_with_modules(String command) {
sh "module purge && " +
"module load spack_visionary-defaults/autobuild && " +
"module load waf && " +
"module load gcc-nux && " +
"module load frickel-dls/current && ${command}"
}
void srun_jenkins(String command) {
run_with_modules("srun -p jenkins -c 8 --mem 15G ${command}" as String)
}
void run_with_board_allocation(String board_id, String command) {
run_with_modules("echo \"${command}\" | salloc -p dls --gres=${board_id}" as String)
}
void run_ppu_tests(String board_id, String regex) {
run_with_board_allocation(board_id,
"find firmware -regex \"${regex}\" -print0 | xargs -n 1 -0 srun python hicann-dls-scripts/run_program.py --as_string" as String
)
}
void post_all_build_action() {
// Scan for compiler warnings
warnings canComputeNew: false,
canRunOnFailed: true,
categoriesPattern: '',
consoleParsers: [[parserName: 'GNU C Compiler 4 (gcc)']],
defaultEncoding: '',
excludePattern: '',
healthy: '',
includePattern: '',
messagesPattern: '',
unHealthy: '',
unstableTotalAll: '0',
unstableTotalHigh: '0',
unstableTotalLow: '0',
unstableTotalNormal: '0'
// Always clean the workspace
cleanWs()
}
void post_error_build_action() {
if (!GERRIT_BUILD) {
mattermostSend(channel: "#dls-software",
text: "@channel Jenkins build `${env.JOB_NAME}` has failed!",
message: "${env.BUILD_URL}",
endpoint: "https://brainscales-r.kip.uni-heidelberg.de:6443/hooks/qrn4j3tx8jfe3dio6esut65tpr")
}
}
#!/usr/bin/env groovy
node {
try {
cleanWs()
stage('checkout') {
dir('libnux') {
checkout scm // for CI files
}
try {
run_with_modules("waf setup " +
"--project libnux " +
"--project hicann-dls-scripts@v3testing " +
"--clone-depth 1 " +
"--gerrit-changes=${GERRIT_CHANGE_NUMBER} " +
"--gerrit-url=ssh://hudson@$GERRIT_HOST:$GERRIT_PORT" as String)
GERRIT_BUILD = true
} catch (MissingPropertyException ignored) { // Jenkinsfile not called via Gerrit
run_with_modules("waf setup " +
"--project libnux " +
"--project hicann-dls-scripts@v3testing " +
"--clone-depth 1 " as String)
GERRIT_BUILD = false
}
}
stage("Build") {
srun_jenkins("waf configure install --test-execnone")
}
withEnv([
'HW_TESTBOARD_ID=B291673',
'HW_TESTBOARD_SOCKET=3']) { // Switchable socket the setup is plugged into
stage("Hardware Tests") {
run_ppu_tests(".*/test_.*\\.binary")
}
}
} catch (Exception e) {
post_error_build_action()
throw e as java.lang.Throwable
} finally {
post_all_build_action()
}
// Some Jenkins steps fail a build without raising (e.g. archiveArtifacts)
if (currentBuild.currentResult != "SUCCESS") {
post_error_build_action()
}
}
/*
/* HELPER FUNCTIONS
*/
void run_with_modules(String command) {
sh "module purge && " +
"module load spack_visionary-defaults/autobuild && " +
"module load waf && " +
"module load gcc-nux && " +
"module load frickel-dls_v3testing/current && ${command}"
}
void srun_jenkins(String command) {
run_with_modules("srun -p jenkins -c 8 --mem 15G ${command}" as String)
}
void run_with_board_allocation(String command) {
run_with_modules("echo \"${command}\" | salloc -p dls --gres=${HW_TESTBOARD_ID}" as String)
}
static String powercycle_fpga_command(String ip, int socket_number) {
return "curl 'http://${ip}/login.html' --data 'pw=spikey' && " + // login
"curl 'http://${ip}/' --data 'cte${socket_number}=0' && " + // disable socket
"sleep 5 && " + // wait
"curl 'http://${ip}/' --data 'cte${socket_number}=1' && " + // enable socket
"curl 'http://${ip}/login.html' && " + // logout
"sleep 5" // FPGA powerup
}
void run_ppu_tests(String regex) {
run_with_board_allocation(
powercycle_fpga_command("129.206.176.148", "${HW_TESTBOARD_SOCKET}" as int) \
+ " && " \
+ "srun bash ./hicann-dls-scripts/helper/pll_config_bypass.sh" \
+ " && " \
+ "find firmware -regex \"${regex}\" -print0 | xargs -n 1 -0 srun python hicann-dls-scripts/run_program.py --as_string" as String)
}
void post_all_build_action() {
// Scan for compiler warnings
warnings canComputeNew: false,
canRunOnFailed: true,
categoriesPattern: '',
consoleParsers: [[parserName: 'GNU C Compiler 4 (gcc)']],
defaultEncoding: '',
excludePattern: '',
healthy: '',
includePattern: '',
messagesPattern: '',
unHealthy: '',
unstableTotalAll: '0',
unstableTotalHigh: '0',
unstableTotalLow: '0',
unstableTotalNormal: '0'
// Always clean the workspace
cleanWs()
}
void post_error_build_action() {
if (!GERRIT_BUILD) {
mattermostSend(channel: "#dls-software",
text: "@channel Jenkins build `${env.JOB_NAME}` has failed!",
message: "${env.BUILD_URL}",
endpoint: "https://brainscales-r.kip.uni-heidelberg.de:6443/hooks/qrn4j3tx8jfe3dio6esut65tpr")
}
}
......@@ -69,7 +69,7 @@ def build(bld):
bld.program(
features = 'c objcopy',
objcopy_bfdname = 'binary',
target = 'test_returncode.bin',
target = 'failing_test_returncode.bin',
source = ['test/test_returncode.c'],
use = ['nux', 'nux_runtime'],
env = bld.all_envs['nux'],
......@@ -78,7 +78,7 @@ def build(bld):
bld.program(
features = 'c objcopy',
objcopy_bfdname = 'binary',
target = 'test_unittest.bin',
target = 'failing_test_unittest.bin',
source = ['test/test_unittest.c'],
use = ['nux', 'nux_runtime'],
env = bld.all_envs['nux'],
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment