rew
This commit is contained in:
@@ -1,58 +1,44 @@
|
|||||||
name: SonarCloud
|
name: SonarQube
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches:
|
||||||
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
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:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build, Test, Coverage, and Analyze
|
name: Build and analyze
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: mcr.microsoft.com/dotnet/sdk:9.0
|
|
||||||
env:
|
|
||||||
PATH: ${{ env.PATH }}:/root/.dotnet/tools
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Set up JDK 17
|
||||||
run: echo "Checking out code..." && pwd && ls -la
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 17
|
||||||
|
distribution: 'zulu' # Alternative distribution options are available.
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
run: echo "Setting up .NET..." && dotnet --version && echo "Dotnet is available"
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: '9.0.x'
|
||||||
|
- name: Install SonarQube Cloud scanner
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.sonar/scanner
|
||||||
|
dotnet tool install dotnet-sonarscanner --tool-path ~/.sonar/scanner
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore --verbosity normal
|
||||||
|
- name: Build and analyze
|
||||||
- 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 test --collect:"XPlat Code Coverage" --results-directory ./TestResults --no-build
|
|
||||||
|
|
||||||
- name: List files for debug
|
|
||||||
run: ls -la
|
|
||||||
|
|
||||||
- name: Print coverage.xml for debug
|
|
||||||
run: find ./TestResults -name "*.xml" -exec echo "Found: {}" \;
|
|
||||||
|
|
||||||
- name: End SonarCloud analysis
|
|
||||||
run: ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
|
||||||
env:
|
env:
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
run: |
|
||||||
|
echo "Starting SonarQube analysis..."
|
||||||
|
echo "Current directory: $(pwd)"
|
||||||
|
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 }}"
|
||||||
|
echo "Building project..."
|
||||||
|
dotnet build --verbosity normal
|
||||||
|
echo "Ending SonarQube analysis..."
|
||||||
|
~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
||||||
Reference in New Issue
Block a user