fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: ChatBot CI/CD
|
name: Code Analysis
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -7,23 +7,9 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
analyze:
|
||||||
name: Build and Test
|
name: Code Analysis
|
||||||
runs-on: windows-latest
|
runs-on: ubuntu-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
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set up JDK 17 (for SonarQube)
|
- name: Set up JDK 17 (for SonarQube)
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
@@ -44,7 +30,7 @@ jobs:
|
|||||||
- 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
|
||||||
|
|
||||||
@@ -52,16 +38,15 @@ jobs:
|
|||||||
id: cache-sonar-scanner
|
id: cache-sonar-scanner
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ${{ runner.temp }}\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'
|
||||||
shell: powershell
|
|
||||||
run: |
|
run: |
|
||||||
New-Item -Path ${{ runner.temp }}\scanner -ItemType Directory
|
mkdir -p ~/.sonar/scanner
|
||||||
dotnet tool update dotnet-sonarscanner --tool-path ${{ runner.temp }}\scanner
|
dotnet tool update dotnet-sonarscanner --tool-path ~/.sonar/scanner
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
@@ -69,21 +54,10 @@ jobs:
|
|||||||
- name: Build project
|
- name: Build project
|
||||||
run: dotnet build --no-restore --configuration Release
|
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
|
- name: Code analysis with SonarQube
|
||||||
env:
|
env:
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
shell: powershell
|
|
||||||
run: |
|
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
|
dotnet build --configuration Release
|
||||||
${{ runner.temp }}\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
||||||
Reference in New Issue
Block a user