-
Notifications
You must be signed in to change notification settings - Fork 4
69 lines (59 loc) · 2.14 KB
/
sonar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: "SonarCloud Analysis"
on:
push:
branches:
- main
paths:
- 'src/**'
- 'tests/**'
- 'sonar-project.properties'
- '.github/workflows/sonar.yml'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'src/**'
- 'tests/**'
- 'sonar-project.properties'
- '.github/workflows/sonar.yml'
# Allow manually triggering the workflow
workflow_dispatch:
jobs:
sonarcloud:
name: "Analyze with Sonar"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
ini-values: "error_reporting=-1, display_errors=On, display_startup_errors=On, zend.assertions=1"
tools: "composer:v2"
php-version: "7.4"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress --prefer-dist"
- name: "Calculate code coverage"
run: "composer ut -- --coverage-clover=reports/coverage.clover --log-junit=reports/test.xml"
- name: "Fix code coverage paths"
working-directory: ./reports
run: |
sed -i 's/\/home\/runner\/work\/${{ github.event.repository.name }}\/${{ github.event.repository.name }}\///g' coverage.clover
sed -i 's/\/home\/runner\/work\/${{ github.event.repository.name }}\/${{ github.event.repository.name }}\///g' test.xml
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}