55 lines
1.7 KiB
YAML
55 lines
1.7 KiB
YAML
name: SonarCloud
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
|
|
env:
|
|
DOTNET_VERSION: '9.0.x'
|
|
SONAR_PROJECT_KEY: 'mrleo1nid_chatbot'
|
|
SONAR_ORG: 'mrleo1nid'
|
|
SONAR_HOST_URL: 'https://sonarcloud.io'
|
|
|
|
jobs:
|
|
build:
|
|
name: Build, Test, Coverage, and Analyze
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Install dotnet-coverage
|
|
run: dotnet tool install --global dotnet-coverage
|
|
|
|
- name: Install SonarCloud Scanner
|
|
run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
|
|
- name: Begin SonarCloud analysis
|
|
run: ./.sonar/scanner/dotnet-sonarscanner begin /k:"${{ env.SONAR_PROJECT_KEY }}" /o:"${{ env.SONAR_ORG }}" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ env.SONAR_HOST_URL }}" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml"
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
|
|
- name: Build
|
|
run: dotnet build --no-incremental
|
|
|
|
- name: Run tests and collect coverage
|
|
run: dotnet-coverage collect "dotnet test --no-build" -f xml -o "coverage.xml"
|
|
|
|
- name: List files for debug
|
|
run: ls -la
|
|
|
|
- name: Print coverage.xml for debug
|
|
run: cat coverage.xml
|
|
|
|
- name: End SonarCloud analysis
|
|
run: ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |