Skip to content

Commit 386024f

Browse files
authored
Merge pull request #138 from splitio/feat/sonar-scanner
SonarQube scanner
2 parents 3f8ce45 + ade707f commit 386024f

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*.phar
22
.idea
3-
*.sh
43
*~
54
ci
65
composer.lock
@@ -23,3 +22,6 @@ test.php
2322

2423
# phpenv
2524
.php-version
25+
26+
# Sonarqube
27+
.scannerwork

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
language: php
22

3+
git:
4+
depth: false
5+
36
env:
47
global:
58
- COMPOSER_DISABLE_XDEBUG_WARN=1
69

710
matrix:
811
include:
912
- dist: precise
10-
php: '5.3'
13+
php: '5.4'
1114
- dist: xenial
1215
php: '7.2'
16+
after_success:
17+
- bash sonar-scanner.sh
1318

1419
services:
1520
- redis-server

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
"require-dev": {
2828
"phpunit/phpunit": "~4.0",
2929
"phpdocumentor/phpdocumentor": "2.*",
30-
"squizlabs/php_codesniffer": "2.*"
30+
"squizlabs/php_codesniffer": "2.*",
31+
"rogervila/php-sonarqube-scanner": "0.4.0"
3132
},
32-
33+
3334
"autoload": {
3435
"psr-4": {
3536
"SplitIO\\": "src/SplitIO/",

sonar-scanner.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#/bin/bash -e
2+
3+
sonar_scanner() {
4+
local params="$@"
5+
6+
vendor/bin/sonar-scanner \
7+
-Dsonar.host.url='https://sonarqube.split-internal.com' \
8+
-Dsonar.login="$SONAR_TOKEN" \
9+
-Dsonar.ws.timeout='300' \
10+
-Dsonar.sources='./src' \
11+
-Dsonar.projectName='php-client' \
12+
-Dsonar.exclusions='**/tests/**/*.*' \
13+
-Dsonar.links.ci='https://travis-ci.com/splitio/php-client' \
14+
-Dsonar.links.scm='https://github.com/splitio/php-client' \
15+
"${params}"
16+
17+
return $?
18+
}
19+
20+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
21+
sonar_scanner \
22+
-Dsonar.pullrequest.provider='GitHub' \
23+
-Dsonar.pullrequest.github.repository='splitio/php-client' \
24+
-Dsonar.pullrequest.key=$TRAVIS_PULL_REQUEST \
25+
-Dsonar.pullrequest.branch=$TRAVIS_PULL_REQUEST_BRANCH \
26+
-Dsonar.pullrequest.base=$TRAVIS_BRANCH
27+
else
28+
if [ "$TRAVIS_BRANCH" == 'develop' ]; then
29+
TARGET_BRANCH='master'
30+
else
31+
TARGET_BRANCH='develop'
32+
fi
33+
sonar_scanner \
34+
-Dsonar.branch.name=$TRAVIS_BRANCH \
35+
-Dsonar.branch.target=$TARGET_BRANCH
36+
fi

0 commit comments

Comments
 (0)