Skip to content

Commit 32f3b29

Browse files
authored
Merge pull request #376 from henrygab/TravisAllWarnings
Improve Travis Builds (inc. additional warnings)
2 parents 3606bbf + a441f0e commit 32f3b29

File tree

2 files changed

+84
-9
lines changed

2 files changed

+84
-9
lines changed

.travis.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
sudo: required
12
language: c
23
dist: xenial
34
git:
@@ -8,10 +9,28 @@ env:
89
global:
910
- BSP_PATH="$HOME/.arduino15/packages/adafruit/hardware/nrf52"
1011
jobs:
11-
# Split into one job per board (aka variant)
12-
- VARIANT="feather52840"
13-
- VARIANT="cplaynrf52840"
14-
- VARIANT="feather52832"
12+
# empty env required, else allow_failures will SILENTY IGNORE matching against env...
13+
-
14+
15+
jobs:
16+
fast_finish: true
17+
include:
18+
- name: "Feather 52840"
19+
env: VARIANT="feather52840"
20+
- name: "Feather 52840 (All warnings)"
21+
env: ALL_WARNINGS="true" VARIANT="feather52840"
22+
- name: "Circuit Playground 52840"
23+
env: VARIANT="cplaynrf52840"
24+
- name: "Circuit Playground 52840 (All warnings)"
25+
env: ALL_WARNINGS="true" VARIANT="cplaynrf52840"
26+
- name: "Feather 52832"
27+
env: VARIANT="feather52832"
28+
- name: "Feather 52832 (All warnings)"
29+
env: ALL_WARNINGS="true" VARIANT="feather52832"
30+
allow_failures:
31+
- env: ALL_WARNINGS="true" VARIANT="feather52840"
32+
- env: ALL_WARNINGS="true" VARIANT="cplaynrf52840"
33+
- env: ALL_WARNINGS="true" VARIANT="feather52832"
1534

1635
addons:
1736
apt:
@@ -24,6 +43,10 @@ addons:
2443
confinement: classic
2544

2645
install:
46+
# Filter only mDNS / Bonjour traffic
47+
- sudo iptables --insert INPUT --jump DROP --protocol udp --dport 5353 -m comment --comment "silently drop all 5353/udp input"
48+
- sudo iptables --insert INPUT --jump DROP --destination 224.0.0.251 -m comment --comment "silently drop all mDNS ipv4 broadcast"
49+
# Install the nRF52 support files for arduino
2750
- pip3 install --user adafruit-nrfutil
2851
- umake electronics arduino $HOME/arduino_ide
2952
- export PATH=$HOME/arduino_ide:$PATH

tools/build_all.py

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
if "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true":
99
travis = True
1010

11+
all_warnings = False
12+
if "ALL_WARNINGS" in os.environ and os.environ["ALL_WARNINGS"] == "true":
13+
all_warnings = True
14+
15+
ENV_VARIABLE_NAME = 'VARIANT'
16+
17+
1118
exit_status = 0
1219
success_count = 0
1320
fail_count = 0
@@ -21,6 +28,25 @@
2128
'feather52832': 'Feather nRF52832'
2229
}
2330

31+
# STDERR receives output that starts with the following text, none of which should be considered a warning or error...
32+
output_to_ignore = (
33+
'Picked up JAVA_TOOL_OPTIONS:',
34+
'Loading configuration...',
35+
'Initializing packages...',
36+
'Preparing boards...',
37+
'Verifying...',
38+
)
39+
40+
def errorOutputFilter(line):
41+
if len(line) == 0:
42+
return False
43+
if line.isspace(): # Note: empty string does not match here!
44+
return False
45+
if line.startswith(output_to_ignore): # alternatively, can trim() each line, but that would create lots of short-lived strings...
46+
return False
47+
# TODO: additional items to remove?
48+
return True
49+
2450

2551
def build_examples(variant):
2652
global exit_status, success_count, fail_count, build_format, build_separator
@@ -33,18 +59,39 @@ def build_examples(variant):
3359
print(build_separator)
3460
subprocess.run("arduino --board adafruit:nrf52:{}:softdevice={},debug=l0 --save-prefs".format(variant, 's140v6' if variant != 'feather52832' else 's132v6'), shell=True,
3561
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
62+
63+
if all_warnings:
64+
subprocess.run("arduino --pref 'compiler.warning_level=all' --save-prefs", shell=True,
65+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
3666

3767
for sketch in glob.iglob('libraries/**/*.ino', recursive=True):
3868
start_time = time.monotonic()
3969

4070
if os.path.exists(os.path.dirname(sketch) + '/.skip') or os.path.exists(os.path.dirname(sketch) + '/.skip.' + variant):
4171
success = "skipped"
4272
else:
43-
build_result = subprocess.run("arduino --verify {}".format(sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
73+
# TODO - preferably, would have STDERR show up in **both** STDOUT and STDERR.
74+
# preferably, would use Python logging handler to get both distinct outputs and one merged output
75+
# for now, split STDERR when building with all warnings enabled, so can detect warning/error output.
76+
if all_warnings:
77+
build_result = subprocess.run("arduino --verify {}".format(sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
78+
else:
79+
build_result = subprocess.run("arduino --verify {}".format(sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
80+
81+
# get stderr into a form where len(warningLines) indicates a true warning was output to stderr
82+
warningLines = [];
83+
if all_warnings and build_result.stderr:
84+
tmpWarningLines = build_result.stderr.decode("utf-8").splitlines()
85+
warningLines = list(filter(errorOutputFilter, (tmpWarningLines)))
86+
4487
if build_result.returncode != 0:
4588
exit_status = build_result.returncode
4689
success = "\033[31mfailed\033[0m "
4790
fail_count += 1
91+
elif len(warningLines) != 0:
92+
exit_status = -1
93+
success = "\033[31mwarnings\033[0m "
94+
fail_count += 1
4895
else:
4996
success = "\033[32msucceeded\033[0m"
5097
success_count += 1
@@ -56,16 +103,21 @@ def build_examples(variant):
56103

57104
print((build_format + '| {:5.2f}s |').format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, build_duration))
58105

59-
if build_result.returncode != 0:
60-
print(build_result.stdout.decode("utf-8"))
106+
if success != "skipped":
107+
if build_result.returncode != 0:
108+
print(build_result.stdout.decode("utf-8"))
109+
if (build_result.stderr):
110+
print(build_result.stderr.decode("utf-8"))
111+
if len(warningLines) != 0:
112+
for line in warningLines:
113+
print(line)
61114

62115
if travis:
63116
print('travis_fold:end:build-{}\\r'.format(sketch))
64117

65118

66119
build_time = time.monotonic()
67120

68-
ENV_VARIABLE_NAME = 'VARIANT'
69121

70122
# build only one variant if the environment variable is specified
71123
if (ENV_VARIABLE_NAME in os.environ):
@@ -74,7 +126,7 @@ def build_examples(variant):
74126
if (variant in variants_dict):
75127
build_examples(variant)
76128
else:
77-
print('\033[31failed\033[0m - invalid variant name "{}"'.format(variant))
129+
print('\033[31INTERNAL ERR\033[0m - invalid variant name "{}"'.format(variant))
78130
fail_count += 1
79131
exit_status = -1
80132

0 commit comments

Comments
 (0)