diff --git a/.github/workflows/cpp-tests.yml b/.github/workflows/cpp-tests.yml index 5055b946..396181b5 100644 --- a/.github/workflows/cpp-tests.yml +++ b/.github/workflows/cpp-tests.yml @@ -12,13 +12,8 @@ on: workflow_dispatch: env: - # Path to the solution file relative to the root of the project. - SOLUTION_FILE_PATH: ./Sources/backend-cpp/Windows/com.ctytler.dcs.sdPlugin.sln - - # Configuration type to build. - # You can convert this to a build matrix if you need coverage of multiple configuration types. - # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - BUILD_CONFIGURATION: Release + SOURCE_DIR: ./Sources/backend-cpp + BUILD_DIR: ./Sources/backend-cpp/build jobs: build: @@ -26,20 +21,20 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 + + - name: Install Ninja + run: choco install ninja -y + shell: powershell - - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v1.1 + - name: Install Boost + run: vcpkg install boost-thread:x64-windows - - name: Restore NuGet packages - working-directory: ${{env.GITHUB_WORKSPACE}} - run: nuget restore ${{env.SOLUTION_FILE_PATH}} + - name: CMake + run: cmake -G Ninja -S ${{env.SOURCE_DIR}} -B ${{env.BUILD_DIR}} -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DCMAKE_TOOLCHAIN_FILE=C:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build - working-directory: ${{env.GITHUB_WORKSPACE}} - # Add additional options to the MSBuild command line here (like platform or verbosity level). - # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference - run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} + run: cmake --build ${{env.BUILD_DIR}} - name: Setup OpenCppCoverage and add to PATH id: setup_opencppcoverage @@ -50,7 +45,16 @@ jobs: - name: Run C++ Unit Tests and Generate Coverage Report id: generate_test_report shell: cmd - run: OpenCppCoverage.exe --sources Sources\backend-cpp --excluded_sources Vendor --excluded_sources Windows --export_type cobertura:StreamdeckDcsInterfaceCov.xml .\Sources\backend-cpp\Windows\x64\Release\Test.exe + run: | + OpenCppCoverage.exe ^ + --quiet ^ + --sources Sources\backend-cpp ^ + --excluded_sources Vendor ^ + --excluded_sources Windows ^ + --excluded_sources Tools ^ + --export_type cobertura:StreamdeckDcsInterfaceCov.xml ^ + --cover_children ^ + -- ctest --test-dir ./${{env.BUILD_DIR}} --output-on-failure - name: Upload Report to Codecov uses: codecov/codecov-action@v5 @@ -58,3 +62,5 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} files: ./StreamdeckDcsInterfaceCov.xml flags: Cpp + disable_search: true + diff --git a/Sources/backend-cpp/StreamdeckContext/BackwardsCompatibilityHandler.cpp b/Sources/backend-cpp/StreamdeckContext/BackwardsCompatibilityHandler.cpp index 44f93b83..a7d77799 100644 --- a/Sources/backend-cpp/StreamdeckContext/BackwardsCompatibilityHandler.cpp +++ b/Sources/backend-cpp/StreamdeckContext/BackwardsCompatibilityHandler.cpp @@ -5,6 +5,10 @@ #include json backwardsCompatibilityHandler(const json &prevVersionPayload) { + if (prevVersionPayload.empty()) { + return prevVersionPayload; + } + json payload = prevVersionPayload; const auto prevSettings = prevVersionPayload["settings"]; if (!prevSettings.contains("send_address") && prevSettings.contains("device_id") && diff --git a/Tools/build_plugin.bat b/Tools/build_plugin.bat index 422b2179..01957267 100644 --- a/Tools/build_plugin.bat +++ b/Tools/build_plugin.bat @@ -5,22 +5,19 @@ :: Change directory to the project root (directory above this batch file location) cd /D "%~dp0"\.. -:: Restore NuGet packages -MSBuild.exe .\Sources\backend-cpp\Windows\com.ctytler.dcs.sdPlugin.sln /t:Restore /p:RestorePackagesConfig=true -if %errorlevel% neq 0 echo "Canceling plugin build due to failure to restore NuGet packages" && pause && exit /b %errorlevel% - :: Build C++ executable: -MSBuild.exe .\Sources\backend-cpp\Windows\com.ctytler.dcs.sdPlugin.sln /p:Configuration="Release" +cmake -G Ninja -S ./Sources/backend-cpp -B ./Sources/backend-cpp/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON +cmake --build ./Sources/backend-cpp/build if %errorlevel% neq 0 echo "Canceling plugin build due to failed backend build" && pause && exit /b %errorlevel% :: Run unit tests, only continue if all tests pass -Sources\backend-cpp\Windows\x64\Release\Test.exe +ctest --test-dir ./Sources/backend-cpp/build --output-on-failure if %errorlevel% neq 0 echo "Canceling plugin build due to failed unit tests" && pause && exit /b %errorlevel% :: Copy C++ executable and DLLs to StreamDeck Plugin package: echo. && echo *** C++ binary compilation complete, published to Sources/com.ctytler.dcs.sdPlugin/bin/ *** && echo. -copy Sources\backend-cpp\Windows\x64\Release\streamdeck_dcs_interface.exe Sources\com.ctytler.dcs.sdPlugin\bin\ -copy Sources\backend-cpp\Windows\x64\Release\*.dll Sources\com.ctytler.dcs.sdPlugin\bin\ +copy Sources\backend-cpp\build\bin\StreamdeckInterface.exe Sources\com.ctytler.dcs.sdPlugin\bin\streamdeck_dcs_interface.exe +copy Sources\backend-cpp\build\bin\*.dll Sources\com.ctytler.dcs.sdPlugin\bin\ :: Remove any prior build of the Plugin: echo. && echo *** Removing any previous builds of com.ctytler.dcs.streamDeckPlugin from Release/ *** diff --git a/codecov.yml b/codecov.yml index a7ee2619..f679c028 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,15 +1,24 @@ +codecov: + require_ci_to_pass: true + notify: + after_n_builds: 2 + coverage: status: - default_rules: project: - default: - target: auto - threshold: 1% + cpp: + informational: true flags: - Cpp + + react: + informational: true + flags: - ReactJS -codecov: - notify: - after_n_builds: 2 + patch: + default: + informational: true + comment: after_n_builds: 2 +