Skip to content

Commit

Permalink
Bsongis/sonar (opentx#5382)
Browse files Browse the repository at this point in the history
Sonar integration
  • Loading branch information
opentx-sonar authored and bsongis committed Nov 19, 2017
1 parent 90e58e4 commit ab4b159
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
18 changes: 17 additions & 1 deletion .travis.yml
Expand Up @@ -73,5 +73,21 @@ install:
fi
- sudo apt-get install --yes --force-yes -qq qt${QT_BASE}base qt${QT_BASE}multimedia qt${QT_BASE}svg qt${QT_BASE}tools; source /opt/qt${QT_BASE}/bin/qt${QT_BASE}-env.sh

addons:
sonarcloud:
organization: "opentx-github"
token:
secure: "BuQrGRijNpL2V/IQNcOxvjChj8PScfCdiv403EE73Nqb4+sB8YL92Fnzrnw9bC8wF7BVSDJVpYF0gbdaTzuCmaeZfM8NJK0TOJAbH6+B8bhIrU/V1SBuVjHQnndV/wysieruKnK/KxYJZqItgSlnPo+PmiFxtXJNlas0Kstb2O4="
github_token:
secure: "Qkmp4VrQJtKgZ/pz65SNnCDiF4slgFfQS/3whyLXLcDbFb1Hv1oj7Hqz9EVDUSO2eEhgQGaOKkRc0CfAAOBwW6OvhE0xh7P1CJEjzOp6+3gI/LyZUNsqa+awVRZTsfm1YZaOPaPWJ7cI0uz3/OoSUeIecs4PDWPrQMGRlsrq7Q8="
branches:
- "2.2"

script:
- ./tools/commit-tests.sh
- build-wrapper-linux-x86-64 --out-dir bw_output ./tools/commit-tests.sh
- sonar-scanner

cache:
directories:
- '$HOME/.sonar/cache'

13 changes: 7 additions & 6 deletions radio/util/build-firmware.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import os
import sys
import subprocess
Expand Down Expand Up @@ -205,7 +206,7 @@ def build_firmware(path):
file(outpath, "a").write("\n".join(cmd) + output + error)
else:
file(errpath, "w").write(output + error)
print filename
print(filename)
exit(COMPILATION_ERROR)

# Launch make
Expand All @@ -216,7 +217,7 @@ def build_firmware(path):
file(outpath, "a").write(output + error)
else:
file(errpath, "w").write(output + error)
print filename
print(filename)
exit(COMPILATION_ERROR)

if what == "firmware":
Expand All @@ -233,11 +234,11 @@ def build_firmware(path):
shutil.move(target, path)

if os.path.isfile(errpath):
print filename
print(filename)
exit(COMPILATION_ERROR)

if os.path.isfile(path):
print filename
print(filename)
exit(0)

lockpath = path + ".lock"
Expand All @@ -247,8 +248,8 @@ def build_firmware(path):
if not os.path.isfile(path):
build_firmware(path)
except filelock.Timeout:
print filename
print(filename)
exit(COMPILATION_ERROR)

print filename
print(filename)
exit(0)
13 changes: 7 additions & 6 deletions radio/util/checksize.py
Expand Up @@ -6,6 +6,7 @@
# on 2.2 release: cmake -DPCB=9X -DTELEMETRY=FRSKY -DAUDIO=YES -DVOICE=YES -DHELI=YES -DTEMPLATES=YES ~/git/opentx
# => 64828 (program) + 3236 (data)

from __future__ import print_function
import os
import sys
import subprocess
Expand All @@ -26,22 +27,22 @@
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = proc.communicate()
if proc.returncode != 0:
print "HEAD~%d git reset failed" % index
print("HEAD~%d git reset failed" % index)
continue

os.chdir(buildir)
cmd = ["cmake"] + options + [srcdir]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = proc.communicate()
if proc.returncode != 0:
print "HEAD~%d cmake failed" % index
print("HEAD~%d cmake failed" % index)
continue

cmd = ["make", "-j4", "firmware"]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = proc.communicate()
if proc.returncode != 0:
print "HEAD~%d make firmware failed" % index
print("HEAD~%d make firmware failed" % index)
continue

if os.path.isfile("firmware.bin"):
Expand All @@ -50,11 +51,11 @@
oldsize = int(subprocess.check_output('avr-size -A firmware.hex | grep Total | cut -f2- -d " "', shell=True))
if size:
if size > oldsize:
print "HEAD~%d %d: increase by %d bytes" % (index-1, size, size-oldsize)
print("HEAD~%d %d: increase by %d bytes" % (index-1, size, size-oldsize))
elif size < oldsize:
print "HEAD~%d %d: decrease by %d bytes" % (index-1, size, oldsize-size)
print("HEAD~%d %d: decrease by %d bytes" % (index-1, size, oldsize-size))
else:
print "HEAD~%d %d" % (index-1, size)
print("HEAD~%d %d" % (index-1, size))
size = oldsize


9 changes: 9 additions & 0 deletions sonar-project.properties
@@ -0,0 +1,9 @@
sonar.host.url = https://sonarcloud.io
sonar.projectKey = OpenTX
sonar.organization = opentx-github
sonar.projectName = OpenTX
sonar.projectVersion = 2.2
sonar.sources = .
sonar.exclusions = sound/**, build/**, radio/src/thirdparty/**
sonar.cfamily.build-wrapper-output = bw_output

0 comments on commit ab4b159

Please sign in to comment.