A
A
Alexander Zemlyanoy2021-03-23 01:57:26
PHP
Alexander Zemlyanoy, 2021-03-23 01:57:26

How to set up a bunch of phpunit and sonarqube on github actions?

I set up unit tests and sonar analysis to run. Now I'm trying to set up a test coverage analysis, and here I have problems. sonar writes

Mon, 22 Mar 2021 22:40:41 GMT
INFO: Analyzing PHPUnit test report: code-coverage/junit.xml
Mon, 22 Mar 2021 22:40:42 GMT
INFO: Analyzing PHPUnit coverage report: code-coverage/clover.xml
Mon, 22 Mar 2021 22:40:42 GMT
WARN: Could not resolve 18 file paths in clover.xml, first unresolved path: /home/runner/work/core-bundle/core-bundle/src/Annotations/Menu/Item.php


Pipeline code
name: CI

on: [push]

jobs:
  phpunit:
    runs-on: ubuntu-latest
    steps:
      - uses: shivammathur/[email protected]
        with:
          php-version: '7.4'
          extensions: mbstring, intl
          ini-values: post_max_size=256M
          coverage: xdebug
          tools: php-cs-fixer, phpunit
      - uses: actions/[email protected]
      - uses: php-actions/[email protected]
      - name: PHPUnit Tests
        run: ./vendor/bin/phpunit
      - name: SonarQube Scan
        uses: kitabisa/[email protected]
        with:
          host: ${{ secrets.SONARQUBE_HOST }}
          login: ${{ secrets.SONARQUBE_TOKEN }}
          projectKey: "myprod-bundle"


That is, most likely the assembly and testing are performed in one context and the analysis in another.
how to win it?
I will be grateful for any help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Zemlyanoy, 2021-03-23
@Galamoon

As expected, the problem is that the unit tests were running in the pipeline machine itself, while the sonar scanner was running in the docker image. All this is solved by replacing the ready action for the scanner by installing the scanner in the pipeline itself.
Script code:

apt-get update
apt-get install unzip wget nodejs

wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.0.2311.zip
unzip sonar-scanner-cli-4.6.0.2311.zip

./vendor/bin/phpunit --stop-on-failure

sonar-scanner-4.6.0.2311/bin/sonar-scanner \
  -Dsonar.host.url=$SONARQUBE_HOST \
  -Dsonar.login=$SONARQUBE_TOKEN

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question