Skip to content

WIP: Continuous integration of Slicer on centos (updated & rebased) #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Applications/SlicerApp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ slicerMacroBuildAppLibrary(
NAME ${APPLIB_NAME}
APPLICATION_NAME ${SlicerApp_APPLICATION_NAME}
DESCRIPTION_SUMMARY ${APPLIB_DESCRIPTION_SUMMARY}
DESCRIPTION_FILE ${Slicer_SOURCE_DIR}/README.txt
DESCRIPTION_FILE ${Slicer_SOURCE_DIR}/README.rst
EXPORT_DIRECTIVE "Q_SLICER_APP_EXPORT"
FOLDER ${${PROJECT_NAME}_FOLDER}
SRCS ${APPLIB_SRCS}
Expand Down
16 changes: 16 additions & 0 deletions CMake/CircleCI/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

script_dir="`cd $(dirname $0); pwd`"

# Run the images which contains the build of slicer (to link with the testing image with mounted volume)
docker run -d --name slicer-build-with-test slicer/slicer-test bash

# Run the opengl docker image which will run the tests located on the volume shared by slicer/slicer-build
$script_dir/run_opengl.sh \
-i slicer/slicer-test:opengl \
-p 6081 \
-r --env="CIRCLE_SHA1=$1" -r --env="CIRCLE_BRANCH=$2" \
-r --volumes-from -r slicer-build-with-test

# Remove the container used to mount volumes from slicer-build
#docker rm slicer-build-with-test
157 changes: 157 additions & 0 deletions CMake/CircleCI/run_opengl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#!/bin/bash

container=opengl
image=slicer/slicer-test:opengl
port=6080
extra_run_args=""
quiet=""

show_help() {
cat << EOF
Usage: ${0##*/} [-h] [-q] [-c CONTAINER] [-i IMAGE] [-p PORT] [-r DOCKER_RUN_FLAGS]

This script is a convenience script to run Docker images based on
thewtex/opengl. It:

- Makes sure docker is available
- On Windows and Mac OSX, creates a docker machine if required
- Informs the user of the URL to access the container with a web browser
- Stops and removes containers from previous runs to avoid conflicts
- Mounts the present working directory to /home/user/work on Linux and Mac OSX
- Prints out the graphical app output log following execution
- Exits with the same return code as the graphical app

Options:

-h Display this help and exit.
-c Container name to use (default ${container}).
-i Image name (default ${image}).
-p Port to expose HTTP server (default ${port}). If an empty
string, the port is not exposed.
-r Extra arguments to pass to 'docker run'. E.g.
--env="APP=glxgears"
-q Do not output informational messages.
EOF
}

while [ $# -gt 0 ]; do
case "$1" in
-h)
show_help
exit 0
;;
-c)
container=$2
shift
;;
-i)
image=$2
shift
;;
-p)
port=$2
shift
;;
-r)
extra_run_args="$extra_run_args $2"
shift
;;
-q)
quiet=1
;;
*)
show_help >&2
exit 1
;;
esac
shift
done


which docker 2>&1 >/dev/null
if [ $? -ne 0 ]; then
echo "Error: the 'docker' command was not found. Please install docker."
exit 1
fi

os=$(uname)
if [ "${os}" != "Linux" ]; then
vm=$(docker-machine active 2> /dev/null || echo "default")
if ! docker-machine inspect "${vm}" &> /dev/null; then
if [ -z "$quiet" ]; then
echo "Creating machine ${vm}..."
fi
docker-machine -D create -d virtualbox --virtualbox-memory 2048 ${vm}
fi
docker-machine start ${vm} > /dev/null
eval $(docker-machine env $vm --shell=sh)
fi

ip=$(docker-machine ip ${vm} 2> /dev/null || echo "localhost")
url="http://${ip}:$port"

cleanup() {
docker stop $container >/dev/null
#docker rm $container >/dev/null
}

running=$(docker ps -a -q --filter "name=${container}")
if [ -n "$running" ]; then
if [ -z "$quiet" ]; then
echo "Stopping and removing the previous session..."
echo ""
fi
cleanup
fi

