|
| 1 | +name: "CI tests" |
| 2 | + |
| 3 | +on: [ push, workflow_dispatch ] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-mingw: |
| 7 | + name: Tests and application run on Windows Latest MinGW |
| 8 | + runs-on: windows-latest |
| 9 | + |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + |
| 13 | + - name: Create CMake cache |
| 14 | + run: | |
| 15 | + cmake -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" |
| 16 | + cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" |
| 17 | +
|
| 18 | + - name: Build main target |
| 19 | + shell: bash |
| 20 | + run: | |
| 21 | + cmake --build cmake-build-release --target cpp_tests || echo Built with errors |
| 22 | +
|
| 23 | + - name: Build tests target |
| 24 | + shell: bash |
| 25 | + run: | |
| 26 | + cmake --build cmake-build-debug --target cpp_tests_tests || echo Built with errors |
| 27 | +
|
| 28 | + - name: Run program |
| 29 | + working-directory: .\cmake-build-release |
| 30 | + run: | |
| 31 | + .\cpp_tests.exe --help |
| 32 | +
|
| 33 | + - name: Run tests |
| 34 | + working-directory: .\cmake-build-debug |
| 35 | + run: | |
| 36 | + echo "Currently unable to run tests on Windows Latest MinGW. See https://gitmemories.com/cristianadam/HelloWorld/issues/12 and https://github.com/microsoft/vscode-cmake-tools/issues/2451" |
| 37 | + % .\cpp_tests_tests.exe |
| 38 | +
|
| 39 | + build-matrix: |
| 40 | + name: Tests and application run on ${{ matrix.config.name }} |
| 41 | + runs-on: ${{ matrix.config.os }} |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + config: |
| 46 | + - { |
| 47 | + name: "Windows Latest MSVC", artifact: "Windows-MSVC.tar.xz", |
| 48 | + os: windows-latest, |
| 49 | + build_type: "Release", cc: "cl", cxx: "cl", |
| 50 | + environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" |
| 51 | + } |
| 52 | + - { |
| 53 | + name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz", |
| 54 | + os: ubuntu-latest, |
| 55 | + build_type: "Release", cc: "gcc", cxx: "g++" |
| 56 | + } |
| 57 | + - { |
| 58 | + name: "macOS Latest Clang", artifact: "macOS.tar.xz", |
| 59 | + os: macos-latest, |
| 60 | + build_type: "Release", cc: "clang", cxx: "clang++" |
| 61 | + } |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Create CMake cache |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + cmake -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release |
| 70 | + cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug |
| 71 | +
|
| 72 | + - name: Build main target |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + cmake --build cmake-build-release --target cpp_tests || echo "Built with errors" |
| 76 | +
|
| 77 | + - name: Build tests target |
| 78 | + shell: bash |
| 79 | + run: | |
| 80 | + cmake --build cmake-build-debug --target cpp_tests_tests || echo "Built with errors" |
| 81 | +
|
| 82 | + - name: Run program |
| 83 | + shell: bash |
| 84 | + working-directory: ./cmake-build-release |
| 85 | + run: | |
| 86 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 87 | + ./cpp_tests.exe --help |
| 88 | + else |
| 89 | + cd bin |
| 90 | + ./cpp_tests --help |
| 91 | + fi |
| 92 | +
|
| 93 | + - name: Run tests |
| 94 | + shell: bash |
| 95 | + working-directory: ./cmake-build-debug |
| 96 | + run: | |
| 97 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 98 | + ./cpp_tests_tests.exe |
| 99 | + else |
| 100 | + cd tests |
| 101 | + ./cpp_tests_tests |
| 102 | + fi |
| 103 | +
|
| 104 | + memory-leaks: |
| 105 | + name: Find memory leaks in tests |
| 106 | + runs-on: ubuntu-latest |
| 107 | + steps: |
| 108 | + - uses: actions/checkout@v4 |
| 109 | + |
| 110 | + - name: Install valgrind |
| 111 | + run: | |
| 112 | + sudo apt-get update && sudo apt-get -y install valgrind |
| 113 | +
|
| 114 | + - name: Create CMake cache |
| 115 | + run: | |
| 116 | + cmake -S . -B cmake-build -DCMAKE_BUILD_TYPE=Debug |
| 117 | +
|
| 118 | + - name: Build tests target |
| 119 | + run: | |
| 120 | + cmake --build cmake-build --target cpp_tests_tests |
| 121 | +
|
| 122 | + - name: Run valgrind |
| 123 | + working-directory: ./cmake-build/tests |
| 124 | + run: | |
| 125 | + valgrind --leak-check=full --track-origins=yes --error-exitcode=1 ./cpp_tests_tests |
0 commit comments