From ab4b159d06f6ecbac6087ca45b649db25e3a2b9e Mon Sep 17 00:00:00 2001 From: Sonar agent <33784529+opentx-sonar@users.noreply.github.com> Date: Sun, 19 Nov 2017 15:27:49 +0100 Subject: [PATCH] Bsongis/sonar (#5382) Sonar integration --- .travis.yml | 18 +++++++++++++++++- radio/util/build-firmware.py | 13 +++++++------ radio/util/checksize.py | 13 +++++++------ sonar-project.properties | 9 +++++++++ 4 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 sonar-project.properties diff --git a/.travis.yml b/.travis.yml index 2d5cf70d6..cdf3432cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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' + diff --git a/radio/util/build-firmware.py b/radio/util/build-firmware.py index b1fe0ccee..12b439209 100755 --- a/radio/util/build-firmware.py +++ b/radio/util/build-firmware.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from __future__ import print_function import os import sys import subprocess @@ -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 @@ -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": @@ -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" @@ -247,8 +248,8 @@ try: 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) diff --git a/radio/util/checksize.py b/radio/util/checksize.py index faaf519b4..6ca91755f 100755 --- a/radio/util/checksize.py +++ b/radio/util/checksize.py @@ -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 @@ -26,7 +27,7 @@ while 1: 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) @@ -34,14 +35,14 @@ while 1: 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"): @@ -50,11 +51,11 @@ while 1: 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 diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..222b07ae9 --- /dev/null +++ b/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 +