Skip to content

Commit

Permalink
Add Conda CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lamyj committed Apr 14, 2024
1 parent b94f558 commit fe17071
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 228 deletions.
24 changes: 0 additions & 24 deletions .ci/brew/build

This file was deleted.

23 changes: 0 additions & 23 deletions .ci/brew/install

This file was deleted.

38 changes: 0 additions & 38 deletions .ci/brew/post_build

This file was deleted.

9 changes: 9 additions & 0 deletions .ci/build/conda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import subprocess
import sys

conda = sys.argv[1] if len(sys.argv) >= 2 else "conda"

subprocess.check_call([
conda, "install", "--yes", "-c", "conda-forge",
"boost", "cmake", "dcmtk", "icu", "jsoncpp", "ninja", "pkg-config",
"pybind11", "zlib"])
38 changes: 20 additions & 18 deletions .ci/build/post_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,39 @@
cwd=os.path.join(workspace, "tests/data"))
time.sleep(1)

# Set-up environment: C++ library, Python module and test data location.
for name in ["DYLD_LIBRARY_PATH", "LD_LIBRARY_PATH"]:
os.environ[name] = os.pathsep.join([
*os.environ.get(name, "").split(os.pathsep), lib_dir])
os.environ["PATH"] = os.pathsep.join([
*os.environ.get("PATH", "").split(os.pathsep), bin_dir])
os.environ["PYTHONPATH"] = os.pathsep.join([
*os.environ.get("PYTHONPATH", "").split(os.pathsep), python_lib_dir])

os.environ |= {
"ODIL_OWN_AET": "LOCAL",
"ODIL_PEER_HOST_NAME": "127.0.0.1",
"ODIL_PEER_PORT": "11112",
"ODIL_PEER_AET": "REMOTE"}
os.environ["PATH"] = os.pathsep.join([
*os.environ["PATH"].split(os.pathsep),
# Set-up environment: test-related variables
environment = os.environ.copy()
environment["ODIL_OWN_AET"] = "LOCAL"
environment["ODIL_PEER_HOST_NAME"] = "127.0.0.1"
environment["ODIL_PEER_PORT"] = "11112"
environment["ODIL_PEER_AET"] = "REMOTE"
environment["PATH"] = os.pathsep.join([
*environment["PATH"].split(os.pathsep),
os.path.join(workspace, "tests/tools")])

# Run C++ and Python tests even if the former fails, return non-zero if any
# failed.
return_code = 0

# No extra environment needed for C++ part
return_code = max(
return_code,
subprocess.call(
["ctest", "--output-on-failure"],
cwd=build_dir, stderr=subprocess.STDOUT))
cwd=build_dir, stderr=subprocess.STDOUT, env=environment))

# Python tests require lib configuration
for name in ["DYLD_LIBRARY_PATH", "LD_LIBRARY_PATH"]:
environment[name] = os.pathsep.join([
*environment.get(name, "").split(os.pathsep), lib_dir])
environment["PYTHONPATH"] = os.pathsep.join([
*environment.get("PYTHONPATH", "").split(os.pathsep), python_lib_dir])

return_code = max(
return_code,
subprocess.call(
[sys.executable, "-m", "unittest", "discover", "-s", python_tests_dir],
cwd=build_dir, stderr=subprocess.STDOUT))
cwd=build_dir, stderr=subprocess.STDOUT, env=environment))

server.terminate()
os.remove(os.path.join(workspace, "tests/data", "index.dat"))
Expand Down
22 changes: 0 additions & 22 deletions .ci/conda_mac/build

This file was deleted.

6 changes: 0 additions & 6 deletions .ci/conda_mac/install

This file was deleted.

40 changes: 0 additions & 40 deletions .ci/conda_mac/post_build

This file was deleted.

38 changes: 0 additions & 38 deletions .ci/deb/post_build

This file was deleted.

