name: metapackage-tests on: # On push, only run if any of the metapackage files has changed push: paths: - 'src/*meta*.f90' - 'src/fpm/*meta*.f90' - 'src/fpm/manifest/*meta*.f90' - 'src/ci/meta_tests.sh' - 'src/.github/workflows/meta.yml' # Always run on PR or release pull_request: release: types: [published] # Allow manual triggering workflow_dispatch: env: CI: "ON" # We can detect this in the build system and other vendors implement it HOMEBREW_NO_ANALYTICS: 1 # Make Homebrew installation a little quicker HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1 HOMEBREW_NO_GITHUB_API: 1 HOMEBREW_NO_INSTALL_CLEANUP: 1 HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 jobs: build: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - os: ubuntu-latest mpi: openmpi release-flags: --flag ' -Wno-external-argument-mismatch' - os: ubuntu-latest mpi: mpich release-flags: --flag ' -Wno-external-argument-mismatch' - os: macos-14 mpi: openmpi release-flags: --flag ' -Wno-external-argument-mismatch' - os: macos-14 mpi: mpich release-flags: --flag ' -Wno-external-argument-mismatch' - os: ubuntu-latest mpi: intel intel_version: "2024.1.0" release-flags: "" # override: no GCC flags - os: ubuntu-latest mpi: intel intel_version: "2025.0" release-flags: "" # override: no GCC flags steps: - name: Checkout code uses: actions/checkout@v6 - name: (Ubuntu) setup gcc version if: contains(matrix.os,'ubuntu') run: | echo "GCC_V=14" >> $GITHUB_ENV - name: (macOS) setup gcc version if: contains(matrix.os,'macos') run: | echo "GCC_V=15" >> $GITHUB_ENV - name: (Windows) Install MSYS2 uses: msys2/setup-msys2@v2 if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi') with: msystem: MINGW64 update: true install: >- git base-devel wget unzip curl hdf5 netcdf netcdf-fortran - name: (Ubuntu) Install gfortran if: contains(matrix.os,'ubuntu') run: | sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \ --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \ --slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V} - name: (Ubuntu) Install OpenMPI if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'openmpi') run: | sudo apt-get update sudo apt install -y -q openmpi-bin libopenmpi-dev hwloc fabric libhdf5-dev \ libhdf5-fortran-102 libnetcdf-dev libnetcdff-dev libopenblas-dev - name: (Ubuntu) Install MPICH if: contains(matrix.os,'ubuntu') && contains(matrix.mpi,'mpich') run: | sudo apt-get update sudo apt install -y -q mpich hwloc fabric libhdf5-dev libhdf5-fortran-102 \ libnetcdf-dev libnetcdff-dev libopenblas-dev # Intel - name: Setup Intel Environment if: contains(matrix.mpi, 'intel') uses: ./.github/actions/setup-intel with: os: ${{ matrix.os }} version: ${{ matrix.intel_version }} - name: (Ubuntu) Build and Install HDF5 from source if: contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'intel') # Needs checkout if source code isn't available, adjust if needed # Ensure compilers are available from the previous step's environment setup shell: bash run: | # Source again just in case shell context is lost (shouldn't be, but safer) source /opt/intel/oneapi/setvars.sh --force # Download HDF5 curl -O -L https://github.com/HDFGroup/hdf5/archive/refs/tags/snapshot-1.14.tar.gz tar zxf snapshot-1.14.tar.gz cd hdf5-snapshot-1.14 # Configure HDF5 with Intel compilers cmake -B build -DCMAKE_Fortran_COMPILER=ifx -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DHDF5_BUILD_FORTRAN=ON -DCMAKE_INSTALL_PREFIX=/usr cd build make -j $(nproc) sudo make install cd ../.. # Go back to workspace directory rm -rf hdf5-snapshot-1.14 snapshot-1.14.tar.gz # Clean up - name: (Ubuntu) Build and Install NetCDF-C from source if: contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'intel') shell: bash run: | source /opt/intel/oneapi/setvars.sh --force # Download NetCDF-C curl -L https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz -o - | tar xz cd netcdf-c-4.9.2 # Configure NetCDF-C with Intel Compilers, referencing installed HDF5 # Set CC/CXX/FC explicitly in environment for configure script export CC=icx CXX=icpx FC=ifx ./configure --prefix=/usr --enable-netcdf-4 --with-hdf5=/usr make -j $(nproc) sudo make install cd .. # Go back to workspace directory rm -rf netcdf-c-4.9.2 # Clean up - name: (Ubuntu) Build and Install NetCDF-Fortran from source if: contains(matrix.os, 'ubuntu') && contains(matrix.mpi, 'intel') shell: bash run: | source /opt/intel/oneapi/setvars.sh --force # Download NetCDF-Fortran curl -L https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz -o - | tar xz cd netcdf-fortran-4.6.1 # Configure NetCDF-Fortran with Intel Compilers using CMake cmake -B build -DCMAKE_Fortran_COMPILER=ifx -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DCMAKE_INSTALL_PREFIX=/usr cd build make -j $(nproc) sudo make install cd ../.. # Go back to workspace directory rm -rf netcdf-fortran-4.6.1 # Clean up - name: (Windows) Put MSYS2_MinGW64 on PATH if: contains(matrix.os,'windows') && (!contains(matrix.mpi,'intel')) # there is not yet an environment variable for this path from msys2/setup-msys2 run: echo "${{ runner.temp }}/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: (Windows) download MS-MPI setup (SDK is from MSYS2) if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi') # run: curl -L -O https://github.com/microsoft/Microsoft-MPI/releases/download/v10.1.2/msmpisetup.exe 10.1.1 run: curl -L -O https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisetup.exe # 10.1.2 - name: (Windows) Install mpiexec.exe (-force needed to bypass GUI on headless) if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi') run: .\msmpisetup.exe -unattend -force - name: (Windows) test that mpiexec.exe exists if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi') # can't use MSMPI_BIN as Actions doesn't update PATH from msmpisetup.exe run: Test-Path "C:\Program Files\Microsoft MPI\Bin\mpiexec.exe" -PathType leaf - name: (Windows) put MSMPI_BIN on PATH (where mpiexec is) if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi') run: | echo "C:\Program Files\Microsoft MPI\Bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "/c/Program Files/Microsoft MPI/Bin/" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\" | Out-File -FilePath $env:GITHUB_ENV -Append - name: (Windows) Install MSYS2 msmpi package if: contains(matrix.os,'windows') && contains(matrix.mpi,'msmpi') shell: msys2 {0} run: pacman --noconfirm -S mingw-w64-x86_64-msmpi - name: (macOS) Set up Homebrew if: contains(matrix.os,'macos') id: set-up-homebrew uses: Homebrew/actions/setup-homebrew@master - name: (macOS) Install Homebrew gfortran if: contains(matrix.os, 'macos') run: | # Only install gcc if not already available which gfortran-${{ env.GCC_V }} || brew install gcc@${{ env.GCC_V }} which gfortran-${{ env.GCC_V }} BREW_PREFIX=$(brew --prefix) which gfortran || ln -s ${BREW_PREFIX}/bin/gfortran-${{ env.GCC_V }} ${BREW_PREFIX}/bin/gfortran - name: (macOS) Install homebrew MPICH if: contains(matrix.mpi,'mpich') && contains(matrix.os,'macos') run: | brew install mpich - name: (macOS) Install homebrew OpenMPI if: contains(matrix.mpi,'openmpi') && contains(matrix.os,'macos') run: | brew install openmpi - name: (macOS) Install homebrew HDF5 if: contains(matrix.os,'macos') run: | brew install hdf5 - name: (macOS) Install homebrew NetCDF if: contains(matrix.os,'macos') run: | brew install netcdf brew install netcdf-fortran # Phase 1: Bootstrap fpm with existing version - name: Install fpm uses: fortran-lang/setup-fpm@v9 with: fpm-version: 'v0.12.0' # Backport gfortran shared libraries to the paths expected by the bootstrap fpm binary. # The macOS x86_64 release used for bootstrapping has hardcoded library paths from the gcc version # it was built with. If the versions match, skip this step. Otherwise, create symlinks. # On ARM64 it runs under Rosetta 2 and needs /usr/local paths. - name: MacOS patch libgfortran if: contains(matrix.os, 'macos') run: | which gfortran-${{ env.GCC_V }} which gfortran || true BREW_PREFIX=$(brew --prefix) # Query the actual library paths that fpm expects echo "Checking library dependencies of fpm bootstrap binary..." otool -L $(which fpm) # Extract the gcc version from the bootstrap binary's library paths BOOTSTRAP_GCC_VERSION=$(otool -L $(which fpm) | grep -o 'gcc@[0-9]\+' | head -n 1 | cut -d@ -f2) if [ -z "$BOOTSTRAP_GCC_VERSION" ]; then # Try alternative pattern: /lib/gcc/13/ -> extract 13 BOOTSTRAP_GCC_VERSION=$(otool -L $(which fpm) | grep libgfortran | grep -o '/lib/gcc/[0-9]\+/' | grep -o '[0-9]\+' | head -n 1) fi echo "Bootstrap fpm built with gcc@$BOOTSTRAP_GCC_VERSION" echo "Current toolchain: gcc@${{ env.GCC_V }}" if [ "$BOOTSTRAP_GCC_VERSION" == "${{ env.GCC_V }}" ]; then echo "✓ Bootstrap gcc version matches current toolchain - no patching needed" exit 0 fi echo "⚠ Version mismatch detected - creating compatibility symlinks..." # Find the actual Cellar path by following the symlink if [ -L "${BREW_PREFIX}/opt/gcc@${{ env.GCC_V }}" ]; then GCC_CELLAR_PATH=$(cd -P "${BREW_PREFIX}/opt/gcc@${{ env.GCC_V }}" && pwd) else GCC_CELLAR_PATH="${BREW_PREFIX}/Cellar/gcc@${{ env.GCC_V }}"/* fi echo "GCC Cellar path: $GCC_CELLAR_PATH" # Find the actual library files CURRENT_GFORTRAN=$(find "$GCC_CELLAR_PATH"/lib/gcc/${{ env.GCC_V }} -name "libgfortran.*.dylib" 2>/dev/null | head -n 1) CURRENT_QUADMATH=$(find "$GCC_CELLAR_PATH"/lib/gcc/${{ env.GCC_V }} -name "libquadmath.*.dylib" 2>/dev/null | head -n 1) CURRENT_GCC_S=$(find "$GCC_CELLAR_PATH"/lib/gcc/${{ env.GCC_V }} -name "libgcc_s.*.dylib" 2>/dev/null | head -n 1) echo "Current gcc@${{ env.GCC_V }} libraries:" echo " libgfortran: $CURRENT_GFORTRAN" echo " libquadmath: $CURRENT_QUADMATH" echo " libgcc_s: $CURRENT_GCC_S" # Extract the expected libgfortran path and create symlink LIBGFORTRAN_PATH=$(otool -L $(which fpm) | grep libgfortran | awk '{print $1}' | head -n 1) if [ -n "$LIBGFORTRAN_PATH" ] && [ -n "$CURRENT_GFORTRAN" ]; then TARGET_DIR=$(dirname "$LIBGFORTRAN_PATH") echo "Creating directory: $TARGET_DIR" sudo mkdir -p "$TARGET_DIR" echo "Linking $CURRENT_GFORTRAN to $LIBGFORTRAN_PATH" sudo ln -fs "$CURRENT_GFORTRAN" "$LIBGFORTRAN_PATH" fi # Extract the expected libquadmath path and create symlink LIBQUADMATH_PATH=$(otool -L $(which fpm) | grep libquadmath | awk '{print $1}' | head -n 1) if [ -n "$LIBQUADMATH_PATH" ] && [ -n "$CURRENT_QUADMATH" ]; then TARGET_DIR=$(dirname "$LIBQUADMATH_PATH") echo "Creating directory: $TARGET_DIR" sudo mkdir -p "$TARGET_DIR" echo "Linking $CURRENT_QUADMATH to $LIBQUADMATH_PATH" sudo ln -fs "$CURRENT_QUADMATH" "$LIBQUADMATH_PATH" fi # Extract the expected libgcc_s path and create symlink LIBGCC_PATH=$(otool -L $(which fpm) | grep libgcc_s | awk '{print $1}' | head -n 1) if [ -n "$LIBGCC_PATH" ] && [ -n "$CURRENT_GCC_S" ]; then TARGET_DIR=$(dirname "$LIBGCC_PATH") echo "Creating directory: $TARGET_DIR" sudo mkdir -p "$TARGET_DIR" echo "Linking $CURRENT_GCC_S to $LIBGCC_PATH" sudo ln -fs "$CURRENT_GCC_S" "$LIBGCC_PATH" fi - name: Remove fpm from path shell: bash run: | mv $(which fpm) fpm-bootstrap${{ matrix.exe }} echo "BOOTSTRAP=$PWD/fpm-bootstrap" >> $GITHUB_ENV - name: (macOS/Ubuntu) Use gcc/g++ instead of Clang for C/C++ / ifx to build fpm if: contains(matrix.os,'macOS') || contains(matrix.os,'ubuntu') shell: bash run: | echo "FPM_FC=gfortran-${{ env.GCC_V }}" >> $GITHUB_ENV echo "FPM_CC=gcc-${{ env.GCC_V }}" >> $GITHUB_ENV echo "FPM_CXX=g++-${{ env.GCC_V }}" >> $GITHUB_ENV - name: Build Fortran fpm (bootstrap) shell: bash run: | ${{ env.BOOTSTRAP }} build - name: Run Fortran fpm (bootstrap) shell: bash run: | ${{ env.BOOTSTRAP }} run ${{ env.BOOTSTRAP }} run -- --version ${{ env.BOOTSTRAP }} run -- --help - name: Test Fortran fpm (bootstrap) if: (!contains(matrix.mpi,'intel')) shell: bash run: | ${{ env.BOOTSTRAP }} test ${{ matrix.release-flags }} - name: Install Fortran fpm (bootstrap) shell: bash run: | ${{ env.BOOTSTRAP }} install # Phase 2: Bootstrap fpm with itself - name: Replace bootstrapping version shell: bash run: | ${{ env.BOOTSTRAP }} run --runner cp -- fpm-debug${{ matrix.exe }} rm -v ${{ env.BOOTSTRAP }} echo "FPM=$PWD/fpm-debug" >> $GITHUB_ENV - name: Get version (normal) if: github.event_name != 'release' shell: bash run: | VERSION=$(git rev-parse --short HEAD) echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Get version (release) if: github.event_name == 'release' shell: bash run: | VERSION=$(echo ${{ github.ref }} | cut -dv -f2) echo "VERSION=$VERSION" >> $GITHUB_ENV FPM_VERSION=$(${{ env.FPM }} --version | grep -o '${{ env.REGEX }}') [ "$VERSION" = "$FPM_VERSION" ] env: REGEX: '[0-9]\{1,4\}\.[0-9]\{1,4\}\.[0-9]\{1,4\}' - name: Build Fortran fpm shell: bash run: | ${{ env.FPM }} build ${{ matrix.release-flags }} - name: Run Fortran fpm shell: bash run: | ${{ env.FPM }} run ${{ matrix.release-flags }} ${{ env.FPM }} run ${{ matrix.release-flags }} -- --version ${{ env.FPM }} run ${{ matrix.release-flags }} -- --help - name: Install Fortran fpm shell: bash run: | ${{ env.FPM }} install ${{ matrix.release-flags }} - name: Package release version shell: bash run: | ${{ env.FPM }} run ${{ matrix.release-flags }} --runner cp -- ${{ env.EXE }} rm -v ${{ env.FPM }} echo "FPM_RELEASE=${{ env.EXE }}" >> $GITHUB_ENV env: EXE: fpm-${{ env.VERSION }}-${{ matrix.os-arch }}${{ matrix.exe }} - name: Use Intel compiler for the metapackage tests if: contains(matrix.mpi,'intel') shell: bash run: | echo "FPM_FC=ifx" >> $GITHUB_ENV echo "FPM_CC=icx" >> $GITHUB_ENV echo "FPM_CXX=icpx" >> $GITHUB_ENV - name: Run metapackage tests using the release version shell: bash run: | ci/meta_tests.sh "$PWD/${{ env.FPM_RELEASE }}"