|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - '**' |
| 10 | + |
| 11 | +env: |
| 12 | + CMAKE_VERSION: '3.31.7' |
| 13 | + CMAKE_INSTALL_DIR: '${{ github.workspace }}/.cmake' |
| 14 | + CMAKE_BIN: '${{ github.workspace }}/.cmake/bin/cmake' |
| 15 | + TEST_RESULTS_DIR: '${{ github.workspace }}/test-results' |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-and-test: |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - name: Ubuntu-20.04-GCC |
| 23 | + os: ubuntu-20.04 |
| 24 | + cc: gcc |
| 25 | + cxx: g++ |
| 26 | + - name: Ubuntu-20.04-Clang |
| 27 | + os: ubuntu-20.04 |
| 28 | + cc: clang |
| 29 | + cxx: clang++ |
| 30 | + - name: Ubuntu-22.04-GCC |
| 31 | + os: ubuntu-22.04 |
| 32 | + cc: gcc |
| 33 | + cxx: g++ |
| 34 | + - name: Ubuntu-22.04-Clang |
| 35 | + os: ubuntu-22.04 |
| 36 | + cc: clang |
| 37 | + cxx: clang++ |
| 38 | + - name: Ubuntu-24.04-GCC |
| 39 | + os: ubuntu-24.04 |
| 40 | + cc: gcc |
| 41 | + cxx: g++ |
| 42 | + - name: Ubuntu-24.04-Clang |
| 43 | + os: ubuntu-24.04 |
| 44 | + cc: clang |
| 45 | + cxx: clang++ |
| 46 | + - name: Ubuntu-22.04-GCC-FFTW |
| 47 | + os: ubuntu-22.04 |
| 48 | + cc: gcc |
| 49 | + cxx: g++ |
| 50 | + extra_packages: libfftw3-dev |
| 51 | + |
| 52 | + runs-on: ${{ matrix.os }} |
| 53 | + name: ${{ matrix.name }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout repository |
| 57 | + uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: Install dependencies |
| 60 | + run: | |
| 61 | + sudo apt update |
| 62 | + sudo apt install -y ninja-build ${{ matrix.cc }} ${{ matrix.cxx }} ${{ matrix.extra_packages }} |
| 63 | +
|
| 64 | + - name: Cache CMake |
| 65 | + uses: actions/cache@v4 |
| 66 | + with: |
| 67 | + path: ${{ env.CMAKE_INSTALL_DIR }} |
| 68 | + key: cmake-${{ env.CMAKE_VERSION }}-${{ matrix.os }}-${{ matrix.cc }}-try2 |
| 69 | + |
| 70 | + - name: Download and Install CMake if not cached |
| 71 | + run: | |
| 72 | + if [ ! -f "${{ env.CMAKE_BIN }}" ]; then |
| 73 | + echo "CMake not found in cache. Downloading..." |
| 74 | + mkdir -p "${{ env.CMAKE_INSTALL_DIR }}" |
| 75 | + wget -q https://github.com/Kitware/CMake/releases/download/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.tar.gz |
| 76 | + tar -xzf cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.tar.gz --strip-components=1 -C "${{ env.CMAKE_INSTALL_DIR }}" |
| 77 | + else |
| 78 | + echo "Using cached CMake" |
| 79 | + fi |
| 80 | + "${{ env.CMAKE_BIN }}" --version |
| 81 | +
|
| 82 | + - name: Run CMake configuration and build |
| 83 | + run: | |
| 84 | + "${{ env.CMAKE_BIN }}" . -B build -G Ninja \ |
| 85 | + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ |
| 86 | + -DCMAKE_C_COMPILER=${{ matrix.cc }} \ |
| 87 | + -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} |
| 88 | + "${{ env.CMAKE_BIN }}" --build build --parallel |
| 89 | +
|
| 90 | + - name: Run Unit Tests |
| 91 | + run: | |
| 92 | + mkdir -p "${{ env.TEST_RESULTS_DIR }}" |
| 93 | + ./build/tests --reporters=junit --out="${{ env.TEST_RESULTS_DIR }}/results.xml" |
| 94 | +
|
| 95 | + - name: Render JUnit results in GitHub UI |
| 96 | + if: always() |
| 97 | + uses: dorny/test-reporter@v1 |
| 98 | + with: |
| 99 | + name: ${{ matrix.name }} Tests |
| 100 | + path: ${{ env.TEST_RESULTS_DIR }}/results.xml |
| 101 | + reporter: junit |
| 102 | + |
| 103 | + - name: Upload Test Results Artifact |
| 104 | + if: always() |
| 105 | + uses: actions/upload-artifact@v4 |
| 106 | + with: |
| 107 | + name: ${{ matrix.name }}-test-results |
| 108 | + path: ${{ env.TEST_RESULTS_DIR }}/results.xml |
0 commit comments