Skip to content

Commit

Permalink
CI: Use presets for testing
Browse files Browse the repository at this point in the history
Only test Release mode, which reduces number of runners needed.
  • Loading branch information
LeonMatthesKDAB committed Jan 17, 2024
1 parent 219eba4 commit 12d987b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
17 changes: 4 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
#- windows-2019
- macos-12
#- macos-11
build_type:
- Debug
- Release

steps:
- name: Checkout sources
Expand All @@ -37,22 +34,16 @@ jobs:
uses: ilammy/msvc-dev-cmd@v1

- name: Configure project
run: >
cmake -S . -B ./build -G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DKDBindings_TESTS=${{ matrix.build_type == 'Debug' }}
-DKDBindings_EXAMPLES=${{ matrix.build_type == 'Debug' }}
-DKDBindings_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
run: cmake --preset=ci

- name: Build Project
run: cmake --build ./build
run: cmake --build --preset=ci

- name: Run tests
if: ${{ matrix.build_type == 'Debug' }}
run: ctest --test-dir ./build -C ${{ matrix.build_type }} --output-on-failure
run: ctest --preset=ci

- name: Read tests log when it fails
uses: andstor/file-reader-action@v1
if: ${{ failure() && matrix.build_type == 'Debug' }}
if: ${{ failure() }}
with:
path: "./build/Testing/Temporary/LastTest.log"
37 changes: 37 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,43 @@
"KDBindings_TESTS" : "ON",
"KDBindings_EXAMPLES" : "ON"
}
},
{
"name": "ci",
"displayName": "ci",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-ci",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"KDBindings_TESTS" : "ON",
"KDBindings_EXAMPLES" : "ON",
"KDBindings_DOCS" : "ON"
}
}
],
"buildPresets": [
{
"name": "ci",
"configurePreset": "ci"
},
{
"name": "dev",
"configurePreset": "dev"
}
],
"testPresets": [
{
"name": "ci",
"configurePreset": "ci",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": true}
},
{
"name": "dev",
"configurePreset": "dev",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": false}
}
]
}

0 comments on commit 12d987b

Please sign in to comment.