-
-
Notifications
You must be signed in to change notification settings - Fork 436
71 lines (63 loc) · 2.31 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
70
71
name: Sonar
on:
# Run automatically every Monday on midnight.
schedule:
- cron: '0 0 * * 1'
workflow_call:
# Allow manually triggering the workflow.
workflow_dispatch:
jobs:
unit:
name: Unit Tests on ${{ matrix.php }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 5
matrix:
os: [ubuntu-latest]
php: ['7.4', '8.1']
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring
tools: composer, pecl, phpcs, phpstan, phpunit:9.5
ini-values: pcov.directory=api, post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: pcov #optional, setup coverage driver
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
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 --dev -n --prefer-source --ignore-platform-req=php+
- name: Run Unit Tests
run: phpunit --configuration ./dev/phpunit.xml.dist --testsuite=Unit;
- name: prepare SonarCloud Scan Data
continue-on-error: true
if: ${{ matrix.php == '8.1' }}
run: |
echo $PWD
ls -la
head ./dev/tests/clover.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./dev/tests/junit.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./dev/tests/clover.xml
head ./dev/tests/clover.xml
ls -la
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
continue-on-error: true
if: ${{ matrix.php == '8.1' }} && SONAR_TOKEN
with:
args: >
-Dproject.settings=dev/sonar-project.properties
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}