This commit is contained in:
Leonid Pershin
2025-10-17 07:23:43 +03:00
parent 9f54eb0814
commit 232c16e988

View File

@@ -16,6 +16,8 @@ jobs:
build: build:
name: Build, Test, Coverage, and Analyze name: Build, Test, Coverage, and Analyze
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
PATH: ${{ env.PATH }}:/root/.dotnet/tools
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -28,7 +30,14 @@ jobs:
run: dotnet restore run: dotnet restore
- name: Install dotnet-coverage - name: Install dotnet-coverage
run: dotnet tool install --global dotnet-coverage run: |
dotnet tool install --global dotnet-coverage
echo "Adding .dotnet/tools to PATH..."
echo 'export PATH="$PATH:/root/.dotnet/tools"' >> ~/.bashrc
export PATH="$PATH:/root/.dotnet/tools"
echo "dotnet-coverage location:"
which dotnet-coverage || echo "dotnet-coverage not found in PATH"
ls -la /root/.dotnet/tools/ | grep dotnet-coverage || echo "No dotnet-coverage in tools directory"
- name: Install SonarCloud Scanner - name: Install SonarCloud Scanner
run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
@@ -41,7 +50,22 @@ jobs:
run: dotnet build --no-incremental run: dotnet build --no-incremental
- name: Run tests and collect coverage - name: Run tests and collect coverage
run: dotnet-coverage collect "dotnet test --no-build" -f xml -o "coverage.xml" run: |
echo "Running tests and collecting coverage..."
echo "PATH: $PATH"
echo "Trying dotnet-coverage from PATH..."
if dotnet-coverage collect "dotnet test --no-build" -f xml -o "coverage.xml"; then
echo "dotnet-coverage succeeded from PATH"
elif /root/.dotnet/tools/dotnet-coverage collect "dotnet test --no-build" -f xml -o "coverage.xml"; then
echo "dotnet-coverage succeeded with full path"
else
echo "dotnet-coverage failed, trying built-in coverage collection..."
dotnet test --collect:"XPlat Code Coverage" --results-directory ./TestResults --no-build
echo "Looking for coverage files..."
find ./TestResults -name "*.xml" -exec echo "Found: {}" \;
# Convert to the expected format
find ./TestResults -name "coverage.cobertura.xml" -exec cp {} coverage.xml \;
fi
- name: List files for debug - name: List files for debug
run: ls -la run: ls -la