Skip to content

Commit 5d4fc11

Browse files
committed
Chore/Add SonarCloud configuration for automated analysis
1 parent a89b159 commit 5d4fc11

2 files changed

Lines changed: 44 additions & 11 deletions

File tree

.github/workflows/sonar.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: SonarCloud
2+
3+
on:
4+
push:
5+
branches: [ 'main' ]
6+
pull_request:
7+
types: [ 'opened', 'synchronize', 'reopened' ]
8+
9+
jobs:
10+
sonarcloud:
11+
name: SonarCloud Analysis
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout source code
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.3'
24+
coverage: xdebug
25+
tools: composer:v2
26+
27+
- name: Install dependencies
28+
run: composer install --prefer-dist --no-progress
29+
30+
- name: Run PHPUnit with coverage
31+
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml --log-junit=test.xml
32+
33+
- name: Fix paths in coverage reports for Sonar
34+
run: |
35+
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
36+
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' test.xml
37+
38+
- name: Run SonarCloud Scan
39+
uses: SonarSource/sonarcloud-github-action@v2
40+
with:
41+
projectBaseDir: .
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/test.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,3 @@ jobs:
4646

4747
- name: Execute Unit, Integration and Acceptance Tests
4848
run: composer test
49-
50-
- name: Fix coverage.xml for Sonar
51-
run: |
52-
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
53-
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' test.xml
54-
55-
- name: SonarCloud Scan
56-
uses: SonarSource/sonarcloud-github-action@master
57-
env:
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)