From cf58516f30b4eca724e58811b2eba833f7859d53 Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Fri, 25 Dec 2020 09:22:14 -0500 Subject: [PATCH] log-code-coverage (#5) Log code coverage using explicit sonar test instead of automatic --- .github/workflows/php.yml | 22 +++++++++++++--------- composer.json | 1 - phpunit.xml.dist | 15 +++++---------- sonar-project.properties | 2 ++ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 9f9654c..5f75029 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -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 @@ -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 }} diff --git a/composer.json b/composer.json index 182291e..211e6cd 100644 --- a/composer.json +++ b/composer.json @@ -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"] diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fa2392e..dd2f550 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,21 +1,16 @@ - + colors="true"> + ./tests/ - + src diff --git a/sonar-project.properties b/sonar-project.properties index 4b594dc..5c2142c 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -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