Skip to content

Commit

Permalink
[FEATURE] Add Travis CI and SonarQube configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
IchHabRecht committed Dec 9, 2018
1 parent 5970c37 commit f939cd2
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .travis.yml
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;
21 changes: 21 additions & 0 deletions sonar-project.properties
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

0 comments on commit f939cd2

Please sign in to comment.