Skip to content

Commit 727da78

Browse files
committed
added sonar cloud scan
1 parent 06d50df commit 727da78

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/sonar.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: SonarCloud
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
sonarcloud:
12+
name: SonarCloud
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
fail-fast: true
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
23+
24+
- name: Install PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: 8
28+
tools: composer:v2
29+
coverage: xdebug
30+
31+
- name: Install dependencies
32+
run: composer install
33+
34+
- name: Execute tests
35+
run: vendor/bin/phpunit --coverage-clover=coverage-report.clover --log-junit=test-report.xml
36+
37+
- name: Fix code coverage paths
38+
run: sed -i 's/\/home\/runner\/work\/csrf-guard\/csrf-guard\//\/github\/workspace\//g' coverage-report.clover
39+
40+
- name: SonarCloud Scan
41+
uses: SonarSource/sonarcloud-github-action@master
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
45+
with:
46+
args: >
47+
-Dsonar.sources=src
48+
-Dsonar.tests=tests
49+
-Dsonar.language=php
50+
-Dsonar.sourceEncoding=UTF-8
51+
-Dsonar.php.coverage.reportPaths=coverage-report.clover
52+
-Dsonar.php.tests.reportPath=test-report.xml

0 commit comments

Comments
 (0)