-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run unit tests on the CI server on check-in
Also, enable running unit tests at build time for desktop builds. To enable: cmake -DRUN_UNIT_TESTS=ON path/to/CMakeLists.txt
- Loading branch information
1 parent
568c6a3
commit 709236d
Showing
6 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage. | ||
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml | ||
name: run unit tests on the desktop build | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | ||
BUILD_TYPE: Release | ||
QT_VERSION: 6.6.1 | ||
|
||
jobs: | ||
build: | ||
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. | ||
# You can convert this to a matrix build if you need cross-platform coverage. | ||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout repository and submodules | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update -yq && | ||
sudo apt-get install -y g++ build-essential mesa-common-dev libssl-dev \ | ||
wget lsb libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev p7zip-full \ | ||
ninja-build dos2unix libegl1 libxcb-cursor0 | ||
sudo snap install yq | ||
- name: Install Qt ${{env.QT_VERSION}} linux desktop | ||
if: steps.cached_qt_emscripten.outputs.cache-hit != 'true' | ||
uses: jurplel/install-qt-action@v3 | ||
with: | ||
aqtversion: '==3.1.*' | ||
version: "${{env.QT_VERSION}}" | ||
host: 'linux' | ||
target: 'desktop' | ||
arch: 'gcc_64' | ||
modules: 'qtwebsockets qt5compat qtshadertools' | ||
dir: '/opt/hostedtoolcache' | ||
|
||
- name: Configure CMake | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: | | ||
export QTDIR=/opt/hostedtoolcache/Qt/$QT_VERSION/gcc_64 | ||
mkdir build && cd build | ||
${QTDIR}/bin/qt-cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ../tests | ||
- name: Build unit tests | ||
run: | | ||
cd build | ||
cmake --build . --config ${{env.BUILD_TYPE}} | ||
- name: Run unit test | ||
run: | | ||
cd build | ||
# The following line needs 'QT_QPA_PLATFORM=offscreen' in order to run on the headless CI server | ||
QT_DEBUG_PLUGINS=1 QT_QPA_PLATFORM=offscreen ctest --rerun-failed --output-on-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,4 @@ target_link_libraries(tst_units PRIVATE | |
Qt6::Quick | ||
) | ||
|
||
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) |