Skip to content

Commit

Permalink
Add CI workflow with SonarCloud analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
tmekinyan committed Mar 11, 2024
1 parent 74c316c commit 8a05da1
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 4 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/reports
/vendor
/.idea
coverage.xml
.phpunit.result.cache
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/en/geodetect.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,4 @@
'ZA' => 'South Africa',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
];
];
2 changes: 1 addition & 1 deletion resources/lang/es/geodetect.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,4 @@
'ZA' => 'Sudáfrica',
'ZM' => 'Zambia',
'ZW' => 'Zimbabue'
];
];
20 changes: 20 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/Exception/InvalidDatabaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
class InvalidDatabaseException extends Exception
{

}
}

0 comments on commit 8a05da1

Please sign in to comment.