diff --git a/ChatBot/.gitea/workflows/build.yml b/ChatBot/.gitea/workflows/build.yml new file mode 100644 index 0000000..73147ff --- /dev/null +++ b/ChatBot/.gitea/workflows/build.yml @@ -0,0 +1,63 @@ +name: Code Analysis +on: + push: + branches: + - master + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + analyze: + name: Code Analysis + runs-on: ubuntu-latest + steps: + - name: Set up JDK 17 (for SonarQube) + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'zulu' + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - 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 + with: + 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 + 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 + ~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file