Skip to content

Commit 480b2c5

Browse files
henrygabNaotoFujihiro
authored andcommitted
Reduce build log output and add "/Wall" build jobs.
Workaround for Arduino mDNS output noise using IPTABLES. See https://forum.arduino.cc/index.php?topic=469428.0 See per1234/arduino-ci-script#1 Arduino IDE adds a lot of noise caused by network traffic (mDNS?), because it's listening for network-attached devices. Firewall it in the TravisCI environment to cleanup logs. Allow jobs with all warnings enabled to fail. This enables the build to occur, and review of warnings, without requiring these builds to be clean of warnings. Also, only outputs the error logs (not full build logs) for these build options. This is a critical step towards getting to 100% warning-free builds, without interrupting current processes.
1 parent 25a8097 commit 480b2c5

File tree

2 files changed

+89
-7
lines changed

2 files changed

+89
-7
lines changed

.travis.yml

+34-4
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:
@@ -34,6 +53,17 @@ install:
3453
- rm -r $BSP_PATH/*
3554
- ln -s $TRAVIS_BUILD_DIR $BSP_PATH/$BSP_VERSION
3655
- arduino --install-library "Adafruit NeoPixel","Adafruit NeoMatrix","Adafruit GFX Library","Adafruit SSD1306","MIDI Library","Adafruit ILI9341","Adafruit HX8357 Library"
56+
# TODO: find way to filter out the noisy mDNS output from arduino IDE...
57+
# See https://forum.arduino.cc/index.php?topic=469428.0
58+
# See https://github.com/per1234/arduino-ci-script/issues/1
59+
# Arduino IDE adds a lot of noise caused by network traffic (mDNS?)
60+
# The following lines attempt to firewall it to prevent polluted error logs....
61+
- sudo iptables -P INPUT DROP
62+
- sudo iptables -P FORWARD DROP
63+
- sudo iptables -P OUTPUT ACCEPT
64+
- sudo iptables -A INPUT -i lo -j ACCEPT
65+
- sudo iptables -A OUTPUT -o lo -j ACCEPT
66+
- sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
3767

3868
before_script:
3969

tools/build_all.py

+55-3
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
@@ -58,14 +105,19 @@ def build_examples(variant):
58105

59106
if build_result.returncode != 0:
60107
print(build_result.stdout.decode("utf-8"))
108+
if (build_result.stderr):
109+
print(build_result.stderr.decode("utf-8"))
110+
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)