name: C/Fortran

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-24.04, macos-15]
        compiler: [gcc, clang]
        exclude:
          # "gcc" on macOS is a symlink to Apple Clang, same as "clang"
          - os: macos-15
            compiler: gcc
        include:
          # macOS: test with real GCC (not Apple Clang symlink)
          - os: macos-15
            compiler: gcc-15
          # macOS: test with Homebrew LLVM
          - os: macos-15
            compiler: llvm

    runs-on: ${{ matrix.os }}

    steps:
    - name: Environment setup
      uses: actions/checkout@v4
    - name: Set LLVM compiler path
      if: matrix.compiler == 'llvm'
      run: echo "CC=$(brew --prefix llvm@18)/bin/clang" >> $GITHUB_ENV
    - name: Set compiler
      if: matrix.compiler != 'llvm'
      run: echo "CC=${{ matrix.compiler }}" >> $GITHUB_ENV
    - name: Show compiler version
      run: $CC --version | head -1
    - name: Build and test libCEED
      env:
        FC: gfortran-14
      run: |
        make info
        make -j
        make prove -j2