20 changes: 16 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ jobs:
fail-fast: false
matrix:
include:
- { os: "ubuntu-latest", container: "debian:bullseye", packaging: "apt", python: "python3" }
- { os: "ubuntu-latest", container: "debian:bookworm", packaging: "apt", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python3" }
- { os: "ubuntu-latest", container: "ubuntu:focal", packaging: "apt", python: "python3" }
- { os: "ubuntu-latest", container: "ubuntu:jammy", packaging: "apt", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python3" }
- { os: "ubuntu-latest", container: "debian:bullseye", packaging: "apt", python: "python3" }
- { os: "ubuntu-latest", container: "debian:bookworm", packaging: "apt", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python3" }
- { os: "ubuntu-latest", container: "ubuntu:focal", packaging: "apt", python: "python3" }
- { os: "ubuntu-latest", container: "ubuntu:jammy", packaging: "apt", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python3" }
- { os: "ubuntu-latest", packaging: "conda", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python" }
# - name: "macOS 11 (Big Sur) + Homebrew"
# os: macos-11
# ci_type: brew
env:
WORKSPACE: "${{ github.workspace }}"
CMAKE_OPTIONS: "${{ matrix.cmake_options }}"
defaults:
run:
shell: ${{ contains(matrix.os, 'windows') && 'pwsh' || 'bash -l {0}' }}
steps:
- name: Provision (Debian, Ubuntu)
# Install Python and Git. macOS workers already have this, however for
Expand All @@ -29,6 +33,14 @@ jobs:
DEBIAN_FRONTEND=noninteractive apt-get install -y git python3
if: ${{ contains(matrix.packaging, 'apt') }}

- name: Provision (Micromamba)
uses: mamba-org/setup-micromamba@v1
with:
init-shell: bash powershell
environment-name: dicomifier
create-args: python=3.11
if: ${{ contains(matrix.packaging, 'conda') }}

- name: Checkout latest revision
uses: actions/checkout@v4

Expand Down
17 changes: 12 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ find_package(ICU REQUIRED COMPONENTS uc)
find_package(JsonCpp REQUIRED)
if(WITH_DCMTK)
find_package(DCMTK REQUIRED)
find_package(ZLIB REQUIRED)
endif()

file(GLOB_RECURSE Header_Files "*.h")
Expand All @@ -24,7 +25,7 @@ add_library(libodil ${Source_Files} ${Header_Files} ${templates})
target_compile_definitions(
libodil
PUBLIC
BOOST_ASIO_SEPARATE_COMPILATION ${DCMTK_DEFINITIONS}
BOOST_ASIO_SEPARATE_COMPILATION
ODIL_VERSION_MAJOR=${Odil_VERSION_MAJOR}
$<$<BOOL:BUILD_SHARED_LIBS>:BOOST_ALL_DYN_LINK>
$<$<PLATFORM_ID:Windows>:BOOST_UUID_FORCE_AUTO_LINK>
Expand All @@ -34,21 +35,27 @@ target_compile_definitions(
target_include_directories(
libodil
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/> $<INSTALL_INTERFACE:>
"$<$<BOOL:${WITH_DCMTK}>:${DCMTK_INCLUDE_DIRS}>")
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/> $<INSTALL_INTERFACE:>)

target_link_libraries(
libodil
PUBLIC
Boost::date_time Boost::exception Boost::filesystem Boost::log
"$<$<BOOL:${WITH_DCMTK}>:${DCMTK_LIBRARIES}>"
ICU::uc JsonCpp::JsonCpp
$<$<PLATFORM_ID:Windows>:netapi32>
# WARNING Need to link with bcrypt explicitly,
# cf. https://github.com/boostorg/uuid/issues/68#issuecomment-430173245
# Not sure why iphlpapi is not linked.
"$<$<BOOL:${VCPKG_TOOLCHAIN}>:bcrypt;iphlpapi>")

if(WITH_DCMTK)
if("${DCMTK_VERSION}" VERSION_LESS 3.6.7)
target_include_directories(libodil PUBLIC ${DCMTK_INCLUDE_DIRS})
target_link_libraries(libodil PUBLIC ${DCMTK_LIBRARIES})
else()
target_link_libraries(libodil PUBLIC DCMTK::DCMTK ZLIB::ZLIB)
endif()
endif()

if(APPLE)
# WARNING: Boost::log may add -licudata -licui18n -licuu, which cause
# problems with macOS/brew
Expand Down
16 changes: 11 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
find_package(
Boost COMPONENTS exception filesystem log unit_test_framework REQUIRED)
find_package(DCMTK REQUIRED)
find_package(ZLIB REQUIRED)
find_package(JsonCpp REQUIRED)

add_subdirectory(tools)
Expand Down Expand Up @@ -36,20 +37,25 @@ foreach(test_file ${tests})
target_compile_definitions(
test_${test}
PRIVATE
BOOST_ASIO_SEPARATE_COMPILATION ${DCMTK_DEFINITIONS}
BOOST_ASIO_SEPARATE_COMPILATION
ODIL_VERSION_MAJOR=${Odil_VERSION_MAJOR}
$<$<BOOL:BUILD_SHARED_LIBS>:BOOST_ALL_DYN_LINK>)

target_include_directories(
test_${test} PRIVATE ${CMAKE_SOURCE_DIR}/src ${DCMTK_INCLUDE_DIRS})
target_include_directories(test_${test} PRIVATE ${CMAKE_SOURCE_DIR}/src)

target_link_libraries(
test_${test}
PRIVATE
Boost::unit_test_framework ${DCMTK_LIBRARIES} JsonCpp::JsonCpp
libodil
Boost::unit_test_framework JsonCpp::JsonCpp libodil
$<$<PLATFORM_ID:Windows>:Ws2_32>)

if("${DCMTK_VERSION}" VERSION_LESS 3.6.7)
target_include_directories(test_${test} PUBLIC ${DCMTK_INCLUDE_DIRS})
target_link_libraries(test_${test} PUBLIC ${DCMTK_LIBRARIES})
else()
target_link_libraries(test_${test} PUBLIC DCMTK::DCMTK ZLIB::ZLIB)
endif()

set_target_properties(
test_${test} PROPERTIES OUTPUT_NAME ${test} FOLDER "Tests")

Expand Down
Loading

0 comments on commit fe17071

Please sign in to comment.