Skip to content

Commit 0fd3361

Browse files
committed
Add ci workflow with build, test and doc jobs
1 parent 4c50839 commit 0fd3361

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed

.github/workflows/ci.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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+
# The CMake configure and build commands are platform agnostic and should work equally
26+
# well on Windows or Mac. You can convert this to a matrix build if you need
27+
# cross-platform coverage.
28+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
29+
runs-on: ${{matrix.os}}
30+
env:
31+
CC: ${{ matrix.cc }}
32+
CXX: ${{ matrix.cxx }}
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
os:
37+
- ubuntu-22.04
38+
cc:
39+
- gcc-12
40+
cxx:
41+
- g++-12
42+
mpi:
43+
- "ON"
44+
omp:
45+
- "ON"
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
# Enable tmate debugging of manually-triggered workflows if the input option was provided
51+
- name: Setup tmate session
52+
uses: mxschmitt/action-tmate@v3
53+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
54+
55+
- name: Prepare ccache timestamp
56+
id: ccache_cache_timestamp
57+
run: echo "{date_and_time}={$(date +'%Y-%m-%d-%H;%M;%S')}" >> $GITHUB_OUTPUT
58+
- name: Set ccache cache directory
59+
shell: bash
60+
run: echo "CCACHE_DIR=${{runner.workspace}}/.ccache" >> "${GITHUB_ENV}"
61+
- name: Cache ccache files
62+
uses: actions/cache@v3
63+
with:
64+
path: ${{runner.workspace}}/.ccache
65+
key: ${{matrix.os}}-${{matrix.cxx}}-${{matrix.mpi}}-${{matrix.omp}}-${{ steps.ccache_cache_timestamp.outputs.date_and_time }}
66+
restore-keys: |
67+
${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}-${{ matrix.omp }}
68+
${{ matrix.os }}-${{ matrix.cxx }}-${{ matrix.mpi }}
69+
${{ matrix.os }}-${{ matrix.cxx }}
70+
${{ matrix.os }}
71+
72+
# - name: Clear ccache
73+
# run: ccache --clear
74+
75+
- name: Install Dependencies on Ubunutu
76+
if: ${{ contains(matrix.os, 'ubuntu') }}
77+
run: |
78+
sudo apt update
79+
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
80+
81+
- name: Install Dependencies on MacOS
82+
if: ${{ contains(matrix.os, 'macos') }}
83+
run: |
84+
brew install gcc libtiff open-mpi libomp eigen libyaml ccache cfitsio boost yaml-cpp
85+
echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp" >> $GITHUB_ENV
86+
echo "/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH
87+
88+
- name: Checkout Catch2
89+
uses: actions/checkout@v4
90+
with:
91+
repository: catchorg/Catch2.git
92+
path: Catch2
93+
ref: v3.4.0
94+
95+
- name: Build Catch2
96+
run: |
97+
mkdir Catch2/build
98+
cd Catch2/build
99+
cmake .. -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local
100+
make -j$(nproc --ignore 1) install
101+
102+
- name: Install FFTW
103+
run: |
104+
wget --no-check-certificate --no-verbose http://www.fftw.org/fftw-3.3.10.tar.gz -O- | tar --no-same-owner -xz;
105+
cd fftw-3.3.10
106+
./configure --prefix=${{github.workspace}}/local --enable-shared
107+
make -j$(nproc --ignore 1) install CFLAGS=-fPIC
108+
# Fix bug in FFT3 (cf. https://github.com/FFTW/fftw3/issues/332)
109+
sed -i -e 's/^.*FFTW3LibraryDepends.cmake.*$//1' ${{github.workspace}}/local/lib*/cmake/*/FFTW3Config.cmake
110+
111+
- name: Checkout SOPT
112+
uses: actions/checkout@v4
113+
with:
114+
repository: astro-informatics/sopt.git
115+
path: sopt
116+
ref: development
117+
118+
- name: Build sopt
119+
run: |
120+
export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH
121+
mkdir -p ${{github.workspace}}/sopt/build
122+
cd ${{github.workspace}}/sopt/build
123+
cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}} -Dtests=OFF -Dexamples=OFF
124+
make -j$(nproc --ignore 1) install
125+
126+
127+
test:
128+
needs:
129+
build
130+
steps:
131+
- name: Build tests
132+
# Build your program with the given configuration
133+
run: |
134+
export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH
135+
mkdir -p ${{github.workspace}}/build
136+
cd ${{github.workspace}}/build
137+
cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddocasa=OFF -Ddompi=${{matrix.mpi}} -Dopenmp=${{matrix.omp}} -Dtests=ON
138+
make -j$(nproc --ignore 1) install
139+
140+
- name: Test
141+
working-directory: ${{github.workspace}}/build
142+
# Execute tests defined by the CMake configuration.
143+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
144+
run: |
145+
export LD_LIBRARY_PATH=${{github.workspace}}/local/lib:${{github.workspace}}/local/external/lib:${LD_LIBRARY_PATH}
146+
ctest -C ${{env.BUILD_TYPE}} --output-on-failure
147+
148+
doc:
149+
needs:
150+
build
151+
steps:
152+
- name: Build docs
153+
run: |
154+
export CMAKE_PREFIX_PATH=${{github.workspace}}/local:$CMAKE_PREFIX_PATH
155+
mkdir -p ${{github.workspace}}/build
156+
cd ${{github.workspace}}/build
157+
cmake .. --fresh -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -Ddompi=OFF -Dopenmp=OFF -Ddocs=ON
158+
make -j$(nproc --ignore 1) install
159+
160+
- name: Deploy to GH pages
161+
if: ${{github.event_name == 'push'}}
162+
uses: JamesIves/github-pages-deploy-action@4.1.6
163+
with:
164+
branch: gh-pages # The branch the action should deploy to.
165+
folder: build/cpp/docs/html # The folder the action should deploy.
166+

0 commit comments

Comments
 (0)