if [ -z "$quiet" ]; then
echo ""
echo "Setting up the graphical application container..."
echo ""
if [ -n "$port" ]; then
echo "Point your web browser to ${url}"
echo ""
fi
fi

#pwd_dir="`cd $(dirname $0)/../..; pwd`"
mount_local=""
#if [ "${os}" = "Linux" ] || [ "${os}" = "Darwin" ]; then
# mount_local=" -v ${pwd_dir}:/usr/src/Slicer "
#fi
port_arg=""
if [ -n "$port" ]; then
port_arg="-p $port:6080"
fi

docker run \
-d \
--name $container \
${mount_local} \
$port_arg \
$extra_run_args \
$image >/dev/null

print_app_output() {
docker cp $container:/var/log/supervisor/graphical-app-launcher.log - \
| tar xO
result=$(docker cp $container:/tmp/graphical-app.return_code - \
| tar xO)
cleanup
exit $result
}

trap "docker stop $container >/dev/null && print_app_output" SIGINT SIGTERM

# Avoid CircleCI Timed Out by displaying a dot every minute
RUNNING=$(docker inspect --format="{{ .State.Running }}" $container)
while "$RUNNING" == "true"
do
echo -n .
sleep 1m
RUNNING=$(docker inspect --format="{{ .State.Running }}" $container)
done

print_app_output

# vim: noexpandtab shiftwidth=4 tabstop=4 softtabstop=0
2 changes: 1 addition & 1 deletion CMake/SlicerGenerateSlicerConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set(Slicer_LAUNCH_COMMAND_CONFIG ${Slicer_LAUNCH_COMMAND})

# License and Readme file
set(Slicer_LICENSE_FILE_CONFIG ${Slicer_SOURCE_DIR}/License.txt)
set(Slicer_README_FILE_CONFIG ${Slicer_SOURCE_DIR}/README.txt)
set(Slicer_README_FILE_CONFIG ${Slicer_SOURCE_DIR}/README.rst)

# Test templates directory
set(Slicer_CXX_MODULE_TEST_TEMPLATES_DIR_CONFIG ${Slicer_CXX_MODULE_TEST_TEMPLATES_DIR})
Expand Down
14 changes: 10 additions & 4 deletions README.txt → README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
Slicer, or 3D Slicer, is a free, open source software package for visualization and
image analysis.
Slicer
==============

3D Slicer is natively designed to be available on multiple platforms,
including Windows, Linux and Mac Os X.
.. image:: https://circleci.com/gh/Slicer/Slicer.svg?style=svg
:target: http://slicer.cdash.org/index.php?project=Slicer4

Slicer, or 3D Slicer, is a free, open source software package for visualization and
image analysis.

3D Slicer is natively designed to be available on multiple platforms,
including Windows, Linux and Mac Os X.

For more information, please see:

Expand Down
7 changes: 7 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ dependencies:
- docker info
- pip install scikit-ci-addons==0.11.0
- ci_addons docker load-pull-save slicer/slicer-dependencies
- if [[ -e ~/docker/image-test.tar ]]; then docker load -i ~/docker/image-test.tar; fi
- docker pull slicer/slicer-test
- mkdir -p ~/docker; docker save slicer/slicer-test > ~/docker/image-test.tar
- if [[ -e ~/docker/image-test-opengl.tar ]]; then docker load -i ~/docker/image-test-opengl.tar; fi
- docker pull slicer/slicer-test:opengl
- mkdir -p ~/docker; docker save slicer/slicer-test:opengl > ~/docker/image-test-opengl.tar

test:
override:
- "echo 'Notice: CircleCI does not build changes to Slicer dependencies' && if git diff --name-only master | grep -q SuperBuild > /dev/null; then false; fi"
- docker run -e "BUILD_TOOL_FLAGS=-j5" --name slicer -v ~/Slicer:/usr/src/Slicer slicer/slicer-dependencies
- docker cp slicer:$(docker cp slicer:/usr/src/Slicer-build/Slicer-build/PACKAGE_FILE.txt - | tar xO) $CIRCLE_ARTIFACTS
- bash ./CMake/CircleCI/run.sh $CIRCLE_SHA1 $CIRCLE_BRANCH