diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 73147ff..2d3e23b 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,39 +1,29 @@ -name: Code Analysis +name: SonarQube on: push: branches: - master - - main pull_request: types: [opened, synchronize, reopened] jobs: - analyze: - name: Code Analysis + build: + name: Build and analyze runs-on: ubuntu-latest steps: - - name: Set up JDK 17 (for SonarQube) + - name: Set up JDK 17 uses: actions/setup-java@v4 with: java-version: 17 - distribution: 'zulu' - - - name: Checkout code - uses: actions/checkout@v4 + distribution: 'zulu' # Alternative distribution options are available. + - uses: actions/checkout@v4 with: - fetch-depth: 0 - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '9.0.x' - + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Cache SonarQube Cloud packages uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - - name: Cache SonarQube Cloud scanner id: cache-sonar-scanner uses: actions/cache@v4 @@ -41,23 +31,15 @@ jobs: path: ~/.sonar/scanner key: ${{ runner.os }}-sonar-scanner restore-keys: ${{ runner.os }}-sonar-scanner - - name: Install SonarQube Cloud scanner if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' run: | mkdir -p ~/.sonar/scanner dotnet tool update dotnet-sonarscanner --tool-path ~/.sonar/scanner - - - name: Restore dependencies - run: dotnet restore - - - name: Build project - run: dotnet build --no-restore --configuration Release - - - name: Code analysis with SonarQube + - name: Build and analyze env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | ~/.sonar/scanner/dotnet-sonarscanner begin /k:"mrleo1nid_chatbot" /o:"mrleo1nid" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" - dotnet build --configuration Release + dotnet build ~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file