Skip to content

Commit

Permalink
CI: test docker CIL (#838)
Browse files Browse the repository at this point in the history
Co-authored-by: Casper da Costa-Luis <casper.dcl@physics.org>
Co-authored-by: Kris Thielemans <KrisThielemans@users.noreply.github.com>
  • Loading branch information
casperdcl and KrisThielemans authored Oct 13, 2023
1 parent d858fda commit 5f394eb
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 77 deletions.
84 changes: 45 additions & 39 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install docker and pre-reqs and clean some disk-space
shell: bash -l {0}
run: |
sudo .github/workflows/install_docker.sh
sudo .github/workflows/GHA_increase_disk_space.sh
- name: Build docker core image
# Builds docker image from Docker file.
shell: bash -l {0}
run: |
docker-compose -f docker/docker-compose.yml build --pull core
docker-compose -f docker/docker-compose.yml build --pull core
- name : docker save core
# https://docs.docker.com/engine/reference/commandline/save/
shell: bash -l {0}
Expand All @@ -44,14 +44,14 @@ jobs:
docker image ls
docker save synerbi/sirf:core | gzip > core.tar.gz
ls -l
- name: Upload artifact of the core image.
uses: actions/upload-artifact@v3.1.2
with:
name: sirf-core
path: core.tar.gz


build-core-gpu:
runs-on: ubuntu-latest
steps:
Expand All @@ -61,27 +61,27 @@ jobs:
run: |
sudo .github/workflows/install_docker.sh
sudo .github/workflows/GHA_increase_disk_space.sh
- name: Build docker core-gpu image
# Builds docker image from Docker file.
shell: bash -l {0}
run: |
docker-compose -f docker/docker-compose.yml -f docker/docker-compose.srv-gpu.yml build --pull core
- name : docker save core-gpu
# https://docs.docker.com/engine/reference/commandline/save/
shell: bash -l {0}
run: |
docker image ls
docker save synerbi/sirf:core-gpu | gzip > core-gpu.tar.gz
ls -l
- name: Upload artifact of the core image.
uses: actions/upload-artifact@v3.1.2
with:
name: sirf-core-gpu
path: core-gpu.tar.gz

build-devel-and-latest:
runs-on: ubuntu-latest
needs: build-core
Expand All @@ -95,7 +95,7 @@ jobs:
run: |
sudo .github/workflows/install_docker.sh
sudo .github/workflows/GHA_increase_disk_space.sh
- name: Download artifact of core image
uses: actions/download-artifact@v3
with:
Expand All @@ -106,18 +106,18 @@ jobs:
shell: bash -l {0}
run: |
docker load --input /tmp/core.tar.gz
- name: Build docker image
# Builds docker image from Docker file.
shell: bash -l {0}
run: |
set -ex;
compose_command="docker-compose -f docker/docker-compose.yml"
compose_command="docker-compose -f docker/docker-compose.yml"
if [[ ${{ matrix.tag }} == 'devel' ]]; then compose_command="$compose_command -f docker/docker-compose.devel.yml"; fi
# $compose_command pull core
$compose_command build --pull sirf
echo "compose_command=$compose_command" >> $GITHUB_ENV
- name : docker save image
# https://docs.docker.com/engine/reference/commandline/save/
shell: bash -l {0}
Expand All @@ -126,13 +126,13 @@ jobs:
sirf_image=`docker image ls | grep ${{ matrix.tag }} | awk '/sirf/ { print $3}'`
docker history "$sirf_image"
docker save synerbi/sirf:${{ matrix.tag }} | gzip > ${{ matrix.tag }}.tar.gz
- name: Upload artifact of image.
uses: actions/upload-artifact@v3.1.2
with:
name: sirf-${{ matrix.tag }}
path: ${{ matrix.tag }}.tar.gz

build-service-gpu:
runs-on: ubuntu-latest
needs: build-core-gpu
Expand Down Expand Up @@ -160,9 +160,9 @@ jobs:
shell: bash -l {0}
run: |
set -ex;
# docker-compose -f docker/docker-compose.yml -f docker/docker-compose.srv-gpu.yml pull core
# docker-compose -f docker/docker-compose.yml -f docker/docker-compose.srv-gpu.yml pull core
docker-compose -f docker/docker-compose.yml -f docker/docker-compose.srv-gpu.yml build --pull sirf
# Temporarily disabling the save and upload of the image as it is too big.
# see https://github.com/SyneRBI/SIRF-SuperBuild/issues/770

Expand All @@ -174,16 +174,16 @@ jobs:
# docker rmi synerbi/sirf:core-gpu
# yes | docker system prune
# docker image ls
# docker save synerbi/sirf:service-gpu | gzip > service-gpu.tar.gz
# docker save synerbi/sirf:service-gpu | gzip > service-gpu.tar.gz

# - name: Upload artifact of image.
# uses: actions/upload-artifact@v3.1.2
# with:
# name: sirf-service-gpu
# path: service-gpu.tar.gz



build-service-images:
runs-on: ubuntu-latest
needs: build-devel-and-latest
Expand All @@ -197,13 +197,13 @@ jobs:
run: |
sudo .github/workflows/install_docker.sh
sudo .github/workflows/GHA_increase_disk_space.sh
- name: setup variables
shell: bash -l {0}
run: |
compose_command="docker-compose -f docker/docker-compose.yml"
if [[ ${{ matrix.tag }} == 'service' ]];
if [[ ${{ matrix.tag }} == 'service' ]];
then
echo "prereq_image_name="latest"" >> $GITHUB_ENV
compose_command="$compose_command -f docker/docker-compose.srv.yml"
Expand All @@ -212,9 +212,9 @@ jobs:
then
echo "prereq_image_name="devel"" >> $GITHUB_ENV
compose_command="$compose_command -f docker/docker-compose.devel.yml -f docker/docker-compose.srv.yml"
fi
fi
echo "compose_command=$compose_command" >> $GITHUB_ENV
- name: Download artifact of image
uses: actions/download-artifact@v3
with:
Expand All @@ -225,15 +225,21 @@ jobs:
shell: bash -l {0}
run: |
docker load --input /tmp/${{ env.prereq_image_name }}.tar.gz
- name: Build docker image
# Builds docker image from Docker file.
shell: bash -l {0}
run: |
set -ex;
# ${{ env.compose_command }} pull sirf
${{ env.compose_command }} build --pull sirf
- name: Test CIL
shell: bash -l {0}
run: |
set -ex;
docker run --rm -v ./.github/workflows:/gh synerbi/sirf:service /gh/test_cil.sh
- name : docker save image
# https://docs.docker.com/engine/reference/commandline/save/
shell: bash -l {0}
Expand All @@ -243,14 +249,14 @@ jobs:
# get rid of everything over 2 days old
docker system prune -a --filter "until=2d"
docker image ls
docker save synerbi/sirf:service | gzip > ${{ matrix.tag }}.tar.gz
docker save synerbi/sirf:service | gzip > ${{ matrix.tag }}.tar.gz
- name: Upload artifact of image.
uses: actions/upload-artifact@v3.1.2
with:
name: sirf-${{ matrix.tag }}
path: ${{ matrix.tag }}.tar.gz

# Docker images are not currently uploaded with this action.
# Disable it for now as it would just waste time.
# upload-images:
Expand All @@ -266,7 +272,7 @@ jobs:
# run: |
# sudo .github/workflows/install_docker.sh
# sudo .github/workflows/GHA_increase_disk_space.sh

# - name: Download artifact of image
# uses: actions/download-artifact@v3
# with:
Expand All @@ -277,14 +283,14 @@ jobs:
# shell: bash -l {0}
# run: |
# docker load --input /tmp/${{ matrix.tag }}.tar.gz

# - name: Upload docker image
# # Builds docker image from Docker file.
# shell: bash -l {0}
# run: |
# # TODO requirement to
# # TODO requirement to
# docker image ls
# echo "Here we would upload image with name: ${{ matrix.tag }}"


# TODO: publish to come later
14 changes: 14 additions & 0 deletions .github/workflows/test_cil.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
[ -f .bashrc ] && . .bashrc
set -euxo pipefail

mkdir cil_sirf_test
touch cil_sirf_test/__init__.py
DEFAULT_CIL_TAG=$(/opt/conda/bin/python -c 'import cil; print(f"v{cil.version.version}" if cil.version.commit_hash == "-1" else cil.version.commit_hash[1:])' | tail -n1)
for fname in test_SIRF.py utils.py testclass.py; do
curl -fsSL https://raw.githubusercontent.com/TomographicImaging/CIL/$DEFAULT_CIL_TAG/Wrappers/Python/test/$fname > cil_sirf_test/$fname
done

$SIRF_PATH/../../INSTALL/bin/gadgetron >& ~/gadgetron.log&
/opt/conda/bin/python -m unittest discover -v ./cil_sirf_test -k GradientPET -k BlockDataContainer
for i in $(jobs -p); do kill -n 15 $i; done 2>/dev/null # kill gadgetron
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- siemens_to_ismrmrd: 8bb8b08f53ce73c2de9ba5f47f1532f96292d92b
- ISMRMRD: v1.13.2
- SIRF: v3.5.0
- CIL: 0ba2f8e2935db66ec3dfe8c88e407e8d0eb5609f
- CIL: v23.1.0
- CCPi-Regularisation: v22.0.0
- TomoPhantom: v2.0.0

Expand Down
2 changes: 1 addition & 1 deletion SuperBuild/External_CIL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${externalProjName}" AND "${USE_SYSTEM_${externalPr
COMMAND ${PYTHON_EXECUTABLE} -m unittest discover -p test_run_*.py
WORKING_DIRECTORY ${${proj}_SOURCE_DIR}/Wrappers/Python/test)
add_test(NAME CIL_SIRF_TESTS
COMMAND ${PYTHON_EXECUTABLE} -m unittest discover -p test_SIRF*.py
COMMAND ${PYTHON_EXECUTABLE} -m unittest discover -p test_SIRF*.py -k GradientPET -k BlockDataContainer
WORKING_DIRECTORY ${${proj}_SOURCE_DIR}/Wrappers/Python/test)
add_test(NAME CIL_FRAMEWORK_TESTS_4
COMMAND ${PYTHON_EXECUTABLE} -m unittest discover -p test_Block_*.py
Expand Down
Loading

0 comments on commit 5f394eb

Please sign in to comment.