diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index e3e2cee..73147ff 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,4 +1,4 @@ -name: ChatBot CI/CD +name: Code Analysis on: push: branches: @@ -7,23 +7,9 @@ on: pull_request: types: [opened, synchronize, reopened] jobs: - build: - name: Build and Test - runs-on: windows-latest - services: - postgres: - image: postgres:15 - env: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - POSTGRES_DB: chatbot_test - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 + analyze: + name: Code Analysis + runs-on: ubuntu-latest steps: - name: Set up JDK 17 (for SonarQube) uses: actions/setup-java@v4 @@ -44,7 +30,7 @@ jobs: - name: Cache SonarQube Cloud packages uses: actions/cache@v4 with: - path: ~\sonar\cache + path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar @@ -52,16 +38,15 @@ jobs: id: cache-sonar-scanner uses: actions/cache@v4 with: - path: ${{ runner.temp }}\scanner + 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' - shell: powershell run: | - New-Item -Path ${{ runner.temp }}\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path ${{ runner.temp }}\scanner + mkdir -p ~/.sonar/scanner + dotnet tool update dotnet-sonarscanner --tool-path ~/.sonar/scanner - name: Restore dependencies run: dotnet restore @@ -69,21 +54,10 @@ jobs: - name: Build project run: dotnet build --no-restore --configuration Release - - name: Run tests - run: dotnet test --no-build --configuration Release --verbosity normal - env: - ConnectionStrings__DefaultConnection: "Host=localhost;Port=5432;Database=chatbot_test;Username=postgres;Password=postgres" - - - name: Run database migrations - run: dotnet ef database update --context ChatBotDbContext --no-build - env: - ConnectionStrings__DefaultConnection: "Host=localhost;Port=5432;Database=chatbot_test;Username=postgres;Password=postgres" - - name: Code analysis with SonarQube env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - shell: powershell run: | - ${{ runner.temp }}\scanner\dotnet-sonarscanner begin /k:"mrleo1nid_chatbot" /o:"mrleo1nid" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" + ~/.sonar/scanner/dotnet-sonarscanner begin /k:"mrleo1nid_chatbot" /o:"mrleo1nid" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" dotnet build --configuration Release - ${{ runner.temp }}\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file + ~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file