can you clarify a bit more about what is missing to get the coverage for your project?
In the documentation, you mentioned a complete example build workflow is provided.
Did you already analyze your project with a GitHub action, or do you still use Autoscan?
At this point, you should be in the onboarding tutorial specific to your CI. Follow the tutorial and when it asks, What option best describes your build?, choose Other (for JS, TS, Go, Python, PHP, …). When you are done with the tutorial, you should have a functioning CI-based analysis setup for your PHP project. The next step is to adjust it to get coverage working.
Thank you so much for your replying. i made file in github build.yml with configuration like in documentation but result was coverage:none and there isnot scan sonar like in documtation. i use php:7.4.26
thank you for providing your GitHub workflow. I can not see where you trigger the SonarQube Analysis in your workflow. To be able to generate a coverage report with PHPUnit you need a coverage provider like Xdebug (you defined none as a provider).
In addition, your PHPUnit command does not create a coverage file.
- name: Run tests with phpunit/phpunit
run: vendor/bin/phpunit --coverage-clover=coverage.xml
At least make sure that you add the coverage analysis to your sonar-project.properties file like this
Thank you so much for replying:) God bless you. i install xdebug x2.0 but can i addded xdebug in this previous workflow result ?
i added coverage analysis in sonar-project.properties.
this is my workflow i created in github.
- name: Setup PHP with Xdebug 2.x
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: xdebug2
- name: Install dependencies with composer
run: composer update --no-ansi --no-interaction --no-progress
- name: Run tests with phpunit/phpunit
run: vendor/bin/phpunit --coverage-clover=coverage.xml
- name: Fix code coverage paths
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
# must be unique in a given SonarQube instance
sonar.projectKey=my:shoppingcartww
sonar.php.coverage.reportPaths=coverage.xml
# --- optional properties ---
# defaults to project key
#sonar.projectName=My project
# defaults to 'not provided'
#sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
#sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
Thank you for providing these two configurations. I wonder how you execute the scanner. Following the guide, you can do it also via the GitHub Action workflow.
Thank you for your helping. but i have problem with unit test is none in my project although i made test by phpunit and there is percentage of coverage.
Glad to see that you managed to create the report and include it in the analysis. Unfortunately, I don’t understand your question. If you are not using PHPUnit to create your test cases, what test framework are you using?
I create use phpunit but unit test in picture no information. I need know number of unit test i put. Report.xml in sonar .php.tests.reportpath=phpunit.report.xml
But still no information