251 lines (242 loc) · 9.87 KB
/
build_check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Build and Check
on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'
jobs:
build-gcc-ubuntu:
name: (ubuntu, apt)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pre-requisites
run: |
sudo apt-get update
sudo apt-get install gobject-introspection gir1.2-glib-2.0 libgirepository1.0-dev gcc gfortran pkg-config libglib2.0-dev libgmp3-dev libmpfr-dev libgsl0-dev libfftw3-dev libopenblas-dev libflint-arb-dev libcfitsio-dev libfyaml-dev libnlopt-dev libhdf5-dev gtk-doc-tools libopenmpi-dev
sudo pip install meson ninja pytest pytest-tap numpy
- name: Ensure clear Jupyter Notebooks
uses: ResearchSoftwareActions/EnsureCleanNotebooksAction@1.1
- name: Configure NumCosmo
run: meson setup build -Dbuildtype=release -Dnumcosmo_py=true -Dgtkdoc=disabled --prefix=/usr || (cat build/meson-logs/meson-log.txt && exit 1)
- name: Building NumCosmo
run: meson compile -C build
- name: Test python examples
run: |
source build/numcosmo_export.sh
cd examples
python example_simple.py
python example_cbe.py
- name: Test example compilation using non-installed library
run: |
source build/numcosmo_export.sh
cd examples
gcc -D_GNU_SOURCE -Wall example_simple.c -o example_simple -lnumcosmo -lgsl -lm $(pkg-config glib-2.0 gobject-2.0 --libs --cflags)
gcc -D_GNU_SOURCE -Wall example_ca.c -o example_ca -lnumcosmo -lgsl -lm $(pkg-config glib-2.0 gobject-2.0 --libs --cflags)
./example_simple
./example_ca
- name: Check NumCosmo
run: meson test -C build || (cat build/meson-logs/testlog.txt && exit 1)
- name: Create a NumCosmo tarball
run: meson dist -C build --no-tests
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2
with:
name: release
path: build/meson-dist/numcosmo-*.tar.xz
- name: Test example compilation using installed library
run: |
sudo meson install -C build
cd examples
gcc -D_GNU_SOURCE -Wall example_simple.c -o example_simple $(pkg-config numcosmo --libs --cflags)
gcc -D_GNU_SOURCE -Wall example_ca.c -o example_ca $(pkg-config numcosmo --libs --cflags)
./example_simple
./example_ca
build-gcc-macos:
name: (macos, brew)
runs-on: macos-latest
env:
CC: gcc-11
FC: gfortran-11
F77: gfortran-11
F90: gfortran-11
LIBRARY_PATH: /usr/local/lib
LD_LIBRARY_PATH: /usr/local/lib
DYLD_LIBRARY_PATH: /usr/local/lib
CPATH: /usr/local/include
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Brew install pre-requisites
run: |
brew install gobject-introspection gsl gmp mpfr fftw cfitsio libfyaml nlopt gfortran gtk-doc glib openblas
- name: Pip install pre-requisites
run: |
pip3 install meson ninja pytest pytest-tap numpy pygobject
- name: Ensure clear Jupyter Notebooks
uses: ResearchSoftwareActions/EnsureCleanNotebooksAction@1.1
- name: Configure NumCosmo
run: |
meson setup build -Dbuildtype=release -Dnumcosmo_py=true -Dmpi=disabled --prefix=/usr || (cat build/meson-logs/meson-log.txt && exit 1)
- name: Building NumCosmo
run: |
meson compile -C build
- name: Test python examples
run: |
source build/numcosmo_export.sh
cd examples
python example_simple.py
python example_cbe.py
- name: Check NumCosmo
run: meson test -C build || (cat build/meson-logs/testlog.txt && exit 1)
build-miniforge:
name: (${{ matrix.os }}, py${{ matrix.python-version }}, ${{ matrix.mpi }}, Miniforge)
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: ["ubuntu", "macos"]
python-version: ["3.10"]
mpi: ["openmpi", "mpich"]
exclude:
- os: "macos"
mpi: "openmpi"
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v3
- name: Setup miniforge
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
activate-environment: numcosmo_developer
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
show-channel-urls: true
use-mamba: true
- name: Cache date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
- name: Cache Conda env
uses: actions/cache@v3
with:
path: ${{ env.CONDA }}/envs
key: miniforge-${{ runner.os }}--${{ runner.arch }}--python-${{ matrix.python-version }}--${{ matrix.mpi }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('devel_environment.yml') }}-${{ env.CACHE_NUMBER }}
env:
CACHE_NUMBER: 0
id: cache
- name: Update environment
run: |
mamba env update -q -v -n numcosmo_developer -f devel_environment.yml
mamba remove -q -v -n numcosmo_developer openmpi
mamba install -q -v -n numcosmo_developer ${{ matrix.mpi }}
if: steps.cache.outputs.cache-hit != 'true'
- name: Setting up NumCosmo
run: |
conda activate numcosmo_developer
[[ -e $GCC_AR ]] && AR=$GCC_AR
[[ -e $GCC_NM ]] && NM=$GCC_NM
[[ -e $GCC_RANLIB ]] && RANLIB=$GCC_RANLIB
meson setup build -Dbuildtype=release -Dnumcosmo_py=true --libdir=$CONDA_PREFIX/lib --prefix=$CONDA_PREFIX || (cat build/meson-logs/meson-log.txt && exit 1)
- name: Building NumCosmo
run: |
meson compile -C build
- name: Installing NumCosmo
run: |
meson install -C build
cd examples
python example_simple.py
python example_cbe.py
- name: Running black check
run: |
black --check numcosmo_py
- name: Running flake8
run: |
flake8 numcosmo_py
- name: Running mypy
run: |
mypy -p numcosmo_py
#- name: Running pylint
# run: |
# pylint --rcfile .pylintrc numcosmo_py
- name: Check NumCosmo
run: meson test -C build || (cat build/meson-logs/testlog.txt && exit 1)
build-miniforge-coverage:
name: Coverage (${{ matrix.os }}, py${{ matrix.python-version }}, openmpi, Miniforge)
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: ["ubuntu"]
python-version: ["3.10"]
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v3
- name: Setup miniforge
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
activate-environment: numcosmo_developer
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
show-channel-urls: true
use-mamba: true
- name: Cache date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
- name: Cache Conda env
uses: actions/cache@v3
with:
path: ${{ env.CONDA }}/envs
key: coverage-miniforge-${{ runner.os }}--${{ runner.arch }}--python-${{ matrix.python-version }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('devel_environment.yml') }}-${{ env.CACHE_NUMBER }}
env:
CACHE_NUMBER: 0
id: cache
- name: Update environment
run: |
conda env update -q -v -n numcosmo_developer -f devel_environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Setting up NumCosmo
run: |
conda activate numcosmo_developer
[[ -e $GCC_AR ]] && AR=$GCC_AR
[[ -e $GCC_NM ]] && NM=$GCC_NM
[[ -e $GCC_RANLIB ]] && RANLIB=$GCC_RANLIB
meson setup build -Dbuildtype=debug -Db_coverage=true -Db_lto=false -Dnumcosmo_py=true --libdir=$CONDA_PREFIX/lib --prefix=$CONDA_PREFIX || (cat build/meson-logs/meson-log.txt && exit 1)
- name: Building NumCosmo
run: |
meson compile -C build
- name: Check and coverage
# First run to generate the coverage base
# Second run to generate the coverage for the tests
# Third run to merge the coverage base and the coverage for the tests
run: |
lcov --config-file .lcovrc --no-external --capture --initial --directory build --directory numcosmo --directory tests --base-directory $(pwd)/build --output-file numcosmo-coverage-base.info
meson test -C build --timeout-multiplier 0 || (cat build/meson-logs/testlog.txt && exit 1)
lcov --config-file .lcovrc --no-external --capture --directory build --directory numcosmo --directory tests --base-directory $(pwd)/build --output-file numcosmo-coverage-tests.info
lcov --config-file .lcovrc --add-tracefile numcosmo-coverage-base.info --add-tracefile numcosmo-coverage-tests.info --output-file numcosmo-coverage-full.info
lcov --config-file .lcovrc --remove numcosmo-coverage-full.info '*/class/*' '*/levmar/*' '*/libcuba/*' '*/plc/*' '*/sundials/*' '*/toeplitz/*' '*/tools/*' --output-file numcosmo-coverage.info
- name: CodeCov
uses: codecov/codecov-action@v4
with:
disable_search: true
fail_ci_if_error: true
files: ./numcosmo-coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
#- name: Generate coverage
# # For some reason, gcovr is ignoring the configured gcovr.cfg file
# # ninja coverage -C build -v -d stats -d explain
# run: |
# gcovr --root . --object-directory build --config gcovr.cfg --xml-pretty -o build/meson-logs/coverage.xml
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
files: ./numcosmo-coverage.info
format: lcov
github-token: ${{ secrets.GITHUB_TOKEN }}