From 428aed25dd00bcf88a1938f7ad1829059044b59f Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Mon, 20 Oct 2025 16:24:14 +0800 Subject: [PATCH 01/12] ci: build release of opencppcoverage --- .../continuous-integration-workflow.yml | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 21d8bec0..77aa0eeb 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -1,9 +1,9 @@ -name: Unit tests +name: build Release on: [push, pull_request] jobs: build: - name: Unit tests + name: build Release runs-on: windows-latest steps: - name: Checkout @@ -16,22 +16,7 @@ jobs: uses: microsoft/setup-msbuild@v1.0.0 - name: Build solution - run: msbuild /m CppCoverage.sln /p:Configuration=Debug /p:Platform=x64 + run: msbuild /m CppCoverage.sln /t:OpenCppCoverage /p:Configuration=Release /p:Platform=x64 - - name: Run CppCoverageTest - run: .\x64\Debug\CppCoverageTest.exe --gtest_filter=-CodeCoverageRunnerTest.OptimizedBuild # Require VS2013 - - - name: Run ExporterTest - run: .\x64\Debug\ExporterTest.exe - - - name: Run FileFilterTest - run: .\x64\Debug\FileFilterTest.exe --gtest_filter=-RelocationsExtractorTest.Extract # Require mspdbcore.dll - - - name: Run OpenCppCoverageTest - run: .\x64\Debug\OpenCppCoverageTest.exe - - - name: Run PluginTest - run: .\x64\Debug\PluginTest.exe - - - name: Run ToolsTest - run: .\x64\Debug\ToolsTest.exe + - name: show list under build path + run: dir .\x64\Release From ddd412e19d40f7a2d7736ae8241c67e687215e4c Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Tue, 21 Oct 2025 16:48:22 +0800 Subject: [PATCH 02/12] ci: fix outdated steps --- .github/workflows/continuous-integration-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 77aa0eeb..ec7e6444 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -13,7 +13,7 @@ jobs: run: ./InstallThirdPartyLibraries.ps1 - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.0.0 + uses: microsoft/setup-msbuild@v2 - name: Build solution run: msbuild /m CppCoverage.sln /t:OpenCppCoverage /p:Configuration=Release /p:Platform=x64 From 22471be0865bfd646bc9f5599323eadb5eabb590 Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Tue, 21 Oct 2025 17:09:38 +0800 Subject: [PATCH 03/12] ci: update msvc version from 142 to 143 --- CppCoverage/CppCoverage.vcxproj | 8 ++++---- CppCoverageTest/CppCoverageTest.vcxproj | 8 ++++---- Exporter/Exporter.vcxproj | 8 ++++---- ExporterTest/ExporterTest.vcxproj | 8 ++++---- FileFilter/FileFilter.vcxproj | 8 ++++---- FileFilterTest/FileFilterTest.vcxproj | 8 ++++---- OpenCppCoverage/OpenCppCoverage.vcxproj | 8 ++++---- OpenCppCoverageTest/OpenCppCoverageTest.vcxproj | 8 ++++---- Plugin/Plugin.vcxproj | 8 ++++---- PluginTest/PluginTest.vcxproj | 8 ++++---- TestCoverageConsole/TestCoverageConsole.vcxproj | 8 ++++---- .../TestCoverageOptimizedBuild.vcxproj | 8 ++++---- TestCoverageSharedLib/TestCoverageSharedLib.vcxproj | 8 ++++---- TestCppCli/TestCppCli.vcxproj | 8 ++++---- TestHelper/TestHelper.vcxproj | 8 ++++---- Tools/Tools.vcxproj | 8 ++++---- ToolsTest/ToolsTest.vcxproj | 8 ++++---- 17 files changed, 68 insertions(+), 68 deletions(-) diff --git a/CppCoverage/CppCoverage.vcxproj b/CppCoverage/CppCoverage.vcxproj index d258a95a..4174acfa 100644 --- a/CppCoverage/CppCoverage.vcxproj +++ b/CppCoverage/CppCoverage.vcxproj @@ -28,26 +28,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/CppCoverageTest/CppCoverageTest.vcxproj b/CppCoverageTest/CppCoverageTest.vcxproj index e9117137..d93f7a0d 100644 --- a/CppCoverageTest/CppCoverageTest.vcxproj +++ b/CppCoverageTest/CppCoverageTest.vcxproj @@ -28,26 +28,26 @@ Application true - v142 + v143 Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode diff --git a/Exporter/Exporter.vcxproj b/Exporter/Exporter.vcxproj index 18c3a2a7..7786ac33 100644 --- a/Exporter/Exporter.vcxproj +++ b/Exporter/Exporter.vcxproj @@ -27,26 +27,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/ExporterTest/ExporterTest.vcxproj b/ExporterTest/ExporterTest.vcxproj index ad849acc..9222c6a4 100644 --- a/ExporterTest/ExporterTest.vcxproj +++ b/ExporterTest/ExporterTest.vcxproj @@ -28,26 +28,26 @@ Application true - v142 + v143 Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode diff --git a/FileFilter/FileFilter.vcxproj b/FileFilter/FileFilter.vcxproj index e1bc72ab..8a04507b 100644 --- a/FileFilter/FileFilter.vcxproj +++ b/FileFilter/FileFilter.vcxproj @@ -28,26 +28,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/FileFilterTest/FileFilterTest.vcxproj b/FileFilterTest/FileFilterTest.vcxproj index 5d130697..891b3251 100644 --- a/FileFilterTest/FileFilterTest.vcxproj +++ b/FileFilterTest/FileFilterTest.vcxproj @@ -28,26 +28,26 @@ Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode diff --git a/OpenCppCoverage/OpenCppCoverage.vcxproj b/OpenCppCoverage/OpenCppCoverage.vcxproj index c4d0e273..0246d0a0 100644 --- a/OpenCppCoverage/OpenCppCoverage.vcxproj +++ b/OpenCppCoverage/OpenCppCoverage.vcxproj @@ -28,26 +28,26 @@ Application true - v142 + v143 Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode diff --git a/OpenCppCoverageTest/OpenCppCoverageTest.vcxproj b/OpenCppCoverageTest/OpenCppCoverageTest.vcxproj index 1b968038..9da5d156 100644 --- a/OpenCppCoverageTest/OpenCppCoverageTest.vcxproj +++ b/OpenCppCoverageTest/OpenCppCoverageTest.vcxproj @@ -28,26 +28,26 @@ Application true - v142 + v143 Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode diff --git a/Plugin/Plugin.vcxproj b/Plugin/Plugin.vcxproj index f58006f9..9b8415dd 100644 --- a/Plugin/Plugin.vcxproj +++ b/Plugin/Plugin.vcxproj @@ -29,26 +29,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/PluginTest/PluginTest.vcxproj b/PluginTest/PluginTest.vcxproj index 3745cbd1..d9eb4e4f 100644 --- a/PluginTest/PluginTest.vcxproj +++ b/PluginTest/PluginTest.vcxproj @@ -29,26 +29,26 @@ Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode diff --git a/TestCoverageConsole/TestCoverageConsole.vcxproj b/TestCoverageConsole/TestCoverageConsole.vcxproj index dc21394d..ff66c648 100644 --- a/TestCoverageConsole/TestCoverageConsole.vcxproj +++ b/TestCoverageConsole/TestCoverageConsole.vcxproj @@ -28,26 +28,26 @@ Application true - v142 + v143 Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application false - v142 + v143 true Unicode diff --git a/TestCoverageOptimizedBuild/TestCoverageOptimizedBuild.vcxproj b/TestCoverageOptimizedBuild/TestCoverageOptimizedBuild.vcxproj index abacdce8..4f8825ce 100644 --- a/TestCoverageOptimizedBuild/TestCoverageOptimizedBuild.vcxproj +++ b/TestCoverageOptimizedBuild/TestCoverageOptimizedBuild.vcxproj @@ -29,26 +29,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/TestCoverageSharedLib/TestCoverageSharedLib.vcxproj b/TestCoverageSharedLib/TestCoverageSharedLib.vcxproj index ce4b7308..2ea3eb7b 100644 --- a/TestCoverageSharedLib/TestCoverageSharedLib.vcxproj +++ b/TestCoverageSharedLib/TestCoverageSharedLib.vcxproj @@ -28,26 +28,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/TestCppCli/TestCppCli.vcxproj b/TestCppCli/TestCppCli.vcxproj index f140de77..33c00c52 100644 --- a/TestCppCli/TestCppCli.vcxproj +++ b/TestCppCli/TestCppCli.vcxproj @@ -30,22 +30,22 @@ DynamicLibrary - v142 + v143 Unicode DynamicLibrary - v142 + v143 Unicode DynamicLibrary - v142 + v143 Unicode DynamicLibrary - v142 + v143 Unicode diff --git a/TestHelper/TestHelper.vcxproj b/TestHelper/TestHelper.vcxproj index 5cb57483..58a6075d 100644 --- a/TestHelper/TestHelper.vcxproj +++ b/TestHelper/TestHelper.vcxproj @@ -28,26 +28,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/Tools/Tools.vcxproj b/Tools/Tools.vcxproj index 4da5368c..34ea0cfc 100644 --- a/Tools/Tools.vcxproj +++ b/Tools/Tools.vcxproj @@ -28,26 +28,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/ToolsTest/ToolsTest.vcxproj b/ToolsTest/ToolsTest.vcxproj index 7ef96f3c..9e676048 100644 --- a/ToolsTest/ToolsTest.vcxproj +++ b/ToolsTest/ToolsTest.vcxproj @@ -28,26 +28,26 @@ Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode From 7f372a0a3987e7d46718d580f85f419c2198915d Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Tue, 21 Oct 2025 17:17:54 +0800 Subject: [PATCH 04/12] ci: fix wstring --- Tools/Tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/Tool.cpp b/Tools/Tool.cpp index 1a28475e..2b1513da 100644 --- a/Tools/Tool.cpp +++ b/Tools/Tool.cpp @@ -18,7 +18,7 @@ #include "Tool.hpp" #include -#include +#include #include #include #include From da84e3fa9fdcdc4eb3a3da4dc50b5d7ae7f8665f Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Tue, 21 Oct 2025 17:29:55 +0800 Subject: [PATCH 05/12] ci: fix cpp --- FileFilter/UnifiedDiffCoverageFilter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FileFilter/UnifiedDiffCoverageFilter.cpp b/FileFilter/UnifiedDiffCoverageFilter.cpp index d29df048..c687bdbb 100644 --- a/FileFilter/UnifiedDiffCoverageFilter.cpp +++ b/FileFilter/UnifiedDiffCoverageFilter.cpp @@ -35,7 +35,10 @@ namespace FileFilter std::wifstream ifs(unifiedDiffPath.wstring()); if (!ifs) - std::runtime_error("The file " + unifiedDiffPath.string() + " cannot be opened."); + { + std::runtime_error errorInfo = std::runtime_error("The file " + unifiedDiffPath.string() + " cannot be opened."); + LOG_DEBUG << errorInfo.what(); + } auto files = UnifiedDiffParser{}.Parse(ifs); LOG_DEBUG << L"Unified diff: " << unifiedDiffPath; From 99a13a47b03bd41fb8c2d689c03d106a6077ebb6 Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Wed, 22 Oct 2025 09:47:10 +0800 Subject: [PATCH 06/12] ci: add release steps --- .../continuous-integration-workflow.yml | 21 +++++++++++++++++++ VERSION.txt | 1 + 2 files changed, 22 insertions(+) create mode 100644 VERSION.txt diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index ec7e6444..cc52af86 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -20,3 +20,24 @@ jobs: - name: show list under build path run: dir .\x64\Release + + - name: release package + shell: pwsh + run: | + $version = Get-Content .\VERSION.txt + $commitId = git rev-list --no-merges -n 1 HEAD + $tagName = "v$version" + + # Check if tag already exists + $existingTag = git tag -l $tagName + if (-not $existingTag) { + git tag $tagName $commitId + git push origin $tagName + + # Create GitHub release + gh release create $tagName .\x64\Release\OpenCppCoverage.exe --title "OpenCppCoverage $version" --notes "Release $version" + } else { + Write-Host "Tag $tagName already exists, skipping release creation" + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 00000000..8a9ecc2e --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +0.0.1 \ No newline at end of file From c1ca4b7caa6bad0ab393364378633d26821f23db Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Wed, 22 Oct 2025 09:50:14 +0800 Subject: [PATCH 07/12] ci: remove pr build --- .github/workflows/continuous-integration-workflow.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index cc52af86..e5c087c3 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -1,5 +1,5 @@ name: build Release -on: [push, pull_request] +on: [push] jobs: build: @@ -22,6 +22,7 @@ jobs: run: dir .\x64\Release - name: release package + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') shell: pwsh run: | $version = Get-Content .\VERSION.txt From ebb09ebb947a0aa36b087b0b70af377db718190c Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Wed, 22 Oct 2025 09:51:10 +0800 Subject: [PATCH 08/12] ci: remove only create release for master or release branch --- .github/workflows/continuous-integration-workflow.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index e5c087c3..748f9f07 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -22,7 +22,6 @@ jobs: run: dir .\x64\Release - name: release package - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') shell: pwsh run: | $version = Get-Content .\VERSION.txt From 353ade727be041a0a8dbfc1442e37299cc883aec Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Wed, 22 Oct 2025 09:58:17 +0800 Subject: [PATCH 09/12] ci: fix release --- .github/workflows/continuous-integration-workflow.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 748f9f07..f75925e1 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -5,6 +5,8 @@ jobs: build: name: build Release runs-on: windows-latest + permissions: + contents: write # Required for creating releases and pushing tags steps: - name: Checkout uses: actions/checkout@v2 @@ -24,6 +26,10 @@ jobs: - name: release package shell: pwsh run: | + # Configure git to use the GitHub token for authentication + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@github.com" + $version = Get-Content .\VERSION.txt $commitId = git rev-list --no-merges -n 1 HEAD $tagName = "v$version" From da6916b3d271f83b34dce3eaa4a16a6184b0629a Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Wed, 22 Oct 2025 10:07:22 +0800 Subject: [PATCH 10/12] ci: add codeQL scan --- .../continuous-integration-workflow.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index f75925e1..b655e43b 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -7,10 +7,23 @@ jobs: runs-on: windows-latest permissions: contents: write # Required for creating releases and pushing tags + strategy: + fail-fast: false + matrix: + include: + - language: c-cpp + build-mode: manual steps: - name: Checkout uses: actions/checkout@v2 + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + - name: Install third party libraries run: ./InstallThirdPartyLibraries.ps1 @@ -20,8 +33,10 @@ jobs: - name: Build solution run: msbuild /m CppCoverage.sln /t:OpenCppCoverage /p:Configuration=Release /p:Platform=x64 - - name: show list under build path - run: dir .\x64\Release + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" - name: release package shell: pwsh From 84c53dc225f8c31c6e85ffed83dc390082e98445 Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Wed, 22 Oct 2025 11:06:01 +0800 Subject: [PATCH 11/12] ci: fix codeql permission --- .github/workflows/continuous-integration-workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index b655e43b..7c98b296 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -6,6 +6,8 @@ jobs: name: build Release runs-on: windows-latest permissions: + security-events: write + actions: read contents: write # Required for creating releases and pushing tags strategy: fail-fast: false From 8268530b77be301e5451ce889ec7cf4690368734 Mon Sep 17 00:00:00 2001 From: Robin Zhao Date: Wed, 22 Oct 2025 14:10:40 +0800 Subject: [PATCH 12/12] ci: fix tag and release check --- .../continuous-integration-workflow.yml | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 7c98b296..1b16280d 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -51,16 +51,43 @@ jobs: $commitId = git rev-list --no-merges -n 1 HEAD $tagName = "v$version" - # Check if tag already exists + # Set error action preference to continue on error + $ErrorActionPreference = "Continue" + + # Check if tag already exists locally $existingTag = git tag -l $tagName - if (-not $existingTag) { + + # Check if GitHub release already exists + $existingRelease = $null + try { + $existingRelease = gh release view $tagName 2>$null + } catch { + # Release doesn't exist, which is fine + } + + if (-not $existingTag -and -not $existingRelease) { + Write-Host "Creating new tag and release: $tagName" + + # Create and push tag git tag $tagName $commitId - git push origin $tagName + $tagResult = git push origin $tagName - # Create GitHub release - gh release create $tagName .\x64\Release\OpenCppCoverage.exe --title "OpenCppCoverage $version" --notes "Release $version" - } else { - Write-Host "Tag $tagName already exists, skipping release creation" + if ($LASTEXITCODE -eq 0) { + # Create GitHub release + $releaseResult = gh release create $tagName .\x64\Release\OpenCppCoverage.exe --title "OpenCppCoverage $version" --notes "Release $version" + + if ($LASTEXITCODE -eq 0) { + Write-Host "Successfully created release $tagName" + } else { + Write-Host "Failed to create GitHub release for $tagName, but tag was created" + } + } else { + Write-Host "Failed to push tag $tagName" + } + } elseif ($existingTag) { + Write-Host "Tag $tagName already exists locally, skipping release creation" + } elseif ($existingRelease) { + Write-Host "Release $tagName already exists on GitHub, skipping release creation" } env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}