fix build

This commit is contained in:
Leonid Pershin
2025-10-17 01:29:48 +03:00
parent e1244ead08
commit 768b68e10e

View File

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