Skip to content

Commit 622d9f6

Browse files
committed
re-enable builds with all warnings
1 parent cb97944 commit 622d9f6

File tree

2 files changed

+40
-28
lines changed

2 files changed

+40
-28
lines changed

.github/workflows/githubci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ jobs:
4949
arduino-cli core update-index --additional-urls $BSP_URL
5050
arduino-cli core install arduino:samd --additional-urls $BSP_URL
5151
arduino-cli core install adafruit:samd --additional-urls $BSP_URL
52-
# Repalce release BSP with our code
52+
# Replace release BSP with our code
5353
BSP_VERSION=`eval ls $HOME/$BSP_PATH`
5454
rm -r $HOME/$BSP_PATH/*
5555
ln -s $GITHUB_WORKSPACE $HOME/$BSP_PATH/$BSP_VERSION
5656
arduino-cli lib install $LIB_DEPS
5757
5858
- name: Build examples
59-
allow_failure: true
6059
run: python3 extras/build_all.py ${{ matrix.arduino-platform }}
6160

62-
# - name: Build examples with all warnings enabled
63-
# run: python3 extras/build_all.py ${{ matrix.arduino-platform }} all_warnings
61+
# How to mark this as allowed-to-fail?
62+
- name: Build default boards with all warnings enabled
63+
run: python3 extras/build_all.py --all_warnings --warnings_do_not_cause_job_failure

extras/build_all.py

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,51 @@
33
import sys
44
import subprocess
55
import time
6+
import argparse
7+
8+
FQBN_PREFIX='adafruit:samd:adafruit_'
9+
10+
11+
parser = argparse.ArgumentParser(
12+
description='python wrapper for adafruit arduino CI workflows',
13+
allow_abbrev=False
14+
)
15+
parser.add_argument(
16+
'--all_warnings', '--Wall',
17+
action='store_true',
18+
help='build with all warnings enabled (`--warnings all`)',
19+
)
20+
parser.add_argument(
21+
'--warnings_do_not_cause_job_failure',
22+
action='store_true',
23+
help='failed builds will be listed as failed, but not cause job to exit with an error status',
24+
)
25+
parser.add_argument(
26+
'build_boards',
27+
metavar='board',
28+
nargs='*',
29+
help='list of boards to be built -- Note that the fqbn is created by prepending "{}"'.format(FQBN_PREFIX),
30+
default= [ 'metro_m0', 'metro_m4', 'circuitplayground_m0' ]
31+
)
32+
args = parser.parse_args()
633

7-
all_warnings = False
834
exit_status = 0
935
success_count = 0
1036
fail_count = 0
1137
skip_count = 0
12-
1338
build_format = '| {:22} | {:30} | {:9} '
1439
build_separator = '-' * 80
1540

16-
default_boards = [ 'metro_m0', 'metro_m4', 'circuitplayground_m0']
17-
18-
build_boards = []
19-
20-
# build all variants if input not existed
21-
if len(sys.argv) > 1:
22-
build_boards.append(sys.argv[1])
23-
else:
24-
build_boards = default_boards
25-
26-
all_warnings = True if 'all_warnings' in sys.arv[2:]
27-
28-
29-
def errorOutputFilter(line):
41+
def errorOutputFilter(line: str):
3042
if len(line) == 0:
3143
return False
3244
if line.isspace(): # Note: empty string does not match here!
3345
return False
3446
# TODO: additional items to remove?
3547
return True
3648

37-
38-
def build_examples(variant):
39-
global exit_status, success_count, fail_count, skip_count, build_format, build_separator
49+
def build_examples(variant: str):
50+
global args, exit_status, success_count, fail_count, skip_count, build_format, build_separator
4051

4152
print('\n')
4253
print(build_separator)
@@ -45,7 +56,7 @@ def build_examples(variant):
4556
print((build_format + '| {:6} |').format('Library', 'Example', 'Result', 'Time'))
4657
print(build_separator)
4758

48-
fqbn = "adafruit:samd:adafruit_{}".format(variant)
59+
fqbn = "{}{}".format(FQBN_PREFIX, variant)
4960

5061
for sketch in glob.iglob('libraries/**/*.ino', recursive=True):
5162
start_time = time.monotonic()
@@ -61,14 +72,14 @@ def build_examples(variant):
6172
# TODO - preferably, would have STDERR show up in **both** STDOUT and STDERR.
6273
# preferably, would use Python logging handler to get both distinct outputs and one merged output
6374
# for now, split STDERR when building with all warnings enabled, so can detect warning/error output.
64-
if all_warnings:
75+
if args.all_warnings:
6576
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
6677
else:
6778
build_result = subprocess.run("arduino-cli compile --warnings default --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
6879

6980
# get stderr into a form where len(warningLines) indicates a true warning was output to stderr
7081
warningLines = [];
71-
if all_warnings and build_result.stderr:
82+
if args.all_warnings and build_result.stderr:
7283
tmpWarningLines = build_result.stderr.decode("utf-8").splitlines()
7384
warningLines = list(filter(errorOutputFilter, (tmpWarningLines)))
7485

@@ -77,7 +88,8 @@ def build_examples(variant):
7788
success = "\033[31mfailed\033[0m "
7889
fail_count += 1
7990
elif len(warningLines) != 0:
80-
exit_status = -1
91+
if not args.warnings_do_not_cause_job_failure:
92+
exit_status = -1
8193
success = "\033[31mwarnings\033[0m "
8294
fail_count += 1
8395
else:
@@ -101,7 +113,7 @@ def build_examples(variant):
101113

102114
build_time = time.monotonic()
103115

104-
for board in build_boards:
116+
for board in args.build_boards:
105117
build_examples(board)
106118

107119
print(build_separator)

0 commit comments

Comments
 (0)