Automated tests with bbi_daily¶
BBI stands for BrainVISA Build Infrastructure. The casa_distro_admin
bbi_daily
command orchestrates this process in a given BBE (BrainVISA Build
Environment, a directory that serves as a base directory for casa-distro).
The bbi_daily
command will run the following main steps, while (optionally)
logging detailed output to a Jenkins server:
- Self-update casa_distro with
git pull
; - Update the
casa-run
andcasa-dev
images from the BrainVISA website; - Run a compilation in a dev environment (
bv_maker sources
,bv_maker configure
,bv_maker build
,bv_maker doc
); - Run all tests that would be run by
bv_maker test
in the dev environment; - Install the compiled software in a new user image based on the
casa-run
image (the software is installed under/casa/install
); - Run the tests in the user image.
Walkthrough¶
Here is a detailed log of how nightly builds are set up in NeuroSpin. You can take inspiration from it to create your own personalized set-up.
Install
singularity
. Configure the fakeroot functionality of Singularity, as explained in the Singularity Admin Guide. In short, you need admin rights on your machine, and you have to run:sudo singularity config fakeroot --add $USER
(with
$USER
beinga-sac-ns-brainvisa
in this case).Create a directory dedicated to the nightly builds and change to it:
export CASA_BASE_DIRECTORY=/volatile/a-sac-ns-brainvisa/bbi_nightly mkdir "$CASA_BASE_DIRECTORY" cd "$CASA_BASE_DIRECTORY"
This directory will be the base directory for your BrainVISA Build Environment (BBE).
Create the
jenkins_auth
file in the BBE base directory. This text file must consist of two lines: the first line contains the username on the Jenkins server, the second line contains the token that can be generated in the Jenkins web interface (click on the user on top right corner, select Configure and create a new API token). This token will be used instead of the account password to upload build results. One advantage of using a token is the possibility to revoke it at any time. It is recommended to use one token per BrainVISA Build Environment and name the token accordingly.warning: You should make this file non-readable by others, e.g. create it with:
chmod 0600 jenkins_auth
Download the
casa-dev
image using the link found on the Downloads page of <https://brainvisa.info/>. Also download the associated JSON file (to be extra safe, check that the md5sum of the image matches that stored in the JSON file). Do the same for thecasa-run
image (it may not appear on the Downloads page, just replace-dev-
by-run-
in the URL of the dev image):wget https://brainvisa.info/download/casa-dev-5.0.sif wget https://brainvisa.info/download/casa-dev-5.0.sif.json md5sum casa-dev-5.0.sif wget https://brainvisa.info/download/casa-run-5.0.sif wget https://brainvisa.info/download/casa-run-5.0.sif.json md5sum casa-run-5.0.sif
Create a directory for your development environment and set it up:
cd "$CASA_BASE_DIRECTORY" mkdir brainvisa-master-5.0 singularity run --bind ./brainvisa-master-5.0:/casa/setup \ casa-dev-5.0.sif distro=brainvisa branch=master
Edit the
conf/svn.secret
file with your BioProj login and password.Check out and compile an initial build:
"$CASA_BASE_DIRECTORY"/brainvisa-master-5.0/bin/bv_maker
Create an inital user image. You may need to set the
SINGULARITY_TMPDIR
environment variable to a disk with enough free space (about twice the size of the final user image):export SINGULARITY_TMPDIR=/volatile/tmp "$CASA_BASE_DIRECTORY"/brainvisa-master-5.0/bin/casa_distro_admin \ create_user_image \ version=nightly \ environment_name=brainvisa-master-5.0 \ name=brainvisa-master-5.0-userimage
environment_name
is the name of the development environment.name
is the full name of the created user image. We change it from the default, because we need it to be fully explicit: this name will be the name of the build on the Jenkins page.
Install the environment for your new user image:
cd "$CASA_BASE_DIRECTORY" mkdir brainvisa-master-5.0-userimage singularity run --bind ./brainvisa-master-5.0-userimage:/casa/setup \ brainvisa-master-5.0-userimage.sif
Add the
branch
andimage_version
keys to theconf/casa_distro.json
of the user environment: these variables are not set by setup_user, but they are necessary forbbi_daily
to make the correct link between the environment of the user image and the corresponding dev environment.note: Issue #246 tracks progress on that issue, this workaround will become obsolete once that issue is fixed. Put the reference test data in place. Best is to copy it from a known-good source. Beware that it must be copied in both environments:
"$CASA_BASE_DIRECTORY"/brainvisa-master-5.0/tests/ref/
"$CASA_BASE_DIRECTORY"/brainvisa-master-5.0-userimage/tests/ref/
Check that the whole
bbi_daily
process is able to run successfully:"$CASA_BASE_DIRECTORY"/brainvisa-master-5.0/bin/casa_distro_admin \ bbi_daily
Beware that the output of each step is displayed only when that step is finished, so the command may seem to hang for a long time.
Set the
bbi_daily
command to run on a regular basis usingcrontab -e
:MAILTO=your.email@host.example 37 5 * * * PATH=/usr/local/bin:/usr/bin:/bin CASA_BASE_DIRECTORY=/volatile/a-sac-ns-brainvisa/bbi_nightly SINGULARITY_TMPDIR=/volatile/tmp /volatile/a-sac-ns-brainvisa/bbi_nightly/brainvisa-master-5.0/bin/casa_distro_admin bbi_daily jenkins_server='https://brainvisa.info/builds'
note: Remember to set all the needed environment variables, including BRAINVISA_PUBLISH_SERVER
if needed.PATH
may need to be set additionally, in case your Singularity installation is under/usr/local
(by default cron limitsPATH
to/usr/bin:/bin
).