diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 21d8bec0..1b16280d 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -1,37 +1,93 @@ -name: Unit tests -on: [push, pull_request] +name: build Release +on: [push] jobs: build: - name: Unit tests + 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 + 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 - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.0.0 + uses: microsoft/setup-msbuild@v2 - 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: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" - - name: Run CppCoverageTest - run: .\x64\Debug\CppCoverageTest.exe --gtest_filter=-CodeCoverageRunnerTest.OptimizedBuild # Require VS2013 + - 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" - - name: Run ExporterTest - run: .\x64\Debug\ExporterTest.exe + $version = Get-Content .\VERSION.txt + $commitId = git rev-list --no-merges -n 1 HEAD + $tagName = "v$version" - - name: Run FileFilterTest - run: .\x64\Debug\FileFilterTest.exe --gtest_filter=-RelocationsExtractorTest.Extract # Require mspdbcore.dll + # Set error action preference to continue on error + $ErrorActionPreference = "Continue" - - name: Run OpenCppCoverageTest - run: .\x64\Debug\OpenCppCoverageTest.exe + # Check if tag already exists locally + $existingTag = git tag -l $tagName - - name: Run PluginTest - run: .\x64\Debug\PluginTest.exe + # Check if GitHub release already exists + $existingRelease = $null + try { + $existingRelease = gh release view $tagName 2>$null + } catch { + # Release doesn't exist, which is fine + } - - name: Run ToolsTest - run: .\x64\Debug\ToolsTest.exe + if (-not $existingTag -and -not $existingRelease) { + Write-Host "Creating new tag and release: $tagName" + + # Create and push tag + git tag $tagName $commitId + $tagResult = git push origin $tagName + + 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 }} 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/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; 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/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 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 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