Skip to content

Commit 9b4b0fe

Browse files
authored
Merge pull request #158 from splitio/feat/sonar-scanner
SonarQube scanner
2 parents 98e4093 + 9f80c74 commit 9b4b0fe

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
language: python
22

3-
python:
4-
- "2.7"
5-
- "3.6"
3+
git:
4+
depth: false
5+
6+
matrix:
7+
include:
8+
- python: '2.7'
9+
- python: '3.6'
10+
after_success:
11+
- bash sonar-scanner.sh
612

713
services:
814
- redis-server
915

16+
addons:
17+
sonarqube: true
18+
1019
install:
1120
- pip install -U setuptools pip
1221
- pip install -e .[cpphash,redis,uwsgi]

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+
sonar-scanner \
7+
-Dsonar.host.url='https://sonarqube.split-internal.com' \
8+
-Dsonar.login="$SONAR_TOKEN" \
9+
-Dsonar.ws.timeout='300' \
10+
-Dsonar.sources='splitio' \
11+
-Dsonar.projectName='python-client' \
12+
-Dsonar.projectKey='python-client' \
13+
-Dsonar.links.ci='https://travis-ci.com/splitio/python-client' \
14+
-Dsonar.links.scm='https://github.com/splitio/python-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/python-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" == 'development' ]; then
29+
TARGET_BRANCH='master'
30+
else
31+
TARGET_BRANCH='development'
32+
fi
33+
sonar_scanner \
34+
-Dsonar.branch.name=$TRAVIS_BRANCH \
35+
-Dsonar.branch.target=$TARGET_BRANCH
36+
fi

0 commit comments

Comments
 (0)