Enabled release configuration #22
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
name: "CI tests" | |
on: [ push ] | |
jobs: | |
build: | |
name: Tests and application run on ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Windows Latest MSVC", artifact: "Windows-MSVC.tar.xz", | |
os: windows-latest, | |
build_type: "Release", cc: "cl", cxx: "cl", | |
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" | |
} | |
# - { | |
# name: "Windows Latest MinGW", artifact: "Windows-MinGW.tar.xz", | |
# os: windows-latest, | |
# build_type: "Release", cc: "gcc", cxx: "g++" | |
# } | |
- { | |
name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz", | |
os: ubuntu-latest, | |
build_type: "Release", cc: "gcc", cxx: "g++" | |
} | |
- { | |
name: "macOS Latest Clang", artifact: "macOS.tar.xz", | |
os: macos-latest, | |
build_type: "Release", cc: "clang", cxx: "clang++" | |
} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Configure | |
shell: cmake -P {0} | |
run: | | |
set(ENV{CC} ${{ matrix.config.cc }}) | |
set(ENV{CXX} ${{ matrix.config.cxx }}) | |
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") | |
execute_process( | |
COMMAND "${{ matrix.config.environment_script }}" && set | |
OUTPUT_FILE environment_script_output.txt | |
) | |
file(STRINGS environment_script_output.txt output_lines) | |
foreach(line IN LISTS output_lines) | |
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") | |
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") | |
endif() | |
endforeach() | |
endif() | |
- name: Create CMake cache | |
shell: bash | |
run: | | |
if [ "${{ matrix.config.cxx }}" == "g++" ]; then | |
git config pack.windowMemory 10m | |
git config pack.windowMemory 10m | |
cmake -S . -B cmake-build-release -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Release -DGTEST_RELATIVE_DIR=lib -DTERMINAL_EMULATOR=bash -G "Unix Makefiles" | |
cmake -S . -B cmake-build-debug -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Debug -DGTEST_RELATIVE_DIR=lib -DTERMINAL_EMULATOR=bash -G "Unix Makefiles" | |
else | |
cmake -S . -B cmake-build-release -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Release -DGTEST_RELATIVE_DIR=lib -DTERMINAL_EMULATOR=bash | |
cmake -S . -B cmake-build-debug -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_BUILD_TYPE=Debug -DGTEST_RELATIVE_DIR=lib -DTERMINAL_EMULATOR=bash | |
fi | |
- name: Build main target | |
shell: bash | |
run: | | |
cmake --build cmake-build-release --target weather-forecast || echo "Built with errors" | |
- name: Build tests target | |
shell: bash | |
run: | | |
cmake --build cmake-build-debug --target weather-forecast_tests || echo "Built with errors" | |
- name: Run program | |
shell: bash | |
working-directory: ./cmake-build-release | |
run: | | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
if [ "${{ matrix.config.cxx }}" == "g++" ]; then | |
./weather-forecast.exe --help | |
else | |
cd Debug | |
./weather-forecast.exe --help | |
fi | |
else | |
cd bin | |
./weather-forecast --help | |
fi | |
- name: Run tests | |
shell: bash | |
working-directory: ./cmake-build-debug | |
run: | | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
if [ "${{ matrix.config.cxx }}" == "g++" ]; then | |
./weather-forecast_tests_.exe | |
else | |
cd Debug | |
fi | |
else | |
cd tests | |
./weather-forecast_tests | |
fi | |
memory-leaks: | |
name: Find memory leaks in tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install valgrind | |
run: | | |
sudo apt-get update && sudo apt-get -y install valgrind | |
- name: Create CMake cache | |
run: | | |
cmake -S . -B cmake-build -DCMAKE_BUILD_TYPE=Debug | |
- name: Build tests target | |
run: | | |
cmake --build cmake-build --target weather-forecast_tests | |
- name: Run valgrind | |
working-directory: ./cmake-build/tests | |
run: | | |
valgrind --leak-check=full --track-origins=yes --error-exitcode=1 ./weather-forecast_tests |