From 13853ae5e6abe5630631ebf9465ae75786b41362 Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Sat, 7 Nov 2026 16:20:34 -0700 Subject: [PATCH] ci: Add conda build to PR workflow. --- .github/configs/conda-ubuntu.yaml | 40 +++++ .github/workflows/pr-conda.yaml | 139 ++++++++++++++++++ .../{ci-stage-1.yml => pr-stage-1.yaml} | 7 +- .../{ci-stage-2.yml => pr-stage-2.yaml} | 1 + .../workflows/{ci-main.yml => pr-stages.yaml} | 7 +- 5 files changed, 189 insertions(+), 5 deletions(-) create mode 100644 .github/configs/conda-ubuntu.yaml create mode 100644 .github/workflows/pr-conda.yaml rename .github/workflows/{ci-stage-1.yml => pr-stage-1.yaml} (87%) rename .github/workflows/{ci-stage-2.yml => pr-stage-2.yaml} (97%) rename .github/workflows/{ci-main.yml => pr-stages.yaml} (54%) diff --git a/.github/configs/conda-ubuntu.yaml b/.github/configs/conda-ubuntu.yaml new file mode 100644 index 00000000..bbc1e9df --- /dev/null +++ b/.github/configs/conda-ubuntu.yaml @@ -0,0 +1,40 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= +# micromamba environment for Ubuntu with the pylith build dependencies +name: ci-conda + +channels: + - conda-forge + +dependencies: + - gxx + - clang-format + - python + - python-gil + - libpython + - setuptools + - cmake + - autoconf + - automake + - libtool + - make + - lcov + - zlib + - swig + - catch2 + - cpptrace + - openmpi + - hdf5=1.14.6=mpi_openmpi* + - h5py=3.16.0=mpi_openmpi* + - netcdf4 + - proj + - proj-data + - pyyaml + +# End of file diff --git a/.github/workflows/pr-conda.yaml b/.github/workflows/pr-conda.yaml new file mode 100644 index 00000000..22448c0a --- /dev/null +++ b/.github/workflows/pr-conda.yaml @@ -0,0 +1,139 @@ +# ================================================================================================= +# This code is part of PyLith, developed through the Computational Infrastructure +# for Geodynamics (https://github.com/geodynamics/pylith). +# +# Copyright (c) 2010-2026 All rights reserved. +# +# See https://mit-license.org/ and LICENSE.md and for license information. +# ================================================================================================= + +name: pr-conda + +on: + - workflow_call + # and manually + - workflow_dispatch + +jobs: + # build and test the ref that launched this action against a conda-forge toolchain + tests: + name: ${{matrix.target}}-${{matrix.os}} + runs-on: ${{matrix.os}} + # a login shell so the micromamba environment is active in every step + defaults: + run: + shell: bash -el {0} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + target: [opt] + include: + - os: ubuntu-latest + environment-file: spatialdata/.github/configs/conda-ubuntu.yaml + toolchain: gcc gxx + cc: mpicc + cxx: mpicxx + - target: opt + cflags: -Wall -g -O3 + cxxflags: -Wall -g -O3 + env: + PETSC_DIR: ${{github.workspace}}/petsc + PETSC_ARCH: arch-pylith + PRTE_MCA_rmaps_default_mapping_policy: ":oversubscribe" + OMPI_MCA_smsc: "^cma" + OMPI_MCA_pml: "ob1" + OMPI_MCA_btl: "self,sm,tcp" + OMPI_MCA_btl_tcp_if_include: "lo" + + steps: + - name: checkout spatialdata + uses: actions/checkout@v7 + with: + path: spatialdata + fetch-depth: 50 + fetch-tags: true + submodules: recursive + + - name: conda-forge environment + uses: mamba-org/setup-micromamba@v3 + with: + micromamba-version: latest + environment-file: ${{matrix.environment-file}} + # conda-forge only, with strict priority so nothing leaks in from defaults + condarc: | + channels: + - conda-forge + channel_priority: strict + create-args: >- + ${{matrix.toolchain}} + + - name: versions + run: | + echo " -- conda prefix" + echo "${CONDA_PREFIX}" + echo " -- make" + make --version + echo " -- C compiler" + ${{matrix.cc}} --version + echo " -- C++ compiler" + ${{matrix.cxx}} --version + echo " -- python" + python3 --version + echo " -- prefix" + python3-config --prefix + echo " -- includes" + python3-config --includes + echo " -- libs" + python3-config --libs + echo " -- platform tag from python" + python3 -c "import sys; print(sys.platform)" + echo " -- distribution tag from python" + python3 -c "import platform as p; v = p.mac_ver()[0]; print(f'macOS {v}' if v else p.freedesktop_os_release()['PRETTY_NAME'])" + + # pythia/pyre/nemesis + - name: clone pythia + run: | + echo " -- cloning pythia" + git clone --recursive --depth 1 https://github.com/geodynamics/pythia + + - name: build pythia + run: | + echo " -- switching to the pythia source directory" + cd pythia + autoreconf --install --verbose --force + echo " -- creating build directory" + mkdir ../pythia-build && cd ../pythia-build + echo " -- configure pythia" + ../pythia/configure --enable-testing --without-build-isolation --prefix=${CONDA_PREFIX} CC=${{ matrix.cc }} CXX=${{ matrix.cxx }} CFLAGS="${{matrix.cflags}}" CXXFLAGS="${{matrix.cxxflags}}" + echo " -- building pythia into the conda prefix" + make -j$(nproc) install + + - name: test pythia + run: | + echo " -- switching to the pythia build directory" + cd pythia-build + echo " -- running pythia tests" + make -j$(nproc) check + + # spatialdata + - name: build spatialdata + run: | + echo " -- switching to the spatialdata source directory" + cd spatialdata + autoreconf --install --verbose --force + echo " -- creating build directory" + mkdir ../spatialdata-build && cd ../spatialdata-build + echo " -- configure spatialdata" + ../spatialdata/configure --enable-testing --enable-swig --without-build-isolation --prefix=${CONDA_PREFIX} CC=${{ matrix.cc }} CXX=${{ matrix.cxx }} CFLAGS="${{matrix.cflags}}" CXXFLAGS="${{matrix.cxxflags}}" + echo " -- building spatialdata into the conda prefix" + make -j$(nproc) install + + - name: test spatialdata + run: | + echo " -- switching to the spatialdata build directory" + cd spatialdata-build + echo " -- running spatialdata tests" + make -j$(nproc) check VERBOSE=1 + +# end of file diff --git a/.github/workflows/ci-stage-1.yml b/.github/workflows/pr-stage-1.yaml similarity index 87% rename from .github/workflows/ci-stage-1.yml rename to .github/workflows/pr-stage-1.yaml index 04f9485f..dae83d9d 100644 --- a/.github/workflows/ci-stage-1.yml +++ b/.github/workflows/pr-stage-1.yaml @@ -15,9 +15,10 @@ jobs: - debian-stable runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout spatialdata + uses: actions/checkout@v7 with: + fetch-depth: 50 submodules: recursive - name: Build Docker image @@ -30,7 +31,7 @@ jobs: docs: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Checkout spatialdata uses: actions/checkout@v7 with: submodules: recursive diff --git a/.github/workflows/ci-stage-2.yml b/.github/workflows/pr-stage-2.yaml similarity index 97% rename from .github/workflows/ci-stage-2.yml rename to .github/workflows/pr-stage-2.yaml index 3049345d..3e9b1e68 100644 --- a/.github/workflows/ci-stage-2.yml +++ b/.github/workflows/pr-stage-2.yaml @@ -28,6 +28,7 @@ jobs: - name: Checkout code uses: actions/checkout@v7 with: + fetch-depth: 50 submodules: recursive - name: Build Docker image diff --git a/.github/workflows/ci-main.yml b/.github/workflows/pr-stages.yaml similarity index 54% rename from .github/workflows/ci-main.yml rename to .github/workflows/pr-stages.yaml index 96a78d52..8602116b 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/pr-stages.yaml @@ -11,7 +11,10 @@ on: jobs: stage-1: - uses: ./.github/workflows/ci-stage-1.yml + uses: ./.github/workflows/pr-stage-1.yaml stage-2: - uses: ./.github/workflows/ci-stage-2.yml + uses: ./.github/workflows/pr-stage-2.yaml + needs: [stage-1] + conda: + uses: ./.github/workflows/pr-conda.yaml needs: [stage-1]