Fix SonarQube Cloud integration #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: coverage | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ "main" ] | |
| # Actions | |
| # shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action | |
| # SonarSource/sonarqube-scan-action@v5 https://github.com/marketplace/actions/official-sonarqube-scan | |
| jobs: | |
| sonarqube-cloud: | |
| name: SonarCloud Scan and Report | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - name: Check SONAR_TOKEN secret | |
| run: | | |
| if [ -z "${{ secrets.SONAR_TOKEN }}" ]; then | |
| echo "::warning ::SONAR_TOKEN non set" | |
| exit 1 | |
| fi | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Unshallow clone to provide blame information | |
| run: git fetch --unshallow | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.4' | |
| coverage: none | |
| tools: composer:v2 | |
| - name: Get composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install project dependencies | |
| run: composer upgrade --no-interaction --no-progress --prefer-dist | |
| - name: Create code coverage | |
| run: vendor/bin/phpunit --testdox --coverage-xml=build/coverage --coverage-clover=build/coverage/clover.xml --log-junit=build/coverage/junit.xml | |
| - name: Prepare SonarCloud Code Coverage Files | |
| run: | | |
| sed 's#'$GITHUB_WORKSPACE'#/github/workspace#g' build/coverage/junit.xml > build/sonar-junit.xml | |
| sed 's#'$GITHUB_WORKSPACE'#/github/workspace#g' build/coverage/clover.xml > build/sonar-coverage.xml | |
| - name: SonarCloud Scan | |
| uses: SonarSource/sonarqube-scan-action@v5 | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |