From cf7911eb407236c33023e709a9244952666402c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Daniel=20Fad=C3=B3n?= Date: Fri, 25 Oct 2019 16:16:22 -0300 Subject: [PATCH 1/2] SonarQube scanner --- .travis.yml | 15 ++++++++++++--- sonar-scanner.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 sonar-scanner.sh diff --git a/.travis.yml b/.travis.yml index 3f9423e9..87e9a0b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,21 @@ language: python -python: - - "2.7" - - "3.6" +git: + depth: false + +matrix: + include: + python: '2.7' + python: '3.6' + after_success: + - bash sonar-scanner.sh services: - redis-server +addons: + sonarqube: true + install: - pip install -U setuptools pip - pip install -e .[cpphash,redis,uwsgi] diff --git a/sonar-scanner.sh b/sonar-scanner.sh new file mode 100644 index 00000000..37ab5a27 --- /dev/null +++ b/sonar-scanner.sh @@ -0,0 +1,36 @@ +#/bin/bash -e + +sonar_scanner() { + local params=$@ + + sonar-scanner \ + -Dsonar.host.url='https://sonarqube.split-internal.com' \ + -Dsonar.login="$SONAR_TOKEN" \ + -Dsonar.ws.timeout='300' \ + -Dsonar.sources='splitio' \ + -Dsonar.projectName='python-client' \ + -Dsonar.projectKey='python-client' \ + -Dsonar.links.ci='https://travis-ci.com/splitio/python-client' \ + -Dsonar.links.scm='https://github.com/splitio/python-client' \ + ${params} + + return $? +} + +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + sonar_scanner \ + -Dsonar.pullrequest.provider='GitHub' \ + -Dsonar.pullrequest.github.repository='splitio/python-client' \ + -Dsonar.pullrequest.key=$TRAVIS_PULL_REQUEST \ + -Dsonar.pullrequest.branch=$TRAVIS_PULL_REQUEST_BRANCH \ + -Dsonar.pullrequest.base=$TRAVIS_BRANCH +else + if [ "$TRAVIS_BRANCH" == 'development' ]; then + TARGET_BRANCH='master' + else + TARGET_BRANCH='development' + fi + sonar_scanner \ + -Dsonar.branch.name=$TRAVIS_BRANCH \ + -Dsonar.branch.target=$TARGET_BRANCH +fi From 9f80c74001a54c0e9f1cf1c01df988cf6c95de12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Daniel=20Fad=C3=B3n?= Date: Fri, 25 Oct 2019 16:19:43 -0300 Subject: [PATCH 2/2] Matrix expansion --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87e9a0b9..36ec7ea3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ git: matrix: include: - python: '2.7' - python: '3.6' + - python: '2.7' + - python: '3.6' after_success: - bash sonar-scanner.sh