Skip to content

Commit f939cd2

Browse files
committed
[FEATURE] Add Travis CI and SonarQube configuration
1 parent 5970c37 commit f939cd2

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

.travis.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
language: php
2+
3+
addons:
4+
apt:
5+
packages:
6+
- parallel
7+
sonarcloud:
8+
organization: "ichhabrecht-github"
9+
branches:
10+
- master
11+
- pre-merge
12+
13+
cache:
14+
directories:
15+
- $HOME/.composer/cache
16+
- $HOME/.sonar/cache
17+
18+
jdk:
19+
- oraclejdk8
20+
21+
sudo: required
22+
23+
install:
24+
- mkdir -p .Log/coverage/ .Log/log/
25+
- >
26+
for COVERAGE in $COVERAGE_VERSIONS; do
27+
echo;
28+
echo "Installing phpunit/php-code-coverage version $COVERAGE";
29+
echo;
30+
echo;
31+
git clean -Xdf;
32+
composer require phpunit/php-code-coverage="$COVERAGE";
33+
git checkout composer.json;
34+
VERSION=${COVERAGE//[!0-9]/};
35+
36+
echo;
37+
echo "Running phpunit";
38+
echo;
39+
echo;
40+
.Build/bin/phpunit --log-junit .Log/log/junit_$VERSION.xml --coverage-php .Log/coverage/coverage_$VERSION.cov --whitelist src/ tests/;
41+
done
42+
43+
script:
44+
- >
45+
echo;
46+
echo "Merging log and coverage files";
47+
echo;
48+
echo;
49+
bin/phpunit-merger coverage .Log/coverage/ .Log/coverage.xml;
50+
bin/phpunit-merger log .Log/log/ .Log/log.xml;
51+
52+
- >
53+
echo;
54+
echo "Running php lint";
55+
echo;
56+
echo;
57+
find . -name \*.php ! -path "./.Build/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;;
58+
59+
jobs:
60+
fast_finish: true
61+
include:
62+
- stage: test
63+
php: 7.2
64+
env: COVERAGE_VERSIONS="~5.0.0 ~5.1.0 ~5.2.0 ~5.3.0"
65+
- stage: test
66+
php: 7.1
67+
env: COVERAGE_VERSIONS="~5.0.0 ~5.1.0 ~5.2.0 ~5.3.0"
68+
- stage: test
69+
php: 7.0
70+
env: COVERAGE_VERSIONS="~5.0.0 ~5.1.0 ~5.2.0 ~5.3.0"
71+
72+
- stage: ✔ with sonarqube scanner
73+
if: type = push AND branch IN (master, pre-merge) AND env(SONAR_TOKEN) IS present AND fork = false
74+
php: 7.2
75+
env: COVERAGE_VERSIONS="~5.0.0 ~5.1.0 ~5.2.0 ~5.3.0"
76+
before_install:
77+
before_script:
78+
script:
79+
- >
80+
echo;
81+
echo "Merging log and coverage files";
82+
echo;
83+
echo;
84+
bin/phpunit-merger coverage .Log/coverage/ .Log/coverage.xml;
85+
bin/phpunit-merger log .Log/junit/ .Log/junit.xml;
86+
87+
- git fetch --unshallow || true
88+
89+
- >
90+
echo;
91+
echo "Running SonarQube Scanner";
92+
echo;
93+
echo;
94+
sonar-scanner;

sonar-project.properties

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
sonar.projectKey=phpunit-merger
2+
sonar.projectName=nimut/phpunit-merger
3+
sonar.projectVersion=1.x
4+
sonar.sources=.
5+
sonar.exclusions=.Build/**, .Log/**, tests/**
6+
7+
# Set Database Cleaner limits
8+
sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay=24
9+
sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek=12
10+
sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByMonth=52
11+
12+
# Ignore issues on multiple criteria
13+
sonar.issue.ignore.multicriteria = e1
14+
15+
# Exclude "String literals should not be duplicated"
16+
sonar.issue.ignore.multicriteria.e1.ruleKey=php:S1192
17+
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.php
18+
19+
# PHPUnit test and coverage results import
20+
sonar.php.tests.reportPath=.Log/junit.xml
21+
sonar.php.coverage.reportPaths=.Log/coverage.xml

0 commit comments

Comments
 (0)