-
Notifications
You must be signed in to change notification settings - Fork 6
275 lines (241 loc) · 10.5 KB
/
ci.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
name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
#
# Build and test Fortuno in various system configurations
#
build-and-test:
runs-on: ${{ matrix.os }}
env:
BUILD_DIR: _build
INSTALL_DIR: _install
FPM_EXPORT_DIR: _fpm_export
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
compiler: gnu
mpi: nompi
interface: serial
- os: ubuntu-24.04
compiler: gnu
mpi: mpich
interface: mpi
- os: ubuntu-24.04
compiler: gnu
mpi: openmpi
interface: mpi
- os: ubuntu-24.04
compiler: intel
mpi: nompi
interface: serial
- os: ubuntu-24.04
compiler: intel
mpi: impi
interface: mpi
- os: ubuntu-24.04
compiler: intel
mpi: nompi
interface: coarray
- os: macos-latest
compiler: gnu
mpi: nompi
interface: serial
# MPICH on MacOS seems to lack mpi_f08 interface
# - os: macos-latest
# compiler: gnu
# mpi: mpich
# interface: mpi
- os: macos-latest
compiler: gnu
mpi: openmpi
interface: mpi
steps:
- name: Check-out code
uses: actions/checkout@v4
- name: Setup Intel compiler
if: ${{ contains(matrix.compiler, 'intel') }}
uses: rscohn2/setup-oneapi@v0
with:
# Restricting to 2024 as fpm fails to build MPI-programs with oneAPI 2025.0
components: |
- name: Setup Intel environment
if: ${{ contains(matrix.compiler, 'intel') }}
run: |
source /opt/intel/oneapi/setvars.sh
printenv >> ${GITHUB_ENV}
echo "CMAKE_FC=ifx" >> ${GITHUB_ENV}
echo "MESON_FC=ifx" >> ${GITHUB_ENV}
echo "FPM_FC=ifx" >> ${GITHUB_ENV}
# Overriding default FPM_FFLAGS as default setting contains '-standard-semantics'
# which is incompatible with intel MPI.
echo "FPM_FFLAGS='-warn all -check all,nouninit -error-limit 1 -O0 -g -stand f18 -traceback'" >> ${GITHUB_ENV}
- name: Setup GNU compiler
if: ${{ contains(matrix.compiler, 'gnu') }}
uses: fortran-lang/setup-fortran@v1
with:
compiler: gcc
version: 13
- name: Setup GNU environment
if: ${{ contains(matrix.compiler, 'gnu') }}
run: |
echo "CMAKE_FC=${{ env.FC }}" >> ${GITHUB_ENV}
if [[ ${{ matrix.interface }} == serial ]] && [[ ${{ matrix.os }} == ubuntu-* ]]; then
echo "CMAKE_FFLAGS=-Og -fsanitize=address" >> ${GITHUB_ENV}
echo "CMAKE_LDFLAGS=-fsanitize=address" >> ${GITHUB_ENV}
fi
echo "MESON_FC=${{ env.FC }}" >> ${GITHUB_ENV}
echo "MESON_FFLAGS=-ffree-line-length-none" >> ${GITHUB_ENV}
echo "FPM_FC=${{ env.FC }}" >> ${GITHUB_ENV}
echo "FPM_FFLAGS=-ffree-line-length-none" >> ${GITHUB_ENV}
- name: Setup MPICH on Ubuntu
if: ${{ contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'mpich') }}
run: |
sudo apt-get update
sudo apt-get install -y mpich
- name: Setup OpenMPI on Ubuntu
if: ${{ contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'openmpi') }}
run: |
sudo apt-get update
sudo apt-get install -y openmpi-common openmpi-bin libopenmpi-dev
echo "CMAKE_FC=mpifort" >> ${GITHUB_ENV}
echo "MPI_RUN_OPTIONS=--oversubscribe" >> ${GITHUB_ENV}
- name: Setup MPICH on MacOS
if: ${{ contains(matrix.os, 'macos') && contains(matrix.mpi, 'mpich') }}
run: |
brew install mpich
- name: Setup OpenMPI on MacOS
if: ${{ contains(matrix.os, 'macos') && contains(matrix.mpi, 'openmpi') }}
run: |
brew install openmpi
echo "MPI_RUN_OPTIONS=--oversubscribe" >> ${GITHUB_ENV}
- name: Setup serial interface options
if: ${{ contains(matrix.interface, 'serial') }}
run: |
echo "CMAKE_OPTIONS=-DFORTUNO_WITH_SERIAL=ON" >> ${GITHUB_ENV}
echo "MESON_OPTIONS_NOFALLBACK=" >> ${GITHUB_ENV}
echo "MESON_OPTIONS_FALLBACK=-Dfortuno:with_serial=true" >> ${GITHUB_ENV}
echo "INTERFACE=serial" >> ${GITHUB_ENV}
echo "RUN_PREFIX=" >> ${GITHUB_ENV}
- name: Setup mpi interface options
if: ${{ contains(matrix.interface, 'mpi') }}
run: |
echo "CMAKE_OPTIONS=-DFORTUNO_WITH_MPI=ON" >> ${GITHUB_ENV}
echo "MESON_OPTIONS_NOFALLBACK=" >> ${GITHUB_ENV}
echo "MESON_OPTIONS_FALLBACK=-Dfortuno:with_mpi=true" >> ${GITHUB_ENV}
echo "INTERFACE=mpi" >> ${GITHUB_ENV}
echo "RUN_PREFIX=mpirun -n 2 ${MPI_RUN_OPTIONS}" >> ${GITHUB_ENV}
- name: Setup coarray interface options
if: ${{ contains(matrix.interface, 'coarray') }}
run: |
echo "CMAKE_OPTIONS=-DFORTUNO_WITH_COARRAY=ON -DFORTUNO_FFLAGS_COARRAY='-coarray' -DFORTUNO_LDFLAGS_COARRAY='-coarray'" >> ${GITHUB_ENV}
echo "MESON_OPTIONS_NOFALLBACK=-Dfflags_coarray=-coarray -Dldflags_coarray=-coarray" >> ${GITHUB_ENV}
echo "MESON_OPTIONS_FALLBACK=-Dfflags_coarray=-coarray -Dldflags_coarray=-coarray -Dfortuno:with_coarray=true -Dfortuno:fflags_coarray=-coarray -Dfortuno:ldflags_coarray=-coarray" >> ${GITHUB_ENV}
echo "FPM_FFLAGS=${FPM_FFLAGS} -coarray" >> ${GITHUB_ENV}
echo "FPM_LDFLAGS=${FPM_LDFLAGS} -coarray" >> ${GITHUB_ENV}
echo "INTERFACE=coarray" >> ${GITHUB_ENV}
echo "RUN_PREFIX=" >> ${GITHUB_ENV}
- name: Setup build tools
run: |
pip install cmake fpm meson ninja fypp
- name: Build Fortuno
run: |
FC=${CMAKE_FC} FFLAGS=${CMAKE_FFLAGS} cmake ${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -B ${BUILD_DIR} -G Ninja
cmake --build ${BUILD_DIR} --verbose
cmake --install ${BUILD_DIR} --verbose
ctest --test-dir ${BUILD_DIR} --verbose
rm -rf ${BUILD_DIR}
- name: Test CMake export
run: |
CMAKE_PREFIX_PATH=${INSTALL_DIR} FC=${CMAKE_FC} FFLAGS=${CMAKE_FFLAGS} cmake -B ${BUILD_DIR} -G Ninja test/export/${INTERFACE}
cmake --build ${BUILD_DIR}
${RUN_PREFIX} ${BUILD_DIR}/app/testapp
${RUN_PREFIX} ${BUILD_DIR}/app/testapp_fpp
${RUN_PREFIX} ${BUILD_DIR}/app/testapp_fypp
rm -rf ${BUILD_DIR}
- name: Test fpm export
run: |
./devel/fpm-repo/export-fpm-repo.sh ${INTERFACE} ${FPM_EXPORT_DIR}
FPM_FC=${FPM_FC} FPM_FFLAGS=${FPM_FFLAGS} fpm run -C ${FPM_EXPORT_DIR}/test/export/${INTERFACE} --runner "${RUN_PREFIX}" testapp testapp_fpp
rm -rf ${FPM_EXPORT_DIR}
- name: Test Meson pkgconfig export
# Meson only detects OpenMPI reliably (as of version 1.5.2)
if: ${{ !contains(matrix.interface, 'mpi') || contains(matrix.mpi, 'openmpi') }}
run: |
export PKG_CONFIG_PATH="${PWD}/${INSTALL_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH}"
cd test/export/${INTERFACE}
FC=${MESON_FC} FFLAGS=${MESON_FFLAGS} meson setup ${MESON_OPTIONS_NOFALLBACK} --wrap-mode nofallback ${BUILD_DIR}
ninja -j1 -v -C ${BUILD_DIR}
${RUN_PREFIX} ${BUILD_DIR}/testapp
${RUN_PREFIX} ${BUILD_DIR}/testapp_fpp
rm -rf ./${BUILD_DIR}
- name: Test Meson subproject export
# Meson only detects OpenMPI reliably (as of version 1.5.2)
if: ${{ !contains(matrix.interface, 'mpi') || contains(matrix.mpi, 'openmpi') }}
run: |
FORTUNO_DIR=${PWD}
GIT_REV=$(git rev-parse HEAD)
cd test/export/${INTERFACE}
mkdir subprojects
echo -e "[wrap-git]\ndirectory=fortuno\n" > subprojects/fortuno.wrap
echo -e "url=file://${FORTUNO_DIR}\nrevision=${GIT_REV}\n" >> subprojects/fortuno.wrap
FC=${MESON_FC} FFLAGS=${MESON_FFLAGS} meson setup ${MESON_OPTIONS_FALLBACK} --wrap-mode forcefallback ${BUILD_DIR}
ninja -j1 -v -C ${BUILD_DIR}
${RUN_PREFIX} ${BUILD_DIR}/testapp
${RUN_PREFIX} ${BUILD_DIR}/testapp_fpp
rm -rf subprojects ${BUILD_DIR}
deploy-fpm-repos:
needs: build-and-test
if: github.repository == 'fortuno-repos/fortuno' && github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
env:
DEPLOYMENT_KEY_PREFIX: DEPLOY_KEY
DEPLOYMENT_TARGET_REPO_PREFIX: fortuno-fpm
steps:
- name: Check-out code
uses: actions/checkout@v4
- name: Export serial repository content
run: ./devel/fpm-repo/export-fpm-repo.sh serial _fpm_serial
- name: Push to serial repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets[format('{0}_FORTUNO_FPM_SERIAL', env.DEPLOYMENT_KEY_PREFIX)] }}
with:
source-directory: _fpm_serial
destination-github-username: fortuno-repos
destination-repository-name: ${{ format('{0}-serial', env.DEPLOYMENT_TARGET_REPO_PREFIX) }}
user-email: [email protected]
target-branch: main
- name: Export mpi repository content
run: ./devel/fpm-repo/export-fpm-repo.sh mpi _fpm_mpi
- name: Push to mpi repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets[format('{0}_FORTUNO_FPM_MPI', env.DEPLOYMENT_KEY_PREFIX)] }}
with:
source-directory: _fpm_mpi
destination-github-username: fortuno-repos
destination-repository-name: ${{ format('{0}-mpi', env.DEPLOYMENT_TARGET_REPO_PREFIX) }}
user-email: [email protected]
target-branch: main
- name: Export coarray repository content
run: ./devel/fpm-repo/export-fpm-repo.sh coarray _fpm_coarray
- name: Push to coarray repository
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets[format('{0}_FORTUNO_FPM_COARRAY', env.DEPLOYMENT_KEY_PREFIX)] }}
with:
source-directory: _fpm_coarray
destination-github-username: fortuno-repos
destination-repository-name: ${{ format('{0}-coarray', env.DEPLOYMENT_TARGET_REPO_PREFIX) }}
user-email: [email protected]
target-branch: main