Compare commits
6 Commits
dev
...
4d56b29e67
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d56b29e67 | |||
| a57108cf21 | |||
| a9569b6985 | |||
| 0c97d0bef0 | |||
| 98f0a0c154 | |||
| d5f56d8b0c |
@@ -1,14 +1,14 @@
|
|||||||
name: SonarQube
|
name: SonarQube
|
||||||
on:
|
on:
|
||||||
pull_request:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build and analyze
|
name: Build and analyze
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 20
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
|
|||||||
@@ -6,10 +6,92 @@ on:
|
|||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
tests:
|
||||||
|
name: Run Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: '9.0.x'
|
||||||
|
|
||||||
|
- name: Restore dependencies
|
||||||
|
run: dotnet restore --verbosity normal
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build --configuration Release --no-restore --verbosity normal
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: dotnet test --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx"
|
||||||
|
|
||||||
|
sonarqube:
|
||||||
|
name: SonarQube Analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 17
|
||||||
|
distribution: 'zulu'
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: '9.0.x'
|
||||||
|
|
||||||
|
- name: Install SonarQube scanner
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.sonar/scanner
|
||||||
|
dotnet tool install dotnet-sonarscanner --tool-path ~/.sonar/scanner
|
||||||
|
|
||||||
|
- name: Restore dependencies
|
||||||
|
run: dotnet restore --verbosity normal
|
||||||
|
|
||||||
|
- name: Build and analyze
|
||||||
|
env:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
run: |
|
||||||
|
~/.sonar/scanner/dotnet-sonarscanner begin \
|
||||||
|
/k:"ChatBot" \
|
||||||
|
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
|
||||||
|
/d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" \
|
||||||
|
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" \
|
||||||
|
/d:sonar.coverage.exclusions="**/Migrations/**/*.cs,**/*ModelSnapshot.cs,**/Migrations/*.cs,**/Program.cs" \
|
||||||
|
/d:sonar.exclusions="**/Migrations/**/*.cs,**/obj/**,**/bin/**,**/TestResults/**" \
|
||||||
|
/d:sonar.cpd.exclusions="**/Migrations/**/*.cs" \
|
||||||
|
/d:sonar.test.inclusions="**/*Tests.cs,**/ChatBot.Tests/**/*.cs"
|
||||||
|
dotnet build --verbosity normal --no-incremental
|
||||||
|
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./coverage/ /p:Exclude="[*]*.Migrations.*" /p:ExcludeByFile="**/Migrations/*.cs"
|
||||||
|
~/.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
||||||
|
|
||||||
|
- name: Wait for Quality Gate
|
||||||
|
run: |
|
||||||
|
sleep 10
|
||||||
|
if ! command -v jq &> /dev/null; then
|
||||||
|
sudo apt-get update && sudo apt-get install -y jq
|
||||||
|
fi
|
||||||
|
RESPONSE=$(curl -s -u "${{ secrets.SONAR_TOKEN }}:" \
|
||||||
|
"${{ secrets.SONAR_HOST_URL }}/api/qualitygates/project_status?projectKey=ChatBot")
|
||||||
|
QUALITY_GATE_STATUS=$(echo "$RESPONSE" | jq -r '.projectStatus.status')
|
||||||
|
if [ "$QUALITY_GATE_STATUS" != "OK" ]; then
|
||||||
|
echo "❌ Quality Gate failed! Status: $QUALITY_GATE_STATUS"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "✅ Quality Gate passed!"
|
||||||
|
fi
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
name: Build and Publish to Harbor
|
name: Build and Publish to Harbor
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 15
|
needs: [tests, sonarqube]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- dev
|
- develop
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
@@ -11,7 +11,6 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
name: Run Tests
|
name: Run Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
Reference in New Issue
Block a user