|
| 1 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | + |
| 3 | +name: Continuous Integration Tests |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + pull_request: |
| 8 | + workflow_dispatch: |
| 9 | + schedule: |
| 10 | + - cron: '30 15 * * *' |
| 11 | + |
| 12 | +jobs: |
| 13 | + preset-test: |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + presets: |
| 18 | + - preset: "gcc-debug" |
| 19 | + platform: "ubuntu-latest" |
| 20 | + - preset: "gcc-release" |
| 21 | + platform: "ubuntu-latest" |
| 22 | + - preset: "llvm-debug" |
| 23 | + platform: "ubuntu-latest" |
| 24 | + - preset: "llvm-release" |
| 25 | + platform: "ubuntu-latest" |
| 26 | + - preset: "appleclang-debug" |
| 27 | + platform: "macos-latest" |
| 28 | + - preset: "appleclang-release" |
| 29 | + platform: "macos-latest" |
| 30 | + - preset: "msvc-debug" |
| 31 | + platform: "windows-latest" |
| 32 | + - preset: "msvc-release" |
| 33 | + platform: "windows-latest" |
| 34 | + name: "Preset: ${{ matrix.presets.preset }} on ${{ matrix.presets.platform }}" |
| 35 | + runs-on: ${{ matrix.presets.platform }} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - name: Setup build environment |
| 39 | + uses: lukka/get-cmake@latest |
| 40 | + with: |
| 41 | + cmakeVersion: "~3.25.0" |
| 42 | + ninjaVersion: "^1.11.1" |
| 43 | + - name: Setup MSVC |
| 44 | + if: startsWith(matrix.presets.platform, 'windows') |
| 45 | + uses: TheMrMilchmann/setup-msvc-dev@v3 |
| 46 | + with: |
| 47 | + arch: x64 |
| 48 | + - name: Run preset |
| 49 | + run: cmake --workflow --preset ${{ matrix.presets.preset }} |
| 50 | + |
| 51 | + gtest-test: |
| 52 | + strategy: |
| 53 | + fail-fast: false |
| 54 | + matrix: |
| 55 | + platform: |
| 56 | + - description: "Ubuntu GNU" |
| 57 | + os: ubuntu-latest |
| 58 | + toolchain: "cmake/gnu-toolchain.cmake" |
| 59 | + - description: "Ubuntu LLVM" |
| 60 | + os: ubuntu-latest |
| 61 | + toolchain: "cmake/llvm-toolchain.cmake" |
| 62 | + - description: "Windows MSVC" |
| 63 | + os: windows-latest |
| 64 | + toolchain: "cmake/msvc-toolchain.cmake" |
| 65 | + - description: "Macos Appleclang" |
| 66 | + os: macos-latest |
| 67 | + toolchain: "cmake/appleclang-toolchain.cmake" |
| 68 | + cpp_version: [20, 23, 26] |
| 69 | + cmake_args: |
| 70 | + - description: "Default" |
| 71 | + - description: "TSan" |
| 72 | + args: "-DBEMAN_BUILDSYS_SANITIZER=TSan" |
| 73 | + - description: "MaxSan" |
| 74 | + args: "-DBEMAN_BUILDSYS_SANITIZER=MaxSan" |
| 75 | + include: |
| 76 | + - platform: |
| 77 | + description: "Ubuntu GCC" |
| 78 | + os: ubuntu-latest |
| 79 | + toolchain: "cmake/gnu-toolchain.cmake" |
| 80 | + cpp_version: 20 |
| 81 | + cmake_args: |
| 82 | + description: "Werror" |
| 83 | + args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'" |
| 84 | + - platform: |
| 85 | + description: "Ubuntu GCC" |
| 86 | + os: ubuntu-latest |
| 87 | + toolchain: "cmake/gnu-toolchain.cmake" |
| 88 | + cpp_version: 20 |
| 89 | + cmake_args: |
| 90 | + description: "Dynamic" |
| 91 | + args: "-DBUILD_SHARED_LIBS=on" |
| 92 | + exclude: |
| 93 | + # MSVC does not support thread sanitizer |
| 94 | + - platform: |
| 95 | + description: "Windows MSVC" |
| 96 | + cmake_args: |
| 97 | + description: "TSan" |
| 98 | + |
| 99 | + name: "Unit: |
| 100 | + ${{ matrix.platform.description }} |
| 101 | + ${{ matrix.cpp_version }} |
| 102 | + ${{ matrix.cmake_args.description }}" |
| 103 | + runs-on: ${{ matrix.platform.os }} |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v4 |
| 106 | + - name: Install Ninja |
| 107 | + uses: lukka/get-cmake@latest |
| 108 | + with: |
| 109 | + cmakeVersion: "~3.25.0" |
| 110 | + ninjaVersion: "^1.11.1" |
| 111 | + - name: Setup MSVC |
| 112 | + if: startsWith(matrix.platform.os, 'windows') |
| 113 | + uses: TheMrMilchmann/setup-msvc-dev@v3 |
| 114 | + with: |
| 115 | + arch: x64 |
| 116 | + - name: Build and Test |
| 117 | + uses: ./.github/actions/cmake-build-test |
| 118 | + with: |
| 119 | + cpp_version: ${{ matrix.cpp_version }} |
| 120 | + toolchain_file: ${{ matrix.platform.toolchain }} |
| 121 | + cmake_extra_args: ${{ matrix.cmake_args.args }} |
| 122 | + |
| 123 | + configuration-test: |
| 124 | + runs-on: ubuntu-latest |
| 125 | + strategy: |
| 126 | + fail-fast: false |
| 127 | + matrix: |
| 128 | + args: |
| 129 | + - name: "Disable build testing" |
| 130 | + arg: "-DBEMAN_EXECUTION_BUILD_TESTS=OFF" |
| 131 | + - name: "Disable example building" |
| 132 | + arg: "-DBEMAN_EXECUTION_BUILD_EXAMPLES=OFF" |
| 133 | + - name: "Disable config-file package creation" |
| 134 | + arg: "-DBEMAN_EXECUTION_INSTALL_CONFIG_FILE_PACKAGE=OFF" |
| 135 | + name: "CMake: ${{ matrix.args.name }}" |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v4 |
| 138 | + - name: Setup build environment |
| 139 | + uses: lukka/get-cmake@latest |
| 140 | + with: |
| 141 | + cmakeVersion: "~3.25.0" |
| 142 | + ninjaVersion: "^1.11.1" |
| 143 | + - name: Build and Test |
| 144 | + uses: ./.github/actions/cmake-build-test |
| 145 | + with: |
| 146 | + cpp_version: 20 |
| 147 | + toolchain_file: "cmake/gnu-toolchain.cmake" |
| 148 | + cmake_extra_args: ${{ matrix.args.arg }} |
| 149 | + disable_test: true |
| 150 | + |
| 151 | + compiler-test: |
| 152 | + runs-on: ubuntu-24.04 |
| 153 | + strategy: |
| 154 | + fail-fast: false |
| 155 | + matrix: |
| 156 | + compilers: |
| 157 | + - class: GNU |
| 158 | + version: 14 |
| 159 | + toolchain: "cmake/gnu-toolchain.cmake" |
| 160 | + - class: GNU |
| 161 | + version: 13 |
| 162 | + toolchain: "cmake/gnu-toolchain.cmake" |
| 163 | + - class: GNU |
| 164 | + version: 12 |
| 165 | + toolchain: "cmake/gnu-toolchain.cmake" |
| 166 | + - class: LLVM |
| 167 | + version: 20 |
| 168 | + toolchain: "cmake/llvm-toolchain.cmake" |
| 169 | + - class: LLVM |
| 170 | + version: 19 |
| 171 | + toolchain: "cmake/llvm-toolchain.cmake" |
| 172 | + - class: LLVM |
| 173 | + version: 18 |
| 174 | + toolchain: "cmake/llvm-toolchain.cmake" |
| 175 | + - class: LLVM |
| 176 | + version: 17 |
| 177 | + toolchain: "cmake/llvm-toolchain.cmake" |
| 178 | + name: "Compiler: ${{ matrix.compilers.class }} ${{ matrix.compilers.version }}" |
| 179 | + steps: |
| 180 | + - uses: actions/checkout@v4 |
| 181 | + - name: Setup build environment |
| 182 | + uses: lukka/get-cmake@latest |
| 183 | + with: |
| 184 | + cmakeVersion: "~3.25.0" |
| 185 | + ninjaVersion: "^1.11.1" |
| 186 | + - name: Install Compiler |
| 187 | + id: install-compiler |
| 188 | + run: | |
| 189 | + sudo add-apt-repository universe |
| 190 | + sudo apt-get update |
| 191 | +
|
| 192 | + if [ "${{ matrix.compilers.class }}" = "GNU" ]; then |
| 193 | + CC=gcc-${{ matrix.compilers.version }} |
| 194 | + CXX=g++-${{ matrix.compilers.version }} |
| 195 | +
|
| 196 | + sudo apt-get install -y $CC |
| 197 | + sudo apt-get install -y $CXX |
| 198 | +
|
| 199 | + $CC --version |
| 200 | + $CXX --version |
| 201 | + else |
| 202 | + wget https://apt.llvm.org/llvm.sh |
| 203 | + chmod +x llvm.sh |
| 204 | + sudo bash llvm.sh ${{ matrix.compilers.version }} |
| 205 | +
|
| 206 | + CC=clang-${{ matrix.compilers.version }} |
| 207 | + CXX=clang++-${{ matrix.compilers.version }} |
| 208 | +
|
| 209 | + $CC --version |
| 210 | + $CXX --version |
| 211 | + fi |
| 212 | +
|
| 213 | + echo "CC=$CC" >> "$GITHUB_OUTPUT" |
| 214 | + echo "CXX=$CXX" >> "$GITHUB_OUTPUT" |
| 215 | + - name: Build and Test |
| 216 | + uses: ./.github/actions/cmake-build-test |
| 217 | + with: |
| 218 | + cpp_version: 20 |
| 219 | + toolchain_file: ${{ matrix.compilers.toolchain }} |
| 220 | + |
| 221 | + create-issue-when-fault: |
| 222 | + runs-on: ubuntu-latest |
| 223 | + needs: [preset-test, gtest-test, configuration-test, compiler-test] |
| 224 | + if: failure() && github.event_name == 'schedule' |
| 225 | + steps: |
| 226 | + # See https://github.com/cli/cli/issues/5075 |
| 227 | + - uses: actions/checkout@v4 |
| 228 | + - name: Create issue |
| 229 | + run: | |
| 230 | + issue_num=$(gh issue list -s open -S "[SCHEDULED-BUILD] Build & Test failure" -L 1 --json number | jq 'if length == 0 then -1 else .[0].number end') |
| 231 | +
|
| 232 | + body="**Build-and-Test Failure Report** |
| 233 | + - **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z') |
| 234 | + - **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}) |
| 235 | + - **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 236 | +
|
| 237 | + The scheduled build-and-test triggered by cron has failed. |
| 238 | + Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error." |
| 239 | +
|
| 240 | + if [[ $issue_num -eq -1 ]]; then |
| 241 | + gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] Build & Test failure" --body "$body" |
| 242 | + else |
| 243 | + gh issue comment --repo ${{ github.repository }} $issue_num --body "$body" |
| 244 | + fi |
| 245 | + env: |
| 246 | + GH_TOKEN: ${{ github.token }} |
0 commit comments