diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c03561..6b9c569 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,6 +38,14 @@ jobs: - run: vendor/bin/rector process --dry-run if: ${{ failure() || success() }} + - run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover ./clover.xml --log-junit ./phpunit.report.xml + if: ${{ failure() || success() }} + + # https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747 + # $GITHUB_WORKSPACE contains a slash so @ is used as delimiter + - run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' clover.xml + - run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' phpunit.report.xml + - uses: sonarsource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any @@ -48,3 +56,6 @@ jobs: -Dsonar.projectKey=assoconnect_linxo-client -Dsonar.organization=assoconnect -Dsonar.sources=src + -Dsonar.tests=tests + -Dsonar.php.coverage.reportPaths=clover.xml + -Dsonar.php.tests.reportPath=phpunit.report.xml diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..ec76bf9 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,13 @@ + + + + + ./tests/ + + + + + ./src + + +