forked from Nimut/phpunit-merger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add Travis CI and SonarQube configuration
- Loading branch information
1 parent
5970c37
commit f939cd2
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
language: php | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- parallel | ||
sonarcloud: | ||
organization: "ichhabrecht-github" | ||
branches: | ||
- master | ||
- pre-merge | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- $HOME/.sonar/cache | ||
|
||
jdk: | ||
- oraclejdk8 | ||
|
||
sudo: required | ||
|
||
install: | ||
- mkdir -p .Log/coverage/ .Log/log/ | ||
- > | ||
for COVERAGE in $COVERAGE_VERSIONS; do | ||
echo; | ||
echo "Installing phpunit/php-code-coverage version $COVERAGE"; | ||
echo; | ||
echo; | ||
git clean -Xdf; | ||
composer require phpunit/php-code-coverage="$COVERAGE"; | ||
git checkout composer.json; | ||
VERSION=${COVERAGE//[!0-9]/}; | ||
echo; | ||
echo "Running phpunit"; | ||
echo; | ||
echo; | ||
.Build/bin/phpunit --log-junit .Log/log/junit_$VERSION.xml --coverage-php .Log/coverage/coverage_$VERSION.cov --whitelist src/ tests/; | ||
done | ||
script: | ||
- > | ||
echo; | ||
echo "Merging log and coverage files"; | ||
echo; | ||
echo; | ||
bin/phpunit-merger coverage .Log/coverage/ .Log/coverage.xml; | ||
bin/phpunit-merger log .Log/log/ .Log/log.xml; | ||
- > | ||
echo; | ||
echo "Running php lint"; | ||
echo; | ||
echo; | ||
find . -name \*.php ! -path "./.Build/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;; | ||
jobs: | ||
fast_finish: true | ||
include: | ||
- stage: test | ||
php: 7.2 | ||
env: COVERAGE_VERSIONS="~5.0.0 ~5.1.0 ~5.2.0 ~5.3.0" | ||
- stage: test | ||
php: 7.1 | ||
env: COVERAGE_VERSIONS="~5.0.0 ~5.1.0 ~5.2.0 ~5.3.0" | ||
- stage: test | ||
php: 7.0 | ||
env: COVERAGE_VERSIONS="~5.0.0 ~5.1.0 ~5.2.0 ~5.3.0" | ||
|
||
- stage: ✔ with sonarqube scanner | ||
if: type = push AND branch IN (master, pre-merge) AND env(SONAR_TOKEN) IS present AND fork = false | ||
php: 7.2 | ||
env: COVERAGE_VERSIONS="~5.0.0 ~5.1.0 ~5.2.0 ~5.3.0" | ||
before_install: | ||
before_script: | ||
script: | ||
- > | ||
echo; | ||
echo "Merging log and coverage files"; | ||
echo; | ||
echo; | ||
bin/phpunit-merger coverage .Log/coverage/ .Log/coverage.xml; | ||
bin/phpunit-merger log .Log/junit/ .Log/junit.xml; | ||
- git fetch --unshallow || true | ||
|
||
- > | ||
echo; | ||
echo "Running SonarQube Scanner"; | ||
echo; | ||
echo; | ||
sonar-scanner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
sonar.projectKey=phpunit-merger | ||
sonar.projectName=nimut/phpunit-merger | ||
sonar.projectVersion=1.x | ||
sonar.sources=. | ||
sonar.exclusions=.Build/**, .Log/**, tests/** | ||
|
||
# Set Database Cleaner limits | ||
sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay=24 | ||
sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek=12 | ||
sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByMonth=52 | ||
|
||
# Ignore issues on multiple criteria | ||
sonar.issue.ignore.multicriteria = e1 | ||
|
||
# Exclude "String literals should not be duplicated" | ||
sonar.issue.ignore.multicriteria.e1.ruleKey=php:S1192 | ||
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.php | ||
|
||
# PHPUnit test and coverage results import | ||
sonar.php.tests.reportPath=.Log/junit.xml | ||
sonar.php.coverage.reportPaths=.Log/coverage.xml |