Skip to content

Sonarcloud GitHub action for PHP library #1

Sonarcloud GitHub action for PHP library

Sonarcloud GitHub action for PHP library #1

name: SonarCloud Analysis
on: [push, pull_request, pull_request_target]
permissions:
contents: read
jobs:
analyse:
name: Analyse
if: github.repository == 'web-eid/web-eid-authtoken-validation-php'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run SonarCloud Scan
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
-Dsonar.projectKey="web-eid_web-eid-authtoken-validation-php" \
-Dsonar.token=${{secrets.SONAR_TOKEN}} \
-Dsonar.organization="web-eid" \
-Dsonar.host.url="https://sonarcloud.io" \
-Dsonar.php.tests.reportPath=tests/report.xml \
-Dsonar.php.coverage.reportPaths=coverage/clover.xml