diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6535626 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,35 @@ +name: CI +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + # PHP + - name: Setup PHP with Xdebug + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + coverage: xdebug + # Dependencies + - name: Install dependencies with composer + run: composer install -q --ignore-platform-reqs --no-progress --no-suggest --prefer-dist --optimize-autoloader + # Run PHPStan + - name: Run PHPStan + run: composer analyse + # Run tests + - name: Run tests with phpunit + run: export XDEBUG_MODE=coverage && composer test-coverage + # Run analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index cdcbe6e..a525fca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /reports /vendor /.idea +coverage.xml .phpunit.result.cache diff --git a/composer.json b/composer.json index e1a6138..a673c54 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "scripts": { "analyse": "vendor/bin/phpstan analyse -c phpstan.neon", "test": "vendor/bin/phpunit tests", - "test-coverage": "vendor/bin/phpunit tests --coverage-html reports/" + "test-coverage": "vendor/bin/phpunit tests --coverage-html reports/ --coverage-clover=coverage.xml" }, "extra": { "laravel": { diff --git a/resources/lang/en/geodetect.php b/resources/lang/en/geodetect.php index e109bb4..01c6571 100644 --- a/resources/lang/en/geodetect.php +++ b/resources/lang/en/geodetect.php @@ -252,4 +252,4 @@ 'ZA' => 'South Africa', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe', -]; \ No newline at end of file +]; diff --git a/resources/lang/es/geodetect.php b/resources/lang/es/geodetect.php index bcb07ac..865e73a 100644 --- a/resources/lang/es/geodetect.php +++ b/resources/lang/es/geodetect.php @@ -252,4 +252,4 @@ 'ZA' => 'Sudáfrica', 'ZM' => 'Zambia', 'ZW' => 'Zimbabue' -]; \ No newline at end of file +]; diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..58048c9 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,20 @@ +# Required metadata +sonar.projectKey=hibit-dev_geodetect +sonar.organization=hibit-dev + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=geodetect +#sonar.projectVersion=1.0 + +# Path to sources & tests +sonar.sources=src +sonar.tests=tests + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 + +# Force the language to scan +sonar.language=PHP + +# PHP Test Coverage & Execution +sonar.php.coverage.reportPaths=coverage.xml diff --git a/src/Exception/InvalidDatabaseException.php b/src/Exception/InvalidDatabaseException.php index a29b6cf..95a0f2e 100644 --- a/src/Exception/InvalidDatabaseException.php +++ b/src/Exception/InvalidDatabaseException.php @@ -7,4 +7,4 @@ class InvalidDatabaseException extends Exception { -} \ No newline at end of file +}