From 2da83d8b84b5aadd0570bd813873e0d3c8731d25 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Fri, 17 Oct 2025 06:35:26 +0300 Subject: [PATCH] add cov --- .gitea/workflows/build.yml | 19 +++++++++++++++++-- .gitea/workflows/test.yml | 6 +++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 35d2ad9..07fdf92 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -26,9 +26,11 @@ jobs: run: | mkdir -p ~/.sonar/scanner dotnet tool install dotnet-sonarscanner --tool-path ~/.sonar/scanner + - name: Install dotnet-coverage + run: dotnet tool install --global dotnet-coverage - name: Restore dependencies run: dotnet restore --verbosity normal - - name: Build and analyze + - name: SonarQube begin env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | @@ -37,8 +39,21 @@ jobs: echo "Listing files:" ls -la echo "Installing SonarQube scanner..." - ~/.sonar/scanner/dotnet-sonarscanner begin /k:"mrleo1nid_chatbot" /o:"mrleo1nid" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + ~/.sonar/scanner/dotnet-sonarscanner begin /k:"mrleo1nid_chatbot" /o:"mrleo1nid" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml + + - name: Build project + run: | echo "Building project..." dotnet build --verbosity normal + + - name: Run tests with coverage + run: | + echo "Running tests with coverage..." + dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml" + + - name: SonarQube end + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | echo "Ending SonarQube analysis..." ~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index c425fc3..e4bce39 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -30,20 +30,20 @@ jobs: run: dotnet build --no-restore --verbosity normal - name: Run unit tests - run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./TestResults + run: dotnet test --no-build --verbosity normal --results-directory ./TestResults - name: Generate test report if: always() run: | echo "Test results:" find ./TestResults -name "*.trx" -exec echo "Found test result file: {}" \; - find ./TestResults -name "*.xml" -exec echo "Found coverage file: {}" \; - name: Upload test results if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: test-results path: ./TestResults/ retention-days: 30 + if-no-files-found: warn