Skip to content

Commit c6726ce

Browse files
committed
refactor: migrando o SonarCloud para ficar dentro do CI
1 parent 1cf0f47 commit c6726ce

File tree

2 files changed

+57
-63
lines changed

2 files changed

+57
-63
lines changed

.github/workflows/ci-pipeline.yml

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
name: CI Pipeline
22
on:
33
pull_request:
4-
branches:
5-
- main
4+
branches: [ main ]
5+
push:
6+
branches: [ main ]
7+
68
jobs:
79
test-and-build:
10+
if: github.event_name == 'pull_request'
811
runs-on: ubuntu-latest
912
steps:
1013
- name: Checkout code
@@ -30,6 +33,56 @@ jobs:
3033

3134
- name: Run Unit tests
3235
run: dotnet test -c Release --no-build --verbosity minimal --filter Category=Unit
33-
36+
3437
- name: Run Integration tests
35-
run: dotnet test -c Release --no-build --verbosity minimal --filter Category=Integration
38+
run: dotnet test -c Release --no-build --verbosity minimal --filter Category=Integration
39+
40+
sonarcloud:
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: read
44+
pull-requests: write
45+
46+
steps:
47+
- name: Checkout code
48+
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0 # Baixa o histórico de commits do repositório
51+
52+
- name: Setup .NET 9
53+
uses: actions/setup-dotnet@v4
54+
with:
55+
dotnet-version: '9.0.x'
56+
57+
- name: Cache SonarCloud packages
58+
uses: actions/cache@v4
59+
with:
60+
path: ~/.sonar/cache # pasta onde irá ficar guardado o cache
61+
# runner.os = pega o nome do sistema operacional
62+
key: ${{ runner.os }}-sonar # Nome único para identificar o cache
63+
restore-keys: ${{ runner.os }}-sonar # Chave alternativa se não encontrar a principal
64+
65+
- name: Install SonarScanner
66+
run: dotnet tool install --global dotnet-sonarscanner
67+
68+
- name: Generate .sln for compatibility
69+
run: |
70+
echo "Generating .sln from projects..."
71+
dotnet new sln -n riber
72+
find . -name "*.csproj" -not -path "*/obj/*" -not -path "*/bin/*" | xargs dotnet sln riber.sln add
73+
echo "Solution file created:"
74+
ls -lh riber.sln
75+
76+
- name: Restore dependencies
77+
run: dotnet restore riber.sln
78+
79+
- name: Run analisys with SonarScanner
80+
env:
81+
CI: true
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
84+
SONAR_PROJECT_KEY: "${{ github.repository_owner }}_riber"
85+
SONAR_ORGANIZATION: "${{ github.repository_owner }}"
86+
run: |
87+
chmod +x analyze.sh
88+
./analyze.sh

.github/workflows/sonarqube.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)