diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 26723ee..48148d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,9 @@ name: Test on: + push: + branches: + - master pull_request: types: [ opened, synchronize, reopened ] @@ -43,11 +46,12 @@ jobs: - name: Execute Unit, Integration and Acceptance Tests run: composer test - - name: Upload Coverage Report - uses: codecov/codecov-action@v2 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage.xml - flags: unittests - fail_ci_if_error: true + - name: Fix coverage.xml for Sonar + run: | + sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index 43cae52..939b17b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ composer.phar /vendor/ .idea/ -/infrastructure +/infrastructure/ +/coverage/ *[N|n]o[G|g]it* -*coverage* +coverage.xml +test.xml .phpunit.result.cache composer.lock diff --git a/README.md b/README.md index 9661269..87a02ac 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Criteria (a.k.a Filter) [![Test](https://github.com/ComplexHeart/php-criteria/actions/workflows/test.yml/badge.svg)](https://github.com/ComplexHeart/php-criteria/actions/workflows/test.yml) -[![codecov](https://codecov.io/gh/ComplexHeart/php-criteria/branch/main/graph/badge.svg?token=T86pvAqfl6)](https://codecov.io/gh/ComplexHeart/php-criteria) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ComplexHeart_php-criteria&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ComplexHeart_php-criteria) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ComplexHeart_php-criteria&metric=coverage)](https://sonarcloud.io/summary/new_code?id=ComplexHeart_php-criteria) Small implementation of a filter criteria pattern in PHP for Complex Heart SDK. Compose several filters using fluent interface. diff --git a/composer.json b/composer.json index 3d94cfb..96cd0d8 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ } }, "scripts": { - "test": "vendor/bin/pest --configuration=phpunit.xml --coverage-clover=coverage.xml", + "test": "vendor/bin/pest --configuration=phpunit.xml --coverage-clover=coverage.xml --log-junit=test.xml", "analyse": "vendor/bin/phpstan analyse src --no-progress --level=5" }, "config": { diff --git a/phpunit.xml b/phpunit.xml index c0ab0d0..20c06bb 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -4,14 +4,14 @@ bootstrap="vendor/autoload.php" colors="true" > - - - ./tests - - - - - ./src - - + + + ./tests + + + + + ./src + + diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..00cc55a --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,10 @@ +sonar.projectName=Complex Heart Criteria +sonar.projectKey=ComplexHeart_php-criteria +sonar.organization=complexheart +sonar.language=php +sonar.sources=./src +sonar.tests=./tests +sonar.inclusions=./src/** +sonar.exclusions=./tests/** +sonar.php.coverage.reportPaths=coverage.xml +sonar.php.tests.reportPaths=phpunit.xml