-
Notifications
You must be signed in to change notification settings - Fork 29
314 lines (267 loc) · 8.71 KB
/
build.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: CI
on: [push, pull_request]
env:
BUILD_DIR: _build
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
build: [meson, cmake, fpm]
build-type: [debug]
compiler: [gnu]
version: [10]
include:
- os: ubuntu-20.04
build: cmake
build-type: debug
compiler: gnu
version: 8
- os: macos-13
build: cmake
build-type: debug
compiler: gnu
version: 10
- os: ubuntu-latest
build: meson
build-type: coverage
compiler: gnu
version: 9
- os: macos-13
build: meson
build-type: debug
compiler: gnu
version: 10
- os: ubuntu-latest
build: meson
build-type: debug
compiler: gnu
version: 11
- os: ubuntu-20.04
build: meson
build-type: debug
compiler: intel
version: 2021.2.0
defaults:
run:
shell: ${{ matrix.shell || 'bash -l {0}' }}
env:
FC: ${{ matrix.compiler == 'intel' && 'ifort' || 'gfortran' }}
CC: ${{ matrix.compiler == 'intel' && 'icc' || 'gcc' }}
GCC_V: ${{ matrix.version }}
PYTHON_V: 3.8
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install GCC (OSX)
if: ${{ contains(matrix.os, 'macos') && matrix.compiler == 'gnu' }}
run: |
brew install gcc@${{ env.GCC_V }}
ln -s /usr/local/bin/gfortran-${{ env.GCC_V }} /usr/local/bin/gfortran
ln -s /usr/local/bin/gcc-${{ env.GCC_V }} /usr/local/bin/gcc
ln -s /usr/local/bin/g++-${{ env.GCC_V }} /usr/local/bin/g++
- name: Install GCC (Linux)
if: ${{ contains(matrix.os, 'ubuntu') && matrix.compiler == 'gnu' }}
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y gcc-${{ env.GCC_V}} gfortran-${{ env.GCC_V }}
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }}
- name: Install GCC (Windows)
if: ${{ contains(matrix.os, 'windows') && matrix.compiler == 'gnu' }}
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: >-
git
mingw-w64-x86_64-gcc-fortran
mingw-w64-x86_64-lapack
mingw-w64-x86_64-cmake
mingw-w64-x86_64-meson
mingw-w64-x86_64-ninja
- name: Install dependencies
if: ${{ ! contains(matrix.os, 'windows') }}
uses: mamba-org/setup-micromamba@v1
with:
environment-file: assets/ci/build-env.yaml
- name: Prepare for cache restore
if: ${{ matrix.compiler == 'intel' }}
run: |
sudo mkdir -p /opt/intel
sudo chown $USER /opt/intel
- name: Cache Intel install
if: ${{ matrix.compiler == 'intel' }}
id: cache-install
uses: actions/cache@v4
with:
path: /opt/intel/oneapi
key: install-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }}
- name: Install Intel
if: ${{ contains(matrix.compiler, 'intel') && steps.cache-install.outputs.cache-hit != 'true' }}
run: |
bash assets/ci/setup-intel.sh
- name: Setup Intel oneAPI environment
if: ${{ matrix.compiler == 'intel' }}
run: |
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- name: Configure build (meson)
if: ${{ matrix.build == 'meson' }}
run: >-
meson setup ${{ env.BUILD_DIR }}
--buildtype=debug
--prefix=$PWD/_dist
--libdir=lib
--warnlevel=0
-Db_coverage=${{ env.COVERAGE }}
env:
COVERAGE: ${{ matrix.build-type == 'coverage' }}
- name: Configure build (CMake)
if: ${{ matrix.build == 'cmake' }}
run: >-
cmake -B${{ env.BUILD_DIR }}
-GNinja
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
-DCMAKE_INSTALL_LIBDIR=lib
- name: Build library (fpm)
if: ${{ matrix.build == 'fpm' }}
run: fpm build
- name: Build library
if: ${{ matrix.build != 'fpm' }}
run: ninja -C ${{ env.BUILD_DIR }}
- name: Run unit tests (fpm)
if: ${{ matrix.build == 'fpm' }}
run: fpm test
- name: Run unit tests (meson)
if: ${{ matrix.build == 'meson' }}
run: >-
meson test
-C ${{ env.BUILD_DIR }}
--print-errorlogs
--no-rebuild
--num-processes 1
--suite s-dftd3
-t 2
env:
OMP_NUM_THREADS: 1,2,1
- name: Run benchmarks
if: ${{ matrix.build == 'meson' }}
run: >-
meson test
-C ${{ env.BUILD_DIR }}
--print-errorlogs
--no-rebuild
--num-processes 1
--suite s-dftd3
-t 2
--benchmark
- name: Run unit tests (ctest)
if: ${{ matrix.build == 'cmake' }}
run: |
ctest --output-on-failure --parallel 2
working-directory: ${{ env.BUILD_DIR }}
env:
OMP_NUM_THREADS: 1,2,1
- name: Create coverage report
if: ${{ matrix.build == 'meson' && matrix.build-type == 'coverage' }}
run:
ninja -C ${{ env.BUILD_DIR }} coverage
- name: Install project
if: ${{ matrix.build != 'fpm' }}
run: |
ninja -C ${{ env.BUILD_DIR }} install
echo "DFTD3_PREFIX=$PWD/_dist" >> $GITHUB_ENV
- name: Create package
if: ${{ matrix.build == 'meson' }}
run: |
tar cvf ${{ env.OUTPUT }} _dist
xz -T0 ${{ env.OUTPUT }}
echo "DFTD3_OUTPUT=${{ env.OUTPUT }}.xz" >> $GITHUB_ENV
env:
OUTPUT: s-dftd3-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }}.tar
- name: Upload package
if: ${{ matrix.build == 'meson' && matrix.build-type != 'coverage' }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.DFTD3_OUTPUT }}
path: ${{ env.DFTD3_OUTPUT }}
- name: Upload coverage report
if: ${{ matrix.build-type == 'coverage' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
python:
needs:
- build
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
gcc_v: [10]
python_v: ['3.8', '3.9', '3.10', '3.11', '3.12']
env:
FC: gfortran
CC: gcc
GCC_V: ${{ matrix.gcc_v }}
PYTHON_V: ${{ matrix.python_v }}
OMP_NUM_THREADS: 2,1
DFTD3_OUTPUT: s-dftd3-gnu-${{ matrix.gcc_v }}-${{ matrix.os }}.tar.xz
steps:
- name: Checkout code
uses: actions/checkout@v4
- run: pip3 install coverage
- name: Install dependencies
uses: mamba-org/setup-micromamba@v1
with:
environment-file: assets/ci/python-env.yaml
create-args: |
python=${{ matrix.python_v }}
- name: Install GCC (OSX)
if: ${{ contains(matrix.os, 'macos') }}
run: |
ln -s /usr/local/bin/gfortran-${{ env.GCC_V }} /usr/local/bin/gfortran
ln -s /usr/local/bin/gcc-${{ env.GCC_V }} /usr/local/bin/gcc
ln -s /usr/local/bin/g++-${{ env.GCC_V }} /usr/local/bin/g++
- name: Install GCC (Linux)
if: ${{ contains(matrix.os, 'ubuntu') }}
run: >-
sudo update-alternatives
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }}
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }}
- name: Download package
uses: actions/download-artifact@v4
with:
name: ${{ env.DFTD3_OUTPUT }}
- name: Unpack package
run: |
tar xvf ${{ env.DFTD3_OUTPUT }}
echo "DFTD3_PREFIX=$PWD/_dist" >> $GITHUB_ENV
- name: Copy parameter file
run: |
cp assets/parameters.toml python/dftd3
- name: Install Python extension module (pip)
run: pip3 install . -vv
working-directory: python
env:
PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}:${{ env.DFTD3_PREFIX }}/lib/pkgconfig
- name: Test Python API
run: pytest --pyargs dftd3 --cov=dftd3 --cov-report term --cov-report xml:coverage.xml -vv
env:
LD_LIBRARY_PATH: ${{ env.LD_LIBRARY_PATH }}:${{ env.DFTD3_PREFIX }}/lib
DYLD_LIBRARY_PATH: ${{ env.DYLD_LIBRARY_PATH }}:${{ env.DFTD3_PREFIX }}/lib
- name: Upload coverage report
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}