From 37e9ec615749ff96057cb808e9bc8197c77979d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Wed, 21 Dec 2022 00:08:11 +0100 Subject: [PATCH] Initialize SonarCloud --- .github/workflows/sonars.yml | 57 ++++++++++++++++++++++++++++++++++++ docker-compose.yml | 2 -- sonar-project.properties | 11 ++----- src/Wsdl.php | 2 +- 4 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/sonars.yml diff --git a/.github/workflows/sonars.yml b/.github/workflows/sonars.yml new file mode 100644 index 0000000..392a52a --- /dev/null +++ b/.github/workflows/sonars.yml @@ -0,0 +1,57 @@ +name: Sonars +on: + push: + branches: + - develop + - feature/* + - feat/* + - release/* + pull_request: + types: [ opened, synchronize, reopened ] +jobs: + sonarcloud: + name: Sonars + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + statuses: write + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup PHP with Xdebug + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + coverage: xdebug + + - name: Install dependencies with composer + run: composer update --no-ansi --no-interaction --no-progress + + - name: Generate coverage report with phpunit + run: vendor/bin/phpunit --coverage-clover coverage.xml --log-junit report.xml + + - name: Monitor coverage + uses: slavcodev/coverage-monitor-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + coverage_path: coverage.xml + threshold_alert: 90 + threshold_warning: 95 + + - name: Codecov analyze + uses: codecov/codecov-action@v3 + with: + files: coverage.xml + + - name: Fix phpunit files paths + run: sed -i 's@'$GITHUB_WORKSPACE/'@''@g' coverage.xml report.xml + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/docker-compose.yml b/docker-compose.yml index 7d972cf..97bd5df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.4' - services: php: build: diff --git a/sonar-project.properties b/sonar-project.properties index 4cf7402..af7f69c 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,12 +3,5 @@ sonar.organization=wsdltophp sonar.php.coverage.reportPaths=coverage.xml sonar.php.tests.reportPath=report.xml -# This is the name and version displayed in the SonarCloud UI. -#sonar.projectName=WsdlHandler -#sonar.projectVersion=1.0 - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -#sonar.sourceEncoding=UTF-8 +sonar.sources=src/ +sonar.tests=tests/ diff --git a/src/Wsdl.php b/src/Wsdl.php index f1c64aa..e8feaf0 100644 --- a/src/Wsdl.php +++ b/src/Wsdl.php @@ -91,7 +91,7 @@ protected function useParentMethodAndExternals(string $method, array $parameters return $result; } - protected function useExternalSchemas(string $method, array $parameters, $parentResult, bool $returnOne = false) + protected function useExternalSchemas(string $method, array $parameters, ?array $parentResult, bool $returnOne = false) { $result = $parentResult;