Merge pull request #171 from winterheart/ci-unittests

Enable unittests on CI
This commit is contained in:
Louis Gombert 2024-04-28 21:09:56 +00:00 committed by GitHub
commit 38f75ee9a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 42 additions and 11 deletions

View File

@ -17,6 +17,7 @@ on:
jobs:
build:
name: ${{ matrix.os.runner }}, ${{ matrix.os.cxx }}, ${{ matrix.build_type }}
strategy:
fail-fast: false
matrix:
@ -46,6 +47,9 @@ jobs:
cc: clang
cxx: clang++
name: Linux-x64-clang
build_type:
- Debug
- Release
runs-on: ${{ matrix.os.runner }}
@ -63,25 +67,23 @@ jobs:
run: |
sudo apt update
sudo apt install -y --no-install-recommends \
ninja-build cmake g++ libsdl1.2-dev libsdl-image1.2-dev libncurses-dev zlib1g-dev
ninja-build cmake g++ libgtest-dev libsdl1.2-dev libsdl-image1.2-dev libncurses-dev zlib1g-dev
- name: Configure CMake
env:
CC: ${{ matrix.os.cc }}
CXX: ${{ matrix.os.cxx }}
VCPKG_ROOT: C:/vcpkg
run: cmake --preset ${{ matrix.os.preset }}
run: cmake --preset ${{ matrix.os.preset }} -DBUILD_TESTING=ON
- name: Debug Build
run: cmake --build --preset ${{ matrix.os.preset }} --config Debug --verbose
- name: Build ${{ matrix.build_type }}
run: cmake --build --preset ${{ matrix.os.preset }} --config ${{ matrix.build_type }} --verbose
- name: Release Build
run: cmake --build --preset ${{ matrix.os.preset }} --config Release --verbose
- name: Run ${{ matrix.build_type }} Unittests
run: ctest --preset ${{ matrix.os.preset }} -C ${{ matrix.build_type }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Descent3_${{ matrix.os.name }}
path: |
${{ github.workspace }}/builds/${{ matrix.os.preset }}/Descent3/Debug/
${{ github.workspace }}/builds/${{ matrix.os.preset }}/Descent3/Release/
name: Descent3_${{ matrix.build_type }}_${{ matrix.os.name }}
path: ${{ github.workspace }}/builds/${{ matrix.os.preset }}/Descent3/${{ matrix.build_type }}/

View File

@ -9,6 +9,7 @@ brew "sdl12-compat"
brew "sdl2_image"
brew "cmake"
brew "googletest"
brew "ninja"
# zlib

View File

@ -52,5 +52,32 @@
"name": "linux",
"configurePreset": "linux"
}
],
"testPresets": [
{
"name": "defaults",
"hidden": true,
"output": {
"outputOnFailure": true
}
},
{
"name": "win",
"inherits": "defaults",
"description": "Testing under Windows",
"configurePreset": "win"
},
{
"name": "mac",
"inherits": "defaults",
"description": "Testing under macOS",
"configurePreset": "mac"
},
{
"name": "linux",
"inherits": "defaults",
"description": "Testing under Linux",
"configurePreset": "linux"
}
]
}

View File

@ -23,7 +23,7 @@
// This code taken from original byteswap.h for testing float conversion
// It cannot convert negative float numbers in 64-bit systems, so testing only non-negative numbers
#define SWAPINT(x) (int)(((x) << 24) | (((ulong)(x)) >> 24) | (((x) & 0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8))
#define SWAPINT(x) (int)(((x) << 24) | (((unsigned long)(x)) >> 24) | (((x) & 0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8))
// Stupid function to trick the compiler into letting me byteswap a float
inline float SWAPFLOAT(float x) {

View File

@ -1,6 +1,7 @@
{
"builtin-baseline": "000d1bda1ffa95a73e0b40334fa4103d6f4d3d48",
"dependencies": [
"gtest",
"zlib"
]
}