Skip to content

Commit

Permalink
Add Windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lamyj committed May 9, 2024
1 parent 57b1040 commit 37ef345
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 33 deletions.
10 changes: 8 additions & 2 deletions .ci/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@
subprocess.check_call(
[
"cmake",
"-G", "Ninja",
# NOTE: if Ninja is used as a builder, compiler chain defaults to gcc on
# Windows
*(["-G", "Ninja"] if os.name != "nt" else []),
"-DPython_EXECUTABLE={}".format(sys.executable),
"-DCMAKE_INSTALL_PREFIX={}".format(install_dir),
*([os.environ["CMAKE_OPTIONS"]] if "CMAKE_OPTIONS" in os.environ else []),
workspace],
cwd=build_dir)

subprocess.check_call(["ninja", "install"], cwd=build_dir)
subprocess.check_call(
[
"cmake", "--build", ".", "--target", "install", "--config", "Release",
"--parallel"],
cwd=build_dir)
3 changes: 2 additions & 1 deletion .ci/build/conda.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import subprocess
import sys

conda = sys.argv[1] if len(sys.argv) >= 2 else "conda"
conda = sys.argv[1] if len(sys.argv) >= 2 else os.environ.get("MAMBA_EXE", "conda")

subprocess.check_call([
conda, "install", "--yes", "-c", "conda-forge",
Expand Down
31 changes: 17 additions & 14 deletions .ci/build/post_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,32 @@
python_tests_dir = os.path.join(workspace, "tests", "wrappers")

subprocess.check_call(
["dcmqridx", "./", "dataset.dcm"],
cwd=os.path.join(workspace, "tests/data"))
["dcmqridx", ".", "dataset.dcm"],
cwd=os.path.join(workspace, "tests", "data"))

server = subprocess.Popen(
["dcmqrscp", "-ll", "fatal", "-c", "dcmqrscp.config", "11112"],
cwd=os.path.join(workspace, "tests/data"))
["dcmqrscp", "-ll", "warning", "-c", "dcmqrscp.config", "11112"],
cwd=os.path.join(workspace, "tests", "data"))
time.sleep(1)

# Set-up environment: test-related variables
def prepend_env_path(item, paths):
return f"{item}{os.pathsep}{paths}" if paths else item
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")])
environment["PATH"] = prepend_env_path(
os.path.join(workspace, "tests", "tools"), environment.get("PATH"))

# 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
# No extra environment needed for C++ part except for Windows
if os.name == "nt":
environment["PATH"] = prepend_env_path(bin_dir, environment.get("PATH"))
return_code = max(
return_code,
subprocess.call(
Expand All @@ -49,10 +52,9 @@

# 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])
environment[name] = prepend_env_path(lib_dir, environment.get(name))
environment["PYTHONPATH"] = prepend_env_path(
python_lib_dir, environment.get("PYTHONPATH"))

return_code = max(
return_code,
Expand All @@ -61,8 +63,9 @@
cwd=build_dir, stderr=subprocess.STDOUT, env=environment))

server.terminate()
os.remove(os.path.join(workspace, "tests/data", "index.dat"))
for path in glob.glob(os.path.join(workspace, "tests/data/RAW_*.dcm")):
os.remove(os.path.join(workspace, "tests", "data", "index.dat"))
for path in glob.glob(os.path.join(workspace, "tests", "data", "RAW_*.dcm")):
os.remove(path)
os.remove(os.path.join(workspace, "tests", "data", "dcmqrscp.config"))

sys.exit(return_code)
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- { 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" }
- { os: "macos-latest", packaging: "conda", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python" }
- { os: "windows-latest", packaging: "conda", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python" }
env:
WORKSPACE: "${{ github.workspace }}"
CMAKE_OPTIONS: "${{ matrix.cmake_options }}"
Expand All @@ -35,7 +36,7 @@ jobs:
uses: mamba-org/setup-micromamba@v1
with:
init-shell: bash powershell
environment-name: dicomifier
environment-name: odil
create-args: python=3.11
if: ${{ contains(matrix.packaging, 'conda') }}

Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ add_library(libodil ${Source_Files} ${Header_Files} ${templates})
target_compile_definitions(
libodil
PUBLIC
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 Down
10 changes: 0 additions & 10 deletions src/odil/asio.cpp

This file was deleted.

1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ foreach(test_file ${tests})
target_compile_definitions(
test_${test}
PRIVATE
BOOST_ASIO_SEPARATE_COMPILATION
ODIL_VERSION_MAJOR=${Odil_VERSION_MAJOR}
$<$<BOOL:BUILD_SHARED_LIBS>:BOOST_ALL_DYN_LINK>)

Expand Down
6 changes: 3 additions & 3 deletions tests/data/dcmqrscp.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
HostTable BEGIN
remote = (REMOTE, localhost, 11112)
local = (LOCAL, localhost, 11113)
remote = (REMOTE, 127.0.0.1, 11112)
local = (LOCAL, 127.0.0.1, 11113)
HostTable END

AETable BEGIN
REMOTE . RW (10, 1024mb) local
REMOTE . RW (500, 1024mb) ANY
AETable END
4 changes: 4 additions & 0 deletions wrappers/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ execute_process(

install(TARGETS pyodil DESTINATION "${PYTHON_SITE_PACKAGES}/odil")
install(FILES ${Python_Files} DESTINATION "${PYTHON_SITE_PACKAGES}/odil")

if(WIN32)
install(TARGETS libodil RUNTIME DESTINATION "${PYTHON_SITE_PACKAGES}/odil")
endif()

0 comments on commit 37ef345

Please sign in to comment.