diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a12b8137..062049f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,38 +1,88 @@ -name: Checkmarx One visual studio extension CI - +name: Checkmarx One Visual Studio Extension CI on: [ pull_request, workflow_dispatch ] - permissions: write-all jobs: integration-tests: - runs-on: windows-latest - permissions: - contents: write + runs-on: windows-2022 + steps: - name: Fetch Sources uses: actions/checkout@v4 - - - name: Setup VSTest - uses: darenm/Setup-VSTest@3a16d909a1f3bbc65b52f8270d475d905e7d3e44 #v1 - + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '6.0.x' # Use .NET 6.x + - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@1ff57057b5cfdc39105cd07a01d78e9b0ea0c14c #v1.3.1 + uses: microsoft/setup-msbuild@v2 with: vs-version: '17.2' - - - name: Restore NuGet packages - run: nuget restore . - - - name: Restore - run: dotnet restore . - - - name: Build - run: msbuild /p:Configuration=Release /p:DeployExtension=False - - - name: Tests - env: - CX_APIKEY: ${{ secrets.CX_APIKEY }} - run: vstest.console.exe /InIsolation .\ast-visual-studio-extension-tests\bin\Release\net60-windows\ast-visual-studio-extension-tests.dll - - + + - name: Install Required Developer Packs + run: | + choco install netfx-4.0.3-devpack + choco install visualstudio2022buildtools + choco install visualstudio2022-workload-manageddesktop + choco install visualstudio2022-workload-visualstudioextension + + - name: Diagnostics and Preparation + run: | + dotnet --info + Get-ChildItem -Recurse -Filter *.csproj | Select-Object FullName + + - name: Restore NuGet Packages + run: | + dotnet nuget locals all --clear + dotnet restore + + - name: Prepare Test Project + shell: pwsh + run: | + $testProject = Get-ChildItem -Recurse -Filter "ast-visual-studio-extension-tests.csproj" | Select-Object -First 1 + + if ($testProject) { + Write-Host "Preparing test project: $($testProject.FullName)" + + dotnet add $testProject.FullName package Microsoft.NET.Test.Sdk + dotnet add $testProject.FullName package coverlet.collector + dotnet add $testProject.FullName package Newtonsoft.Json + + dotnet add $testProject.FullName package Microsoft.VisualStudio.SDK + dotnet add $testProject.FullName package Microsoft.VSSDK.BuildTools + } else { + Write-Error "Test project not found" + exit 1 + } + + - name: Build Solution + run: | + msbuild /p:Configuration=Release /p:DeployExtension=False /p:VSSDKTargetPlatformRegRootSuffix=Exp /p:GenerateResourceUsePreserializedResources=true + + - name: Run Tests with Coverage + shell: pwsh + run: | + $testProject = Get-ChildItem -Recurse -Filter "ast-visual-studio-extension-tests.csproj" | Select-Object -First 1 + + if ($testProject) { + Write-Host "Running tests with coverage for: $($testProject.FullName)" + + dotnet test $testProject.FullName --configuration Release /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=./coverage/ + } else { + Write-Error "Test project not found" + exit 1 + } + + - name: Upload Test Results + uses: actions/upload-artifact@v3 + with: + name: test-results + path: | + **/*.trx + + - name: Upload Coverage Report + uses: actions/upload-artifact@v3 + with: + name: coverage-report + path: ./coverage/ diff --git a/ast-visual-studio-extension/ast-visual-studio-extension.csproj b/ast-visual-studio-extension/ast-visual-studio-extension.csproj index e769f223..edc06102 100644 --- a/ast-visual-studio-extension/ast-visual-studio-extension.csproj +++ b/ast-visual-studio-extension/ast-visual-studio-extension.csproj @@ -6,7 +6,7 @@ Default - v4.7.2 + net6.0-windows true true @@ -170,7 +170,7 @@ - + 7.5.1