Skip to content

Commit

Permalink
log-code-coverage (#5)
Browse files Browse the repository at this point in the history
Log code coverage using explicit sonar test instead of automatic
  • Loading branch information
kdebisschop authored Dec 25, 2020
1 parent 8637889 commit cf58516
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
php-version: ${{ matrix.php-version }}
ini-values: post_max_size=256M, log_errors=1
coverage: pcov
coverage: xdebug

- name: Validate composer.json and composer.lock
run: composer validate
Expand Down Expand Up @@ -56,15 +56,19 @@ jobs:
run: composer run-script analyze

- name: Run test suite
run: composer run-script coverage
run: composer run-script test -- --coverage-clover=clover.xml --log-junit=junit.xml

- name: Run test suite
- name: Estimate coverage
if: ${{ matrix.php-version == '7.4' }}
run: composer run-script infection

# - name: SonarCloud Scan
# if: ${{ matrix.php-version == '7.4' }}
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Process clover file
if: ${{ matrix.php-version == '7.4' }}
run: sed 's~/home/runner/work/php-etl-google-analytics-extractor/php-etl-google-analytics-extractor/~~' clover.xml > coverage.xml

- name: SonarCloud Scan
if: ${{ matrix.php-version == '7.4' }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"cs": "phpcs -p -s",
"analyze": "phpstan --memory-limit=256M analyze",
"test": "phpunit",
"coverage": "phpunit --coverage-clover coverage.xml --log-junit junit.xml",
"infection": "infection",
"scan": ["@fixer", "@cs", "@analyze"],
"check": ["@scan", "@test"]
Expand Down
15 changes: 5 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
colors="true">

<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
Expand Down
2 changes: 2 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
sonar.projectKey=kdebisschop_php-etl-google-analytics-extractor
sonar.organization=kdebisschop
sonar.language=php
sonar.sourceEncoding=UTF-8
sonar.php.tests.reportPath=junit.xml
sonar.php.coverage.reportPaths=coverage.xml
sonar.sources=src
Expand Down

0 comments on commit cf58516

Please sign in to comment.