Skip to content

Commit

Permalink
Add project to sonarcloud.io
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipxe13 committed Feb 23, 2022
1 parent 8916a8a commit 7ed9e8d
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
/sonar-project.properties export-ignore
65 changes: 65 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,68 @@ jobs:
path: build/coverage
- name: infection
run: infection --skip-initial-tests --coverage=build/coverage --no-progress --no-interaction --logger-github

sonarcloud-secrets:
name: SonarCloud check secrets are present
runs-on: ubuntu-latest
outputs:
github: ${{ steps.check-secrets.outputs.github }}
sonar: ${{ steps.check-secrets.outputs.sonar }}
steps:
- name: Check secrets are present
id: check-secrets
run: |
if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then
echo "::set-output name=github::yes"
else
echo "::set-output name=github::no"
echo "::warning ::GITHUB_TOKEN non set"
fi
if [ -n "${{ secrets.SONAR_TOKEN }}" ]; then
echo "::set-output name=sonar::yes"
else
echo "::set-output name=sonar::no"
echo "::warning ::SONAR_TOKEN non set"
fi
sonarcloud:
name: SonarCloud Scan and Report
needs: [ "tests-coverage", "sonarcloud-secrets" ]
if: ${{ needs.sonarcloud-secrets.outputs.github == 'yes' && needs.sonarcloud-secrets.outputs.sonar == 'yes' }}
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow clone to provide blame information
run: git fetch --unshallow
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none
tools: composer:v2
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install project dependencies
run: composer upgrade --no-interaction --no-progress --prefer-dist
- name: Obtain code coverage
uses: actions/download-artifact@v2
with:
name: code-coverage
path: build/coverage
- name: Prepare SonarCloud Code Coverage Files
run: |
sed 's#'$GITHUB_WORKSPACE'#/github/workspace#g' build/coverage/junit.xml > build/sonar-junit.xml
sed 's#'$GITHUB_WORKSPACE'#/github/workspace#g' build/coverage/clover.xml > build/sonar-coverage.xml
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# phpcfdi/sat-estado-cfdi

[![Source Code][badge-source]][source]
[![Packagist PHP Version Support][badge-php-version]][php-version]
[![Discord][badge-discord]][discord]
[![Latest Version][badge-release]][release]
[![Software License][badge-license]][license]
[![Build Status][badge-build]][build]
[![Scrutinizer][badge-quality]][quality]
[![Coverage Status][badge-coverage]][coverage]
[![Reliability][badge-reliability]][reliability]
[![Maintainability][badge-maintainability]][maintainability]
[![Code Coverage][badge-coverage]][coverage]
[![Violations][badge-violations]][violations]
[![Total Downloads][badge-downloads]][downloads]

> Consulta el estado de un CFDI en el webservice del SAT
Expand Down Expand Up @@ -218,17 +222,25 @@ and licensed for use under the MIT License (MIT). Please see [LICENSE][] for mor
[todo]: https://github.com/phpcfdi/sat-estado-cfdi/blob/main/docs/TODO.md

[source]: https://github.com/phpcfdi/sat-estado-cfdi
[php-version]: https://packagist.org/packages/phpcfdi/sat-estado-cfdi
[discord]: https://discord.gg/aFGYXvX
[release]: https://github.com/phpcfdi/sat-estado-cfdi/releases
[license]: https://github.com/phpcfdi/sat-estado-cfdi/blob/main/LICENSE
[build]: https://github.com/phpcfdi/sat-estado-cfdi/actions/workflows/build.yml?query=branch:main
[quality]: https://scrutinizer-ci.com/g/phpcfdi/sat-estado-cfdi/
[coverage]: https://scrutinizer-ci.com/g/phpcfdi/sat-estado-cfdi/code-structure/main/code-coverage
[reliability]:https://sonarcloud.io/component_measures?id=phpcfdi_sat-estado-cfdi&metric=Reliability
[maintainability]: https://sonarcloud.io/component_measures?id=phpcfdi_sat-estado-cfdi&metric=Maintainability
[coverage]: https://sonarcloud.io/component_measures?id=phpcfdi_sat-estado-cfdi&metric=Coverage
[violations]: https://sonarcloud.io/project/issues?id=phpcfdi_sat-estado-cfdi&resolved=false
[downloads]: https://packagist.org/packages/phpcfdi/sat-estado-cfdi

[badge-source]: https://img.shields.io/badge/source-phpcfdi/sat--estado--cfdi-blue?style=flat-square
[badge-release]: https://img.shields.io/github/release/phpcfdi/sat-estado-cfdi?style=flat-square
[badge-license]: https://img.shields.io/github/license/phpcfdi/sat-estado-cfdi?style=flat-square
[badge-build]: https://img.shields.io/github/workflow/status/phpcfdi/sat-estado-cfdi/build/main?style=flat-square
[badge-quality]: https://img.shields.io/scrutinizer/g/phpcfdi/sat-estado-cfdi/main?style=flat-square
[badge-coverage]: https://img.shields.io/scrutinizer/coverage/g/phpcfdi/sat-estado-cfdi/main?style=flat-square
[badge-downloads]: https://img.shields.io/packagist/dt/phpcfdi/sat-estado-cfdi?style=flat-square
[badge-source]: https://img.shields.io/badge/source-phpcfdi/sat--estado--cfdi-blue?logo=github
[badge-discord]: https://img.shields.io/discord/459860554090283019?logo=discord
[badge-php-version]: https://img.shields.io/packagist/php-v/phpcfdi/sat-estado-cfdi?logo=php
[badge-release]: https://img.shields.io/github/release/phpcfdi/sat-estado-cfdi?logo=git
[badge-license]: https://img.shields.io/github/license/phpcfdi/sat-estado-cfdi?logo=open-source-initiative
[badge-build]: https://img.shields.io/github/workflow/status/phpcfdi/sat-estado-cfdi/build/main?logo=github-actions
[badge-reliability]: https://sonarcloud.io/api/project_badges/measure?project=phpcfdi_sat-estado-cfdi&metric=reliability_rating
[badge-maintainability]: https://sonarcloud.io/api/project_badges/measure?project=phpcfdi_sat-estado-cfdi&metric=sqale_rating
[badge-coverage]: https://img.shields.io/sonar/coverage/phpcfdi_sat-estado-cfdi/main?logo=sonarcloud&server=https%3A%2F%2Fsonarcloud.io
[badge-violations]: https://img.shields.io/sonar/violations/phpcfdi_sat-estado-cfdi/main?format=long&logo=sonarcloud&server=https%3A%2F%2Fsonarcloud.io
[badge-downloads]: https://img.shields.io/packagist/dt/phpcfdi/sat-estado-cfdi?logo=packagist
10 changes: 10 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sonar.organization=phpcfdi
sonar.projectKey=phpcfdi_sat-estado-cfdi
sonar.sourceEncoding=UTF-8
sonar.language=php
sonar.sources=src
sonar.tests=tests
sonar.exclusions=vendor/,tools/,build/,tests/_files/
sonar.working.directory=build/.scannerwork
sonar.php.tests.reportPath=build/sonar-junit.xml
sonar.php.coverage.reportPaths=build/sonar-coverage.xml

0 comments on commit 7ed9e8d

Please sign in to comment.