Skip to content

Commit

Permalink
Add Windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lamyj committed Apr 16, 2024
1 parent 57b1040 commit 0d5b58d
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 39 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
40 changes: 25 additions & 15 deletions .ci/build/post_build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import glob
import os
import platform
import string
import subprocess
import sys
import sysconfig
Expand All @@ -18,29 +20,37 @@
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"))

with open(os.path.join(workspace, "tests", "data", "dcmqrscp.config.in")) as src:
config_template = string.Template(src.read())
config = config_template.substitute(localhost=platform.node())
with open(os.path.join(workspace, "tests", "data", "dcmqrscp.config"), "w") as dst:
dst.write(config)
server = subprocess.Popen(
["dcmqrscp", "-ll", "fatal", "-c", "dcmqrscp.config", "11112"],
cwd=os.path.join(workspace, "tests/data"))
["dcmqrscp", "-ll", "debug", "-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_HOST_NAME"] = platform.node()
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 +59,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 +70,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
8 changes: 0 additions & 8 deletions tests/data/dcmqrscp.config

This file was deleted.

8 changes: 8 additions & 0 deletions tests/data/dcmqrscp.config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
HostTable BEGIN
remote = (REMOTE, ${localhost}, 11112)
local = (LOCAL, ${localhost}, 11113)
HostTable END

AETable BEGIN
REMOTE . RW (10, 1024mb) ANY
AETable END

0 comments on commit 0d5b58d

Please sign in to comment.