|
| 1 | +name: Sonars |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - develop |
| 6 | + - feature/* |
| 7 | + - feat/* |
| 8 | + pull_request: |
| 9 | + types: [ opened, synchronize, reopened ] |
| 10 | +jobs: |
| 11 | + sonarcloud: |
| 12 | + name: Sonars |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v2 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Setup PHP with Xdebug |
| 21 | + uses: shivammathur/setup-php@v2 |
| 22 | + with: |
| 23 | + php-version: 7.4 |
| 24 | + coverage: xdebug |
| 25 | + |
| 26 | + - name: Install dependencies with composer |
| 27 | + run: composer update --no-ansi --no-interaction --no-progress |
| 28 | + |
| 29 | + - name: Generate coverage report with phpunit |
| 30 | + run: vendor/bin/phpunit --coverage-clover coverage.xml --log-junit report.xml --coverage-cobertura cobertura.xml |
| 31 | + |
| 32 | + - name: Monitor coverage |
| 33 | + uses: slavcodev/coverage-monitor-action@v1 |
| 34 | + with: |
| 35 | + github_token: ${{ secrets.ACTIONS_GITHUB_TOKEN }} |
| 36 | + coverage_path: coverage.xml |
| 37 | + threshold_alert: 90 |
| 38 | + threshold_warning: 95 |
| 39 | + |
| 40 | + - name: Code Coverage Summary |
| 41 | + uses: irongut/CodeCoverageSummary@v1.3.0 |
| 42 | + with: |
| 43 | + filename: cobertura.xml |
| 44 | + badge: true |
| 45 | + fail_below_min: true |
| 46 | + format: markdown |
| 47 | + output: file |
| 48 | + thresholds: '90 95' |
| 49 | + |
| 50 | + - name: Add Coverage PR Comment |
| 51 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 52 | + if: github.event_name == 'pull_request' |
| 53 | + with: |
| 54 | + path: code-coverage-results.md |
| 55 | + |
| 56 | + - name: Coverage Diff |
| 57 | + uses: clearlyip/code-coverage-report-action@v1.0.0 |
| 58 | + with: |
| 59 | + filename: coverage.xml |
| 60 | + |
| 61 | + - name: Codecov analyze |
| 62 | + uses: codecov/codecov-action@v3 |
| 63 | + with: |
| 64 | + files: coverage.xml |
| 65 | + |
| 66 | + - name: Fix phpunit files paths |
| 67 | + run: sed -i 's@'$GITHUB_WORKSPACE/'@''@g' coverage.xml report.xml |
| 68 | + |
| 69 | + - name: SonarCloud Scan |
| 70 | + uses: SonarSource/sonarcloud-github-action@master |
| 71 | + env: |
| 72 | + GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }} |
| 73 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
0 commit comments