Debian Codegraph @

.github/workflows/meta.yml

raw
1 name: metapackage-tests
2
3 on:
4 # On push, only run if any of the metapackage files has changed
5 push:
6 paths:
7 - 'src/*meta*.f90'
8 - 'src/fpm/*meta*.f90'
9 - 'src/fpm/manifest/*meta*.f90'
10 - 'src/ci/meta_tests.sh'
11 - 'src/.github/workflows/meta.yml'
12 # Always run on PR or release
13 pull_request:
14 release:
15 types: [published]
16 # Allow manual triggering
17 workflow_dispatch:
18
19 env:
20 CI: "ON" # We can detect this in the build system and other vendors implement it
21 HOMEBREW_NO_ANALYTICS: 1 # Make Homebrew installation a little quicker
22 HOMEBREW_NO_AUTO_UPDATE: 1
23 HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1
24 HOMEBREW_NO_GITHUB_API: 1
25 HOMEBREW_NO_INSTALL_CLEANUP: 1
26 HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
27
28 jobs:
29
30 build:
31 runs-on: ${{ matrix.os }}
32 strategy:
33 fail-fast: false
34 matrix:
35 include:
36 - os: ubuntu-latest
37 mpi: openmpi
38 release-flags: --flag ' -Wno-external-argument-mismatch'
39 - os: ubuntu-latest
40 mpi: mpich
41 release-flags: --flag ' -Wno-external-argument-mismatch'
42 - os: macos-14
43 mpi: openmpi
44 release-flags: --flag ' -Wno-external-argument-mismatch'
45 - os: macos-14
46 mpi: mpich
47 release-flags: --flag ' -Wno-external-argument-mismatch'
48 - os: ubuntu-latest
49 mpi: intel
50 intel_version: "2024.1.0"
51 release-flags: "" # override: no GCC flags
52 - os: ubuntu-latest
53 mpi: intel
54 intel_version: "2025.0"
55 release-flags: "" # override: no GCC flags
56
57 steps:
58 - name: Checkout code
59 uses: actions/checkout@v6
60
61 - name: (Ubuntu) setup gcc version
62 if: contains(matrix.os,'ubuntu')
63 run: |
64 echo "GCC_V=14" >> $GITHUB_ENV
65
66 - name: (macOS) setup gcc version
67 if: contains(matrix.os,'macos')
68 run: |
69 echo "GCC_V=15" >> $GITHUB_ENV
70
71 - name: (Windows) Install MSYS2
72 uses: msys2/setup-msys2@v2
73 if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi')
74 with:
75 msystem: MINGW64
76 update: true
77 install: >-
78 git
79 base-devel
80 wget
81 unzip
82 curl
83 hdf5
84 netcdf
85 netcdf-fortran
86
87 - name: (Ubuntu) Install gfortran
88 if: contains(matrix.os,'ubuntu')
89 run: |
90 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
91 --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
92 --slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
93
94 - name: (Ubuntu) Install OpenMPI
95 if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'openmpi')
96 run: |
97 sudo apt-get update
98 sudo apt install -y -q openmpi-bin libopenmpi-dev hwloc fabric libhdf5-dev \
99 libhdf5-fortran-102 libnetcdf-dev libnetcdff-dev libopenblas-dev
100
101 - name: (Ubuntu) Install MPICH
102 if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'mpich')
103 run: |
104 sudo apt-get update
105 sudo apt install -y -q mpich hwloc fabric libhdf5-dev libhdf5-fortran-102 \
106 libnetcdf-dev libnetcdff-dev libopenblas-dev
107
108 # Intel
109 - name: Setup Intel Environment
110 if: contains(matrix.mpi, 'intel')
111 uses: ./.github/actions/setup-intel
112 with:
113 os: ${{ matrix.os }}
114 version: ${{ matrix.intel_version }}
115
116 - name: (Ubuntu) Build and Install HDF5 from source
117 if: contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'intel')
118 # Needs checkout if source code isn't available, adjust if needed
119 # Ensure compilers are available from the previous step's environment setup
120 shell: bash
121 run: |
122 # Source again just in case shell context is lost (shouldn't be, but safer)
123 source /opt/intel/oneapi/setvars.sh --force
124 # Download HDF5
125 curl -O -L https://github.com/HDFGroup/hdf5/archive/refs/tags/snapshot-1.14.tar.gz
126 tar zxf snapshot-1.14.tar.gz
127 cd hdf5-snapshot-1.14
128 # Configure HDF5 with Intel compilers
129 cmake -B build -DCMAKE_Fortran_COMPILER=ifx -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DHDF5_BUILD_FORTRAN=ON -DCMAKE_INSTALL_PREFIX=/usr
130 cd build
131 make -j $(nproc)
132 sudo make install
133 cd ../.. # Go back to workspace directory
134 rm -rf hdf5-snapshot-1.14 snapshot-1.14.tar.gz # Clean up
135
136 - name: (Ubuntu) Build and Install NetCDF-C from source
137 if: contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'intel')
138 shell: bash
139 run: |
140 source /opt/intel/oneapi/setvars.sh --force
141 # Download NetCDF-C
142 curl -L https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz -o - | tar xz
143 cd netcdf-c-4.9.2
144 # Configure NetCDF-C with Intel Compilers, referencing installed HDF5
145 # Set CC/CXX/FC explicitly in environment for configure script
146 export CC=icx CXX=icpx FC=ifx
147 ./configure --prefix=/usr --enable-netcdf-4 --with-hdf5=/usr
148 make -j $(nproc)
149 sudo make install
150 cd .. # Go back to workspace directory
151 rm -rf netcdf-c-4.9.2 # Clean up
152
153 - name: (Ubuntu) Build and Install NetCDF-Fortran from source
154 if: contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'intel')
155 shell: bash
156 run: |
157 source /opt/intel/oneapi/setvars.sh --force
158 # Download NetCDF-Fortran
159 curl -L https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz -o - | tar xz
160 cd netcdf-fortran-4.6.1
161 # Configure NetCDF-Fortran with Intel Compilers using CMake
162 cmake -B build -DCMAKE_Fortran_COMPILER=ifx -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DCMAKE_INSTALL_PREFIX=/usr
163 cd build
164 make -j $(nproc)
165 sudo make install
166 cd ../.. # Go back to workspace directory
167 rm -rf netcdf-fortran-4.6.1 # Clean up
168
169 - name: (Windows) Put MSYS2_MinGW64 on PATH
170 if: contains(matrix.os,'windows') && (!contains(matrix.mpi,'intel'))
171 # there is not yet an environment variable for this path from msys2/setup-msys2
172 run: echo "${{ runner.temp }}/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
173
174 - name: (Windows) download MS-MPI setup (SDK is from MSYS2)
175 if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi')
176 # run: curl -L -O https://github.com/microsoft/Microsoft-MPI/releases/download/v10.1.2/msmpisetup.exe 10.1.1
177 run: curl -L -O https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisetup.exe # 10.1.2
178
179 - name: (Windows) Install mpiexec.exe (-force needed to bypass GUI on headless)
180 if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi')
181 run: .\msmpisetup.exe -unattend -force
182
183 - name: (Windows) test that mpiexec.exe exists
184 if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi')
185 # can't use MSMPI_BIN as Actions doesn't update PATH from msmpisetup.exe
186 run: Test-Path "C:\Program Files\Microsoft MPI\Bin\mpiexec.exe" -PathType leaf
187
188 - name: (Windows) put MSMPI_BIN on PATH (where mpiexec is)
189 if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi')
190 run: |
191 echo "C:\Program Files\Microsoft MPI\Bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
192 echo "/c/Program Files/Microsoft MPI/Bin/" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
193 echo "MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\" | Out-File -FilePath $env:GITHUB_ENV -Append
194
195 - name: (Windows) Install MSYS2 msmpi package
196 if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi')
197 shell: msys2 {0}
198 run: pacman --noconfirm -S mingw-w64-x86_64-msmpi
199
200 - name: (macOS) Set up Homebrew
201 if: contains(matrix.os,'macos')
202 id: set-up-homebrew
203 uses: Homebrew/actions/setup-homebrew@master
204
205 - name: (macOS) Install Homebrew gfortran
206 if: contains(matrix.os, 'macos')
207 run: |
208 # Only install gcc if not already available
209 which gfortran-${{ env.GCC_V }} || brew install gcc@${{ env.GCC_V }}
210 which gfortran-${{ env.GCC_V }}
211 BREW_PREFIX=$(brew --prefix)
212 which gfortran || ln -s ${BREW_PREFIX}/bin/gfortran-${{ env.GCC_V }} ${BREW_PREFIX}/bin/gfortran
213
214 - name: (macOS) Install homebrew MPICH
215 if: contains(matrix.mpi,'mpich') && contains(matrix.os,'macos')
216 run: |
217 brew install mpich
218
219 - name: (macOS) Install homebrew OpenMPI
220 if: contains(matrix.mpi,'openmpi') && contains(matrix.os,'macos')
221 run: |
222 brew install openmpi
223
224 - name: (macOS) Install homebrew HDF5
225 if: contains(matrix.os,'macos')
226 run: |
227 brew install hdf5
228
229 - name: (macOS) Install homebrew NetCDF
230 if: contains(matrix.os,'macos')
231 run: |
232 brew install netcdf
233 brew install netcdf-fortran
234
235 # Phase 1: Bootstrap fpm with existing version
236 - name: Install fpm
237 uses: fortran-lang/setup-fpm@v9
238 with:
239 fpm-version: 'v0.12.0'
240
241 # Backport gfortran shared libraries to the paths expected by the bootstrap fpm binary.
242 # The macOS x86_64 release used for bootstrapping has hardcoded library paths from the gcc version
243 # it was built with. If the versions match, skip this step. Otherwise, create symlinks.
244 # On ARM64 it runs under Rosetta 2 and needs /usr/local paths.
245 - name: MacOS patch libgfortran
246 if: contains(matrix.os, 'macos')
247 run: |
248 which gfortran-${{ env.GCC_V }}
249 which gfortran || true
250 BREW_PREFIX=$(brew --prefix)
251
252 # Query the actual library paths that fpm expects
253 echo "Checking library dependencies of fpm bootstrap binary..."
254 otool -L $(which fpm)
255
256 # Extract the gcc version from the bootstrap binary's library paths
257 BOOTSTRAP_GCC_VERSION=$(otool -L $(which fpm) | grep -o 'gcc@[0-9]\+' | head -n 1 | cut -d@ -f2)
258 if [ -z "$BOOTSTRAP_GCC_VERSION" ]; then
259 # Try alternative pattern: /lib/gcc/13/ -> extract 13
260 BOOTSTRAP_GCC_VERSION=$(otool -L $(which fpm) | grep libgfortran | grep -o '/lib/gcc/[0-9]\+/' | grep -o '[0-9]\+' | head -n 1)
261 fi
262
263 echo "Bootstrap fpm built with gcc@$BOOTSTRAP_GCC_VERSION"
264 echo "Current toolchain: gcc@${{ env.GCC_V }}"
265
266 if [ "$BOOTSTRAP_GCC_VERSION" == "${{ env.GCC_V }}" ]; then
267 echo "✓ Bootstrap gcc version matches current toolchain - no patching needed"
268 exit 0
269 fi
270
271 echo "⚠ Version mismatch detected - creating compatibility symlinks..."
272
273 # Find the actual Cellar path by following the symlink
274 if [ -L "${BREW_PREFIX}/opt/gcc@${{ env.GCC_V }}" ]; then
275 GCC_CELLAR_PATH=$(cd -P "${BREW_PREFIX}/opt/gcc@${{ env.GCC_V }}" && pwd)
276 else
277 GCC_CELLAR_PATH="${BREW_PREFIX}/Cellar/gcc@${{ env.GCC_V }}"/*
278 fi
279 echo "GCC Cellar path: $GCC_CELLAR_PATH"
280
281 # Find the actual library files
282 CURRENT_GFORTRAN=$(find "$GCC_CELLAR_PATH"/lib/gcc/${{ env.GCC_V }} -name "libgfortran.*.dylib" 2>/dev/null | head -n 1)
283 CURRENT_QUADMATH=$(find "$GCC_CELLAR_PATH"/lib/gcc/${{ env.GCC_V }} -name "libquadmath.*.dylib" 2>/dev/null | head -n 1)
284 CURRENT_GCC_S=$(find "$GCC_CELLAR_PATH"/lib/gcc/${{ env.GCC_V }} -name "libgcc_s.*.dylib" 2>/dev/null | head -n 1)
285
286 echo "Current gcc@${{ env.GCC_V }} libraries:"
287 echo " libgfortran: $CURRENT_GFORTRAN"
288 echo " libquadmath: $CURRENT_QUADMATH"
289 echo " libgcc_s: $CURRENT_GCC_S"
290
291 # Extract the expected libgfortran path and create symlink
292 LIBGFORTRAN_PATH=$(otool -L $(which fpm) | grep libgfortran | awk '{print $1}' | head -n 1)
293 if [ -n "$LIBGFORTRAN_PATH" ] && [ -n "$CURRENT_GFORTRAN" ]; then
294 TARGET_DIR=$(dirname "$LIBGFORTRAN_PATH")
295 echo "Creating directory: $TARGET_DIR"
296 sudo mkdir -p "$TARGET_DIR"
297 echo "Linking $CURRENT_GFORTRAN to $LIBGFORTRAN_PATH"
298 sudo ln -fs "$CURRENT_GFORTRAN" "$LIBGFORTRAN_PATH"
299 fi
300
301 # Extract the expected libquadmath path and create symlink
302 LIBQUADMATH_PATH=$(otool -L $(which fpm) | grep libquadmath | awk '{print $1}' | head -n 1)
303 if [ -n "$LIBQUADMATH_PATH" ] && [ -n "$CURRENT_QUADMATH" ]; then
304 TARGET_DIR=$(dirname "$LIBQUADMATH_PATH")
305 echo "Creating directory: $TARGET_DIR"
306 sudo mkdir -p "$TARGET_DIR"
307 echo "Linking $CURRENT_QUADMATH to $LIBQUADMATH_PATH"
308 sudo ln -fs "$CURRENT_QUADMATH" "$LIBQUADMATH_PATH"
309 fi
310
311 # Extract the expected libgcc_s path and create symlink
312 LIBGCC_PATH=$(otool -L $(which fpm) | grep libgcc_s | awk '{print $1}' | head -n 1)
313 if [ -n "$LIBGCC_PATH" ] && [ -n "$CURRENT_GCC_S" ]; then
314 TARGET_DIR=$(dirname "$LIBGCC_PATH")
315 echo "Creating directory: $TARGET_DIR"
316 sudo mkdir -p "$TARGET_DIR"
317 echo "Linking $CURRENT_GCC_S to $LIBGCC_PATH"
318 sudo ln -fs "$CURRENT_GCC_S" "$LIBGCC_PATH"
319 fi
320
321 - name: Remove fpm from path
322 shell: bash
323 run: |
324 mv $(which fpm) fpm-bootstrap${{ matrix.exe }}
325 echo "BOOTSTRAP=$PWD/fpm-bootstrap" >> $GITHUB_ENV
326
327 - name: (macOS/Ubuntu) Use gcc/g++ instead of Clang for C/C++ / ifx to build fpm
328 if: contains(matrix.os,'macOS') || contains(matrix.os,'ubuntu')
329 shell: bash
330 run: |
331 echo "FPM_FC=gfortran-${{ env.GCC_V }}" >> $GITHUB_ENV
332 echo "FPM_CC=gcc-${{ env.GCC_V }}" >> $GITHUB_ENV
333 echo "FPM_CXX=g++-${{ env.GCC_V }}" >> $GITHUB_ENV
334
335 - name: Build Fortran fpm (bootstrap)
336 shell: bash
337 run: |
338 ${{ env.BOOTSTRAP }} build
339
340 - name: Run Fortran fpm (bootstrap)
341 shell: bash
342 run: |
343 ${{ env.BOOTSTRAP }} run
344 ${{ env.BOOTSTRAP }} run -- --version
345 ${{ env.BOOTSTRAP }} run -- --help
346
347 - name: Test Fortran fpm (bootstrap)
348 if: (!contains(matrix.mpi,'intel'))
349 shell: bash
350 run: |
351 ${{ env.BOOTSTRAP }} test ${{ matrix.release-flags }}
352
353 - name: Install Fortran fpm (bootstrap)
354 shell: bash
355 run: |
356 ${{ env.BOOTSTRAP }} install
357
358 # Phase 2: Bootstrap fpm with itself
359 - name: Replace bootstrapping version
360 shell: bash
361 run: |
362 ${{ env.BOOTSTRAP }} run --runner cp -- fpm-debug${{ matrix.exe }}
363 rm -v ${{ env.BOOTSTRAP }}
364 echo "FPM=$PWD/fpm-debug" >> $GITHUB_ENV
365
366 - name: Get version (normal)
367 if: github.event_name != 'release'
368 shell: bash
369 run: |
370 VERSION=$(git rev-parse --short HEAD)
371 echo "VERSION=$VERSION" >> $GITHUB_ENV
372
373 - name: Get version (release)
374 if: github.event_name == 'release'
375 shell: bash
376 run: |
377 VERSION=$(echo ${{ github.ref }} | cut -dv -f2)
378 echo "VERSION=$VERSION" >> $GITHUB_ENV
379 FPM_VERSION=$(${{ env.FPM }} --version | grep -o '${{ env.REGEX }}')
380 [ "$VERSION" = "$FPM_VERSION" ]
381 env:
382 REGEX: '[0-9]\{1,4\}\.[0-9]\{1,4\}\.[0-9]\{1,4\}'
383
384 - name: Build Fortran fpm
385 shell: bash
386 run: |
387 ${{ env.FPM }} build ${{ matrix.release-flags }}
388
389 - name: Run Fortran fpm
390 shell: bash
391 run: |
392 ${{ env.FPM }} run ${{ matrix.release-flags }}
393 ${{ env.FPM }} run ${{ matrix.release-flags }} -- --version
394 ${{ env.FPM }} run ${{ matrix.release-flags }} -- --help
395
396 - name: Install Fortran fpm
397 shell: bash
398 run: |
399 ${{ env.FPM }} install ${{ matrix.release-flags }}
400
401 - name: Package release version
402 shell: bash
403 run: |
404 ${{ env.FPM }} run ${{ matrix.release-flags }} --runner cp -- ${{ env.EXE }}
405 rm -v ${{ env.FPM }}
406 echo "FPM_RELEASE=${{ env.EXE }}" >> $GITHUB_ENV
407 env:
408 EXE: fpm-${{ env.VERSION }}-${{ matrix.os-arch }}${{ matrix.exe }}
409
410 - name: Use Intel compiler for the metapackage tests
411 if: contains(matrix.mpi,'intel')
412 shell: bash
413 run: |
414 echo "FPM_FC=ifx" >> $GITHUB_ENV
415 echo "FPM_CC=icx" >> $GITHUB_ENV
416 echo "FPM_CXX=icpx" >> $GITHUB_ENV
417
418 - name: Run metapackage tests using the release version
419 shell: bash
420 run: |
421 ci/meta_tests.sh "$PWD/${{ env.FPM_RELEASE }}"