From a9e7e513b9463a9b05fb58ddce58c369168ea177 Mon Sep 17 00:00:00 2001 From: Julien Lamy Date: Sun, 14 Apr 2024 12:21:54 +0200 Subject: [PATCH] Rewrite apt-based CI --- .ci/build/apt.py | 15 +++++++++++++ .ci/build/build.py | 25 ++++++++++++++++++++++ .github/workflows/build.yml | 42 ++++++++++++++++++------------------- 3 files changed, 60 insertions(+), 22 deletions(-) create mode 100644 .ci/build/apt.py create mode 100644 .ci/build/build.py diff --git a/.ci/build/apt.py b/.ci/build/apt.py new file mode 100644 index 0000000..aa180da --- /dev/null +++ b/.ci/build/apt.py @@ -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"]) diff --git a/.ci/build/build.py b/.ci/build/build.py new file mode 100644 index 0000000..04ea53c --- /dev/null +++ b/.ci/build/build.py @@ -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) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c1ed48f..088652c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 - - name: Run tests - run: ./.ci/${{ matrix.ci_type}}/post_build + run: ${{ matrix.python }} ./.ci/build/build.py + + # - name: Run tests + # run: ./.ci/${{ matrix.ci_type}}/post_build