Skip to content

Commit

Permalink
Rewrite apt-based CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lamyj committed Apr 14, 2024
1 parent f10b3c9 commit b94f558
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 64 deletions.
15 changes: 15 additions & 0 deletions .ci/build/apt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import subprocess

os.environ["DEBIAN_FRONTEND"] = "noninteractive"

subprocess.check_call(["apt-get", "update"])

subprocess.check_call([
"apt-get", "-y", "--no-install-recommends", "install",
"build-essential", "cmake", "ninja-build", "pkg-config", "python3",
"libboost-dev", "libboost-date-time-dev", "libboost-exception-dev",
"libboost-log-dev", "libboost-filesystem-dev", "libboost-regex-dev",
"libdcmtk-dev", "libicu-dev", "libjsoncpp-dev", "zlib1g-dev",
"pybind11-dev", "python3-pybind11", "python3-dev",
"libboost-test-dev", "dcmtk"])
25 changes: 25 additions & 0 deletions .ci/build/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import subprocess
import sys

print(f"Building with {sys.executable}")

workspace = os.environ["WORKSPACE"]
build_dir = os.environ.get("BUILD_DIR", os.path.join(workspace, "build"))
install_dir = os.environ.get("INSTALL_DIR", os.path.join(workspace, "install"))

for dir in [build_dir, install_dir]:
if not os.path.isdir(dir):
os.makedirs(dir)

subprocess.check_call(
[
"cmake",
"-G", "Ninja",
"-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)
66 changes: 66 additions & 0 deletions .ci/build/post_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import glob
import os
import subprocess
import sys
import sysconfig
import time

workspace = os.environ["WORKSPACE"]
build_dir = os.environ.get("BUILD_DIR", os.path.join(workspace, "build"))
install_dir = os.environ.get("INSTALL_DIR", os.path.join(workspace, "install"))

bin_dir = os.path.join(install_dir, "bin")
lib_dir = os.path.join(install_dir, "lib")
python_lib_dir = os.path.join(
install_dir,
sysconfig.get_path(
"purelib", {"posix":"posix_prefix", "nt":"nt"}[os.name], {"base": "."}))
python_tests_dir = os.path.join(workspace, "tests", "wrappers")

subprocess.check_call(
["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"))
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),
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
return_code = max(
return_code,
subprocess.call(
["ctest", "--output-on-failure"],
cwd=build_dir, stderr=subprocess.STDOUT))
return_code = max(
return_code,
subprocess.call(
[sys.executable, "-m", "unittest", "discover", "-s", python_tests_dir],
cwd=build_dir, stderr=subprocess.STDOUT))

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(path)

sys.exit(return_code)
21 changes: 0 additions & 21 deletions .ci/deb/build

This file was deleted.

22 changes: 0 additions & 22 deletions .ci/deb/install

This file was deleted.

40 changes: 19 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,33 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
container: debian:bullseye
ci_type: deb
- os: ubuntu-latest
container: debian:bookworm
ci_type: deb
cmake_options: "-DCMAKE_CXX_STANDARD=17"
- os: ubuntu-latest
container: ubuntu:focal
ci_type: deb
- os: ubuntu-latest
container: ubuntu:jammy
ci_type: deb
cmake_options: "-DCMAKE_CXX_STANDARD=17"
- { 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" }
# - name: "macOS 11 (Big Sur) + Homebrew"
# os: macos-11
# ci_type: brew
# start_worker: ""
# worker: ""
# stop_worker: ""
env:
WORKSPACE: "${{ github.workspace }}"
CMAKE_OPTIONS: "${{ matrix.cmake_options }}"
steps:
- name: Provision (Debian, Ubuntu)
# Install Python and Git. macOS workers already have this, however for
# Linux we are running in minimal containers.
run: |
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y git python3
if: ${{ contains(matrix.packaging, 'apt') }}

- name: Checkout latest revision
uses: actions/checkout@v4
- name: Configure the build
run: ./.ci/${{ matrix.ci_type}}/install

- name: Set-up (${{ matrix.packaging }})
run: ${{ matrix.python }} .ci/build/${{ matrix.packaging }}.py

- name: Build
run: ./.ci/${{ matrix.ci_type}}/build
run: ${{ matrix.python }} ./.ci/build/build.py

- name: Run tests
run: ./.ci/${{ matrix.ci_type}}/post_build
run: ${{ matrix.python }} ./.ci/build/post_build.py

0 comments on commit b94f558

Please sign in to comment.