Skip to content

Commit

Permalink
Merge pull request #350 from astro-informatics/tk/refactor-ci
Browse files Browse the repository at this point in the history
Refactor CI to remove duplication
  • Loading branch information
20DM authored Sep 13, 2024
2 parents 0a92448 + ffd2cc8 commit 90c0369
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 114 deletions.
169 changes: 136 additions & 33 deletions .github/workflows/cmake.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CMake
name: CI

on:
push:
Expand All @@ -22,7 +22,7 @@ jobs:
build:
# Skip CI if PR is a draft
if: github.event.pull_request.draft == false
name: ${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}}
name: build (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}})
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
Expand All @@ -35,15 +35,13 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
- macos-14
cc:
- gcc-10
- gcc-11
- gcc-12
- clang
cxx:
- g++-10
- g++-11
- g++-12
- clang++
mpi:
- "ON"
Expand All @@ -52,32 +50,16 @@ jobs:
- "ON"
- "OFF"
exclude:
- cc: gcc-11
cxx: clang++
- cc: clang
cxx: g++-11
- cc: gcc-10
cxx: clang++
- cc: clang
cxx: g++-10
- os: ubuntu-20.04
- os: ubuntu-22.04
cc: clang
- os: ubuntu-22.04
cxx: clang++
- os: macos-14
cxx: g++-10
- os: macos-14
cc: gcc-10
- os: ubuntu-20.04
cxx: g++-11
- os: ubuntu-20.04
cc: gcc-11
cc: gcc-12
- os: macos-14
mpi: "on"
cxx: g++-12
- os: macos-14
cxx: g++-11
- cxx: clang++
omp: "on"

mpi: "ON"
steps:
- uses: actions/checkout@v4

Expand All @@ -93,7 +75,7 @@ jobs:
shell: bash
run: echo "CCACHE_DIR=${{runner.workspace}}/.ccache" >> "${GITHUB_ENV}"
- name: Cache ccache files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{runner.workspace}}/.ccache
key: ${{matrix.os}}-${{matrix.cxx}}-${{matrix.mpi}}-${{matrix.omp}}-${{ steps.ccache_cache_timestamp.outputs.date_and_time }}
Expand All @@ -110,12 +92,12 @@ jobs:
if: ${{ contains(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install openmpi-bin libopenmpi-dev ccache graphviz libeigen3-dev libspdlog-dev libtiff-dev libcfitsio-dev libbenchmark-dev libboost-all-dev libyaml-cpp-dev
sudo apt install openmpi-bin libopenmpi-dev libyaml-cpp-dev libeigen3-dev libtiff-dev ccache
- name: Install Dependencies on MacOS
if: ${{ contains(matrix.os, 'macos') }}
run: |
brew install gcc libtiff open-mpi libomp eigen libyaml ccache cfitsio boost yaml-cpp
brew install open-mpi libomp yaml-cpp eigen cfitsio ccache
echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV
echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH
Expand Down Expand Up @@ -157,13 +139,77 @@ jobs:
cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}} -Dtests=OFF -Dexamples=OFF
make -j$(nproc --ignore 1) install
- name: Install
- uses: actions/upload-artifact@v4
with:
name: dependencies-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}-${{ matrix.omp }}
path: ${{github.workspace}}/local


test:
needs:
build
name: test (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}})
runs-on: ${{matrix.os}}
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- macos-14
cc:
- gcc-12
- clang
cxx:
- g++-12
- clang++
mpi:
- "ON"
- "OFF"
omp:
- "ON"
- "OFF"
exclude:
- os: ubuntu-22.04
cc: clang
- os: ubuntu-22.04
cxx: clang++
- os: macos-14
cc: gcc-12
- os: macos-14
cxx: g++-12
- os: macos-14
mpi: "ON"
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: dependencies-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}-${{ matrix.omp }}
path: ${{github.workspace}}/local

- name: Install Dependencies on Ubunutu
if: ${{ contains(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install openmpi-bin libopenmpi-dev ccache graphviz libeigen3-dev libtiff-dev libcfitsio-dev libboost-all-dev libyaml-cpp-dev
- name: Install Dependencies on MacOS
if: ${{ contains(matrix.os, 'macos') }}
run: |
brew install open-mpi libomp eigen ccache cfitsio boost yaml-cpp
echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV
echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH
- name: Build tests
# Build your program with the given configuration
run: |
export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH
mkdir -p ${{github.workspace}}/build
cd ${{github.workspace}}/build
cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddocasa=OFF -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}}
cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddocasa=OFF -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}} -Dtests=ON
make -j$(nproc --ignore 1) install
- name: Test
Expand All @@ -173,3 +219,60 @@ jobs:
run: |
export LD_LIBRARY_PATH=${{github.workspace}}/local/lib:${{github.workspace}}/local/external/lib:${LD_LIBRARY_PATH}
ctest -C ${{env.BUILD_TYPE}} --output-on-failure
doc:
needs:
build
name: doc (${{matrix.os}}-${{matrix.cxx}}-mpi:${{matrix.mpi}}-openmp:${{matrix.omp}})
runs-on: ${{matrix.os}}
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
cc:
- gcc-12
cxx:
- g++-12
mpi:
- "OFF"
omp:
- "OFF"
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: dependencies-${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}-${{ matrix.omp }}
path: ${{github.workspace}}/local

- name: Install Dependencies on Ubunutu
if: ${{ contains(matrix.os, 'ubuntu') }}
run: |
sudo apt update
sudo apt install ccache doxygen graphviz libeigen3-dev libtiff-dev libcfitsio-dev libboost-all-dev libyaml-cpp-dev
- name: Install Dependencies on MacOS
if: ${{ contains(matrix.os, 'macos') }}
run: |
brew install gcc libtiff eigen libyaml ccache cfitsio boost yaml-cpp
echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV
echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH
- name: Build docs
run: |
export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH
mkdir -p ${{github.workspace}}/build
cd ${{github.workspace}}/build
cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddompi=OFF -Dopenmp=OFF -Ddocs=ON
make -j$(nproc --ignore 1) install
- name: Deploy to GH pages
if: ${{github.event_name == 'push'}}
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: build/cpp/docs/html # The folder the action should deploy.
78 changes: 0 additions & 78 deletions .github/workflows/documentation.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:

jobs:
linting:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

# Check code meets Google C++ style guide https://google.github.io/styleguide/cppguide.html
- name: Run linting
uses: DoozyX/clang-format-lint-action@v0.16.2
uses: DoozyX/clang-format-lint-action@v0.18.2
with:
source: '.'
extensions: 'h,cc'
Expand Down

0 comments on commit 90c0369

Please sign in to comment.