|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ development ] |
| 6 | + pull_request: |
| 7 | + # CI runs when new commits are pushed or when draft PR is marked ready for review |
| 8 | + types: [opened, synchronize, reopened, ready_for_review] |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + debug_enabled: |
| 12 | + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' |
| 13 | + required: false |
| 14 | + default: false |
| 15 | + |
| 16 | +env: |
| 17 | + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
| 18 | + BUILD_TYPE: Release |
| 19 | + OMP_NUM_THREADS: 2 |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + # Skip CI if PR is a draft |
| 24 | + if: github.event.pull_request.draft == false |
| 25 | + name: build (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}}) |
| 26 | + # The CMake configure and build commands are platform agnostic and should work equally |
| 27 | + # well on Windows or Mac. You can convert this to a matrix build if you need |
| 28 | + # cross-platform coverage. |
| 29 | + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
| 30 | + runs-on: ${{matrix.os}} |
| 31 | + env: |
| 32 | + CC: ${{ matrix.cc }} |
| 33 | + CXX: ${{ matrix.cxx }} |
| 34 | + strategy: |
| 35 | + fail-fast: false |
| 36 | + matrix: |
| 37 | + os: |
| 38 | + - ubuntu-22.04 |
| 39 | + - macos-14 |
| 40 | + cc: |
| 41 | + - gcc-12 |
| 42 | + - clang |
| 43 | + cxx: |
| 44 | + - g++-12 |
| 45 | + - clang++ |
| 46 | + mpi: |
| 47 | + - "ON" |
| 48 | + - "OFF" |
| 49 | + omp: |
| 50 | + - "ON" |
| 51 | + - "OFF" |
| 52 | + exclude: |
| 53 | + - os: ubuntu-22.04 |
| 54 | + cc: clang |
| 55 | + - os: ubuntu-22.04 |
| 56 | + cxx: clang++ |
| 57 | + - os: macos-14 |
| 58 | + cc: gcc-12 |
| 59 | + - os: macos-14 |
| 60 | + cxx: g++-12 |
| 61 | + - os: macos-14 |
| 62 | + mpi: "ON" |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + |
| 66 | + # Enable tmate debugging of manually-triggered workflows if the input option was provided |
| 67 | + - name: Setup tmate session |
| 68 | + uses: mxschmitt/action-tmate@v3 |
| 69 | + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} |
| 70 | + |
| 71 | + - name: Prepare ccache timestamp |
| 72 | + id: ccache_cache_timestamp |
| 73 | + run: echo "{date_and_time}={$(date +'%Y-%m-%d-%H;%M;%S')}" >> $GITHUB_OUTPUT |
| 74 | + - name: Set ccache cache directory |
| 75 | + shell: bash |
| 76 | + run: echo "CCACHE_DIR=${{runner.workspace}}/.ccache" >> "${GITHUB_ENV}" |
| 77 | + - name: Cache ccache files |
| 78 | + uses: actions/cache@v4 |
| 79 | + with: |
| 80 | + path: ${{runner.workspace}}/.ccache |
| 81 | + key: ${{matrix.os}}-${{matrix.cxx}}-${{matrix.mpi}}-${{matrix.omp}}-${{ steps.ccache_cache_timestamp.outputs.date_and_time }} |
| 82 | + restore-keys: | |
| 83 | + ${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}-${{ matrix.omp }} |
| 84 | + ${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }} |
| 85 | + ${{ matrix.os }}-${{ matrix.cxx }} |
| 86 | + ${{ matrix.os }} |
| 87 | +
|
| 88 | +# - name: Clear ccache |
| 89 | +# run: ccache --clear |
| 90 | + |
| 91 | + - name: Install Dependencies on Ubunutu |
| 92 | + if: ${{ contains(matrix.os, 'ubuntu') }} |
| 93 | + run: | |
| 94 | + sudo apt update |
| 95 | + sudo apt install openmpi-bin libopenmpi-dev libyaml-cpp-dev libeigen3-dev libtiff-dev ccache |
| 96 | +
|
| 97 | + - name: Install Dependencies on MacOS |
| 98 | + if: ${{ contains(matrix.os, 'macos') }} |
| 99 | + run: | |
| 100 | + brew install open-mpi libomp yaml-cpp eigen cfitsio ccache |
| 101 | + echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV |
| 102 | + echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH |
| 103 | +
|
| 104 | + - name: Checkout Catch2 |
| 105 | + uses: actions/checkout@v4 |
| 106 | + with: |
| 107 | + repository: catchorg/Catch2.git |
| 108 | + path: Catch2 |
| 109 | + ref: v3.4.0 |
| 110 | + |
| 111 | + - name: Build Catch2 |
| 112 | + run: | |
| 113 | + mkdir Catch2/build |
| 114 | + cd Catch2/build |
| 115 | + cmake .. -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local |
| 116 | + make -j$(nproc --ignore 1) install |
| 117 | +
|
| 118 | + - name: Install FFTW |
| 119 | + run: | |
| 120 | + wget --no-check-certificate --no-verbose http://www.fftw.org/fftw-3.3.10.tar.gz -O- | tar --no-same-owner -xz; |
| 121 | + cd fftw-3.3.10 |
| 122 | + ./configure --prefix=${{github.workspace}}/local --enable-shared |
| 123 | + make -j$(nproc --ignore 1) install CFLAGS=-fPIC |
| 124 | + # Fix bug in FFT3 (cf. https://github.com/FFTW/fftw3/issues/332) |
| 125 | + sed -i -e 's/^.*FFTW3LibraryDepends.cmake.*$//1' ${{github.workspace}}/local/lib*/cmake/*/FFTW3Config.cmake |
| 126 | +
|
| 127 | + - name: Checkout SOPT |
| 128 | + uses: actions/checkout@v4 |
| 129 | + with: |
| 130 | + repository: astro-informatics/sopt.git |
| 131 | + path: sopt |
| 132 | + ref: development |
| 133 | + |
| 134 | + - name: Build sopt |
| 135 | + run: | |
| 136 | + export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH |
| 137 | + mkdir -p ${{github.workspace}}/sopt/build |
| 138 | + cd ${{github.workspace}}/sopt/build |
| 139 | + cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}} -Dtests=OFF -Dexamples=OFF |
| 140 | + make -j$(nproc --ignore 1) install |
| 141 | +
|
| 142 | + - name: Pack dependencies |
| 143 | + run: | |
| 144 | + cd ${{github.workspace}} |
| 145 | + tar cfv dependencies.tar local |
| 146 | + |
| 147 | + - uses: actions/upload-artifact@v4 |
| 148 | + with: |
| 149 | + name: dependencies-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}-${{ matrix.omp }} |
| 150 | + path: ${{github.workspace}}/dependencies.tar |
| 151 | + retention-days: 5 |
| 152 | + |
| 153 | + test: |
| 154 | + needs: |
| 155 | + build |
| 156 | + name: test (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}}) |
| 157 | + runs-on: ${{matrix.os}} |
| 158 | + env: |
| 159 | + CC: ${{ matrix.cc }} |
| 160 | + CXX: ${{ matrix.cxx }} |
| 161 | + strategy: |
| 162 | + fail-fast: false |
| 163 | + matrix: |
| 164 | + os: |
| 165 | + - ubuntu-22.04 |
| 166 | + - macos-14 |
| 167 | + cc: |
| 168 | + - gcc-12 |
| 169 | + - clang |
| 170 | + cxx: |
| 171 | + - g++-12 |
| 172 | + - clang++ |
| 173 | + mpi: |
| 174 | + - "ON" |
| 175 | + - "OFF" |
| 176 | + omp: |
| 177 | + - "ON" |
| 178 | + - "OFF" |
| 179 | + exclude: |
| 180 | + - os: ubuntu-22.04 |
| 181 | + cc: clang |
| 182 | + - os: ubuntu-22.04 |
| 183 | + cxx: clang++ |
| 184 | + - os: macos-14 |
| 185 | + cc: gcc-12 |
| 186 | + - os: macos-14 |
| 187 | + cxx: g++-12 |
| 188 | + - os: macos-14 |
| 189 | + mpi: "ON" |
| 190 | + steps: |
| 191 | + - uses: actions/checkout@v4 |
| 192 | + |
| 193 | + - uses: actions/download-artifact@v4 |
| 194 | + with: |
| 195 | + name: dependencies-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}-${{ matrix.omp }} |
| 196 | + |
| 197 | + - name: Unpack dependencies |
| 198 | + run: tar xfv dependencies.tar |
| 199 | + |
| 200 | + - name: Install Dependencies on Ubunutu |
| 201 | + if: ${{ contains(matrix.os, 'ubuntu') }} |
| 202 | + run: | |
| 203 | + sudo apt update |
| 204 | + sudo apt install openmpi-bin libopenmpi-dev ccache graphviz libeigen3-dev libtiff-dev libcfitsio-dev libboost-all-dev libyaml-cpp-dev |
| 205 | +
|
| 206 | + - name: Install Dependencies on MacOS |
| 207 | + if: ${{ contains(matrix.os, 'macos') }} |
| 208 | + run: | |
| 209 | + brew install open-mpi libomp eigen ccache cfitsio boost yaml-cpp |
| 210 | + echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV |
| 211 | + echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH |
| 212 | +
|
| 213 | + - name: Build tests |
| 214 | + # Build your program with the given configuration |
| 215 | + run: | |
| 216 | + export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH |
| 217 | + mkdir -p ${{github.workspace}}/build |
| 218 | + cd ${{github.workspace}}/build |
| 219 | + cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddocasa=OFF -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}} -Dtests=ON |
| 220 | + make -j$(nproc --ignore 1) install |
| 221 | +
|
| 222 | + - name: Test |
| 223 | + working-directory: ${{github.workspace}}/build |
| 224 | + # Execute tests defined by the CMake configuration. |
| 225 | + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail |
| 226 | + run: | |
| 227 | + export LD_LIBRARY_PATH=${{github.workspace}}/local/lib:${{github.workspace}}/local/external/lib:${LD_LIBRARY_PATH} |
| 228 | + ctest -C ${{env.BUILD_TYPE}} --output-on-failure |
| 229 | +
|
| 230 | + doc: |
| 231 | + needs: |
| 232 | + build |
| 233 | + name: doc (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}}) |
| 234 | + runs-on: ${{matrix.os}} |
| 235 | + env: |
| 236 | + CC: ${{ matrix.cc }} |
| 237 | + CXX: ${{ matrix.cxx }} |
| 238 | + strategy: |
| 239 | + fail-fast: false |
| 240 | + matrix: |
| 241 | + os: |
| 242 | + - ubuntu-22.04 |
| 243 | + cc: |
| 244 | + - gcc-12 |
| 245 | + cxx: |
| 246 | + - g++-12 |
| 247 | + mpi: |
| 248 | + - "OFF" |
| 249 | + omp: |
| 250 | + - "OFF" |
| 251 | + steps: |
| 252 | + - uses: actions/checkout@v4 |
| 253 | + |
| 254 | + - uses: actions/download-artifact@v4 |
| 255 | + with: |
| 256 | + name: dependencies-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}-${{ matrix.omp }} |
| 257 | + |
| 258 | + - name: Unpack dependencies |
| 259 | + run: tar xfv dependencies.tar |
| 260 | + |
| 261 | + - name: Install Dependencies on Ubunutu |
| 262 | + if: ${{ contains(matrix.os, 'ubuntu') }} |
| 263 | + run: | |
| 264 | + sudo apt update |
| 265 | + sudo apt install ccache doxygen graphviz libeigen3-dev libtiff-dev libcfitsio-dev libboost-all-dev libyaml-cpp-dev |
| 266 | +
|
| 267 | + - name: Install Dependencies on MacOS |
| 268 | + if: ${{ contains(matrix.os, 'macos') }} |
| 269 | + run: | |
| 270 | + brew install gcc libtiff eigen libyaml ccache cfitsio boost yaml-cpp |
| 271 | + echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV |
| 272 | + echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH |
| 273 | +
|
| 274 | + - name: Build docs |
| 275 | + run: | |
| 276 | + export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH |
| 277 | + mkdir -p ${{github.workspace}}/build |
| 278 | + cd ${{github.workspace}}/build |
| 279 | + cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddompi=OFF -Dopenmp=OFF -Ddocs=ON |
| 280 | + make -j$(nproc --ignore 1) install |
| 281 | +
|
| 282 | + - name: Deploy to GH pages |
| 283 | + if: ${{github.event_name == 'push'}} |
| 284 | + |
| 285 | + with: |
| 286 | + branch: gh-pages # The branch the action should deploy to. |
| 287 | + folder: build/cpp/docs/html # The folder the action should deploy. |
0 commit comments