|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, unstable, '[0-9]+.[0-9]+.x' ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, unstable, '[0-9]+.[0-9]+.x' ] |
| 8 | + workflow_call: |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +env: |
| 12 | + CMAKE_C_COMPILER_LAUNCHER: ccache |
| 13 | + CMAKE_CXX_COMPILER_LAUNCHER: ccache |
| 14 | + CCACHE_COMPILERCHECK: content |
| 15 | + CCACHE_BASEDIR: ${{ github.workspace }} |
| 16 | + CCACHE_DIR: ${{ github.workspace }}/.ccache |
| 17 | + CCACHE_MAXSIZE: 500M |
| 18 | + CCACHE_SLOPPINESS: pch_defines,time_macros,include_file_mtime,include_file_ctime |
| 19 | + CCACHE_COMPRESS: "1" |
| 20 | + CCACHE_COMPRESSLEVEL: "1" |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + include: |
| 29 | + - {os: ubuntu-24.04, cxx: g++} |
| 30 | + - {os: ubuntu-24.04, cxx: clang++} |
| 31 | + |
| 32 | + runs-on: ${{ matrix.os }} |
| 33 | + |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - uses: actions/cache/restore@v4 |
| 38 | + with: |
| 39 | + path: ${{ env.CCACHE_DIR }} |
| 40 | + key: ccache-${{ matrix.os }}-${{ matrix.cxx }}-${{ github.run_id }}-${{ github.run_attempt }} |
| 41 | + restore-keys: | |
| 42 | + ccache-${{ matrix.os }}-${{ matrix.cxx }}- |
| 43 | +
|
| 44 | + - name: Set cxx variables |
| 45 | + run: | |
| 46 | + if [[ ${{ matrix.os }} == 'macos-15' && ${{ matrix.cxx }} == 'g++' ]]; then |
| 47 | + echo "CXX=g++-15" >> $GITHUB_ENV |
| 48 | + else |
| 49 | + echo "CXX=${{ matrix.cxx }}" >> $GITHUB_ENV |
| 50 | + fi |
| 51 | +
|
| 52 | + - name: Install ubuntu dependencies |
| 53 | + if: ${{ contains(matrix.os, 'ubuntu') }} |
| 54 | + run: > |
| 55 | + sudo apt-get update && |
| 56 | + sudo apt-get install lsb-release wget software-properties-common && |
| 57 | + sudo apt-get install |
| 58 | + ccache |
| 59 | + cmake |
| 60 | + ninja-build |
| 61 | + clang |
| 62 | + g++ |
| 63 | + hdf5-tools |
| 64 | + libblas-dev |
| 65 | + libc++-dev |
| 66 | + libc++abi-dev |
| 67 | + libomp-dev |
| 68 | + libhdf5-dev |
| 69 | + libopenblas-dev |
| 70 | + libopenmpi-dev |
| 71 | + openmpi-bin |
| 72 | + openmpi-common |
| 73 | +
|
| 74 | + - name: Install homebrew dependencies |
| 75 | + if: ${{ contains(matrix.os, 'macos') }} |
| 76 | + run: | |
| 77 | + brew update |
| 78 | + brew install ccache gcc llvm hdf5 open-mpi openblas |
| 79 | + echo "PATH=$(brew --prefix llvm)/bin:$(brew --prefix gcc)/bin:$PATH" >> $GITHUB_ENV |
| 80 | + echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV |
| 81 | + echo "LDFLAGS=-L$(brew --prefix llvm)/lib/c++ -L/opt/homebrew/opt/llvm/lib/unwind -lunwind" >> $GITHUB_ENV |
| 82 | +
|
| 83 | + - name: Add clang CXXFLAGS |
| 84 | + if: ${{ matrix.cxx == 'clang++' }} |
| 85 | + run: | |
| 86 | + echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV |
| 87 | +
|
| 88 | + - name: Build cppdlr2d |
| 89 | + run: | |
| 90 | + cmake -S . -B build -G Ninja -DCMAKE_INSTALL_PREFIX=$HOME/install |
| 91 | + cmake --build build --verbose |
| 92 | +
|
| 93 | + - name: Test cppdlr2d |
| 94 | + env: |
| 95 | + OPENBLAS_NUM_THREADS: "1" |
| 96 | + run: | |
| 97 | + cd build |
| 98 | + ctest -j2 --output-on-failure |
| 99 | +
|
| 100 | + - name: ccache statistics |
| 101 | + if: always() |
| 102 | + run: ccache -sv |
| 103 | + |
| 104 | + - uses: actions/cache/save@v4 |
| 105 | + if: always() |
| 106 | + with: |
| 107 | + path: ${{ env.CCACHE_DIR }} |
| 108 | + key: ccache-${{ matrix.os }}-${{ matrix.cxx }}-${{ github.run_id }}-${{ github.run_attempt }} |
0 commit comments