|
| 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 | + # Allows you to run this workflow manually from the Actions tab |
| 9 | + workflow_dispatch: |
| 10 | + schedule: |
| 11 | + - cron: '30 15 * * *' |
| 12 | + |
| 13 | +jobs: |
| 14 | + # preset-test: |
| 15 | + # runs-on: ubuntu-latest |
| 16 | + # strategy: |
| 17 | + # matrix: |
| 18 | + # preset: [] |
| 19 | + # name: "Preset Test: ${{ matrix.preset }}" |
| 20 | + # steps: |
| 21 | + # - uses: actions/checkout@v4 |
| 22 | + # - name: Setup build environment |
| 23 | + # uses: lukka/get-cmake@latest |
| 24 | + # with: |
| 25 | + # cmakeVersion: "~3.25.0" |
| 26 | + # ninjaVersion: "^1.11.1" |
| 27 | + # - name: Run preset |
| 28 | + # run: cmake --workflow --preset ${{ matrix.preset }} |
| 29 | + |
| 30 | + test: |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + platform: [ubuntu-latest] |
| 35 | + compiler: |
| 36 | + - cpp: g++ |
| 37 | + c: gcc |
| 38 | + - cpp: clang++ |
| 39 | + c: clang |
| 40 | + cpp_version: [20, 23, 26] |
| 41 | + cmake_args: |
| 42 | + - description: "Default" |
| 43 | + args: "" |
| 44 | + - description: "TSan" |
| 45 | + args: "-DCMAKE_CXX_FLAGS=-fsanitize=thread" |
| 46 | + - description: "ASan" |
| 47 | + args: "-DCMAKE_CXX_FLAGS=-fsanitize=address -fsanitize=undefined" |
| 48 | + include: |
| 49 | + - platform: ubuntu-latest |
| 50 | + compiler: |
| 51 | + cpp: g++ |
| 52 | + c: gcc |
| 53 | + cpp_version: 20 |
| 54 | + cmake_args: |
| 55 | + description: "Werror" |
| 56 | + cmake_args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'" |
| 57 | + - platform: ubuntu-latest |
| 58 | + compiler: |
| 59 | + cpp: g++ |
| 60 | + c: gcc |
| 61 | + cpp_version: 20 |
| 62 | + cmake_args: |
| 63 | + description: "Dynamic" |
| 64 | + cmake_args: "-DBUILD_SHARED_LIBS=on" |
| 65 | + |
| 66 | + name: "Bulid & Test: ${{ matrix.compiler.c }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}" |
| 67 | + runs-on: ${{ matrix.platform }} |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v4 |
| 70 | + - name: Install Ninja |
| 71 | + uses: lukka/get-cmake@latest |
| 72 | + with: |
| 73 | + cmakeVersion: "~3.25.0" |
| 74 | + ninjaVersion: "^1.11.1" |
| 75 | + - name: Print installed softwares |
| 76 | + run: | |
| 77 | + clang++ --version |
| 78 | + g++ --version |
| 79 | + cmake --version |
| 80 | + ninja --version |
| 81 | + - name: Configure CMake |
| 82 | + run: | |
| 83 | + cmake -B build -S . "-DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} ${{ matrix.cmake_args.args }}" |
| 84 | + env: |
| 85 | + CC: ${{ matrix.compiler.c }} |
| 86 | + CXX: ${{ matrix.compiler.cpp }} |
| 87 | + CMAKE_GENERATOR: "Ninja Multi-Config" |
| 88 | + - name: Build Release |
| 89 | + run: | |
| 90 | + cmake --build build --config Release --verbose |
| 91 | + # cmake --build build --config Release --target all_verify_interface_header_sets |
| 92 | + cmake --install build --config Release --prefix /tmp/beman.inplace_vector |
| 93 | + find /tmp/beman.inplace_vector -type f |
| 94 | + - name: Test Release |
| 95 | + run: ctest --test-dir build --build-config Release |
| 96 | + - name: Build Debug |
| 97 | + run: | |
| 98 | + cmake --build build --config Debug --verbose |
| 99 | + # cmake --build build --config Debug --target all_verify_interface_header_sets |
| 100 | + cmake --install build --config Debug --prefix /tmp/beman.inplace_vector |
| 101 | + find /tmp/beman.inplace_vector -type f |
| 102 | + - name: Test Debug |
| 103 | + run: ctest --test-dir build --build-config Debug |
| 104 | + |
| 105 | + create-issue-when-fault: |
| 106 | + runs-on: ubuntu-latest |
| 107 | + needs: [test] |
| 108 | + if: failure() && github.event_name == 'schedule' |
| 109 | + steps: |
| 110 | + # See https://github.com/cli/cli/issues/5075 |
| 111 | + - uses: actions/checkout@v4 |
| 112 | + - name: Create issue |
| 113 | + run: | |
| 114 | + 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') |
| 115 | +
|
| 116 | + body="**Build-and-Test Failure Report** |
| 117 | + - **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z') |
| 118 | + - **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}) |
| 119 | + - **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 120 | +
|
| 121 | + The scheduled build-and-test triggered by cron has failed. |
| 122 | + Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error." |
| 123 | +
|
| 124 | + if [[ $issue_num -eq -1 ]]; then |
| 125 | + gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] Build & Test failure" --body "$body" |
| 126 | + else |
| 127 | + gh issue comment --repo ${{ github.repository }} $issue_num --body "$body" |
| 128 | + fi |
| 129 | + env: |
| 130 | + GH_TOKEN: ${{ github.token }} |
0 commit comments