|
| 1 | +name: SonarCloud Analysis |
| 2 | + |
| 3 | +on: [push, pull_request, pull_request_target] |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | + |
| 8 | +jobs: |
| 9 | + analyse: |
| 10 | + name: Analyse |
| 11 | + if: github.repository == 'web-eid/web-eid-authtoken-validation-php' |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Set up PHP |
| 19 | + uses: shivammathur/setup-php@v2 |
| 20 | + with: |
| 21 | + php-version: '8.3' |
| 22 | + |
| 23 | + - name: Validate composer.json and composer.lock |
| 24 | + run: composer validate --strict |
| 25 | + |
| 26 | + - name: Cache Composer packages |
| 27 | + id: composer-cache |
| 28 | + uses: actions/cache@v4 |
| 29 | + with: |
| 30 | + path: vendor |
| 31 | + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} |
| 32 | + restore-keys: | |
| 33 | + ${{ runner.os }}-php- |
| 34 | +
|
| 35 | + - name: Install dependencies |
| 36 | + run: composer install --prefer-dist --no-progress |
| 37 | + |
| 38 | + - name: Install SonarScanner |
| 39 | + run: | |
| 40 | + wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/4.8.0.2856/sonar-scanner-cli-4.8.0.2856-linux.zip |
| 41 | + unzip sonar-scanner-cli-4.8.0.2856-linux.zip |
| 42 | + sudo mv sonar-scanner-4.8.0.2856-linux /opt/sonar-scanner |
| 43 | + echo "/opt/sonar-scanner/bin" >> $GITHUB_PATH |
| 44 | +
|
| 45 | + - name: Verify SonarScanner Installation |
| 46 | + run: sonar-scanner --version |
| 47 | + |
| 48 | + - name: Run SonarCloud Scan |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 52 | + run: | |
| 53 | + sonar-scanner \ |
| 54 | + -Dsonar.projectKey="web-eid_web-eid-authtoken-validation-php" \ |
| 55 | + -Dsonar.token=${{secrets.SONAR_TOKEN}} \ |
| 56 | + -Dsonar.organization="web-eid" \ |
| 57 | + -Dsonar.host.url="https://sonarcloud.io" \ |
| 58 | + -Dsonar.php.tests.reportPath=tests/report.xml \ |
| 59 | + -Dsonar.php.coverage.reportPaths=coverage/clover.xml |
0 commit comments