More actionci (#406)

* clean up build script
* more test
* add comment
* update .test.skip to match ci-arduino
* added skip_count
* fix test skip
* more skip files
This commit is contained in:
Ha Thach authored and GitHub committed 2020-01-03 00:31:57 +07:00
1 parent bb7a8f2940
commit 5cea31bff7
8 files changed
+26 -44

No files matched your search

+21 -40
View File
@@ -4,46 +4,24 @@ import sys
import subprocess
import time
travis = False
if "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true":
travis = True
all_warnings = False
if "ALL_WARNINGS" in os.environ and os.environ["ALL_WARNINGS"] == "true":
all_warnings = True
ENV_VARIABLE_NAME = 'VARIANT'
exit_status = 0
success_count = 0
fail_count = 0
skip_count = 0
build_format = '| {:20} | {:30} | {:9} '
build_separator = '-' * 78
build_format = '| {:20} | {:35} | {:9} '
build_separator = '-' * 83
variants_dict = {
'feather52832': 'Feather nRF52832',
'feather52840': 'Feather nRF52840 Express',
'cplaynrf52840': 'Circuit Playground Bluefruit Express',
'itsybitsy52840': 'ItsyBitsy nRF52840 Express',
'cluenrf52840': 'CLUE nRF52840'
}
default_boards = [ 'feather52832', 'feather52840', 'cplaynrf52840', 'itsybitsy52840', 'cluenrf52840' ]
all_variants = []
build_boards = []
# build all variants if input not existed
if len(sys.argv) > 1:
if (sys.argv[1] in variants_dict):
all_variants.append(sys.argv[1])
else:
print('\033[31INTERNAL ERR\033[0m - invalid variant name "{}"'.format(sys.argv[1]))
sys.exit(-1)
build_boards.append(sys.argv[1])
else:
all_variants = list(variants_dict.keys())
print(all_variants)
exit
build_boards = default_boards
def errorOutputFilter(line):
if len(line) == 0:
@@ -55,11 +33,11 @@ def errorOutputFilter(line):
def build_examples(variant):
global exit_status, success_count, fail_count, build_format, build_separator
global exit_status, success_count, fail_count, skip_count, build_format, build_separator
print('\n')
print(build_separator)
print('| {:^74} |'.format(variants_dict[variant]))
print('| {:^79} |'.format('Board ' + variant))
print(build_separator)
print((build_format + '| {:6} |').format('Library', 'Example', 'Result', 'Time'))
print(build_separator)
@@ -69,12 +47,13 @@ def build_examples(variant):
for sketch in glob.iglob('libraries/**/*.ino', recursive=True):
start_time = time.monotonic()
# skip if example contains: ".skip" or ".skip.variant"
# however ".build.variant" file can overwrite ".skip", used to build a specific variant only
# Skip if contains: ".board.test.skip" or ".all.test.skip"
# Skip if not contains: ".board.test.only" for a specific board
sketchdir = os.path.dirname(sketch)
if ( (os.path.exists(sketchdir + '/.skip') or os.path.exists(sketchdir + '/.skip.' + variant)) and
not os.path.exists(sketchdir + '/.build.' + variant)):
success = "skipped"
if os.path.exists(sketchdir + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'):
success = "\033[33mskipped\033[0m "
elif glob.glob(sketchdir+"/.*.test.only") and not os.path.exists(sketchdir + '/.build.' + variant):
success = "\033[33mskipped\033[0m "
else:
# TODO - preferably, would have STDERR show up in **both** STDOUT and STDERR.
# preferably, would use Python logging handler to get both distinct outputs and one merged output
@@ -106,7 +85,7 @@ def build_examples(variant):
print((build_format + '| {:5.2f}s |').format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, build_duration))
if success != "skipped":
if success != "\033[33mskipped\033[0m ":
if build_result.returncode != 0:
print(build_result.stdout.decode("utf-8"))
if (build_result.stderr):
@@ -114,16 +93,18 @@ def build_examples(variant):
if len(warningLines) != 0:
for line in warningLines:
print(line)
else:
skip_count += 1
build_time = time.monotonic()
for var in all_variants:
build_examples(var)
for board in build_boards:
build_examples(board)
print(build_separator)
build_time = time.monotonic() - build_time
print("Build Summary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m and took {:.2f}s".format(success_count, fail_count, build_time))
print("Build Summary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m, {} \033[33mskipped\033[0m and took {:.2f}s".format(success_count, fail_count, skip_count, build_time))
print(build_separator)
sys.exit(exit_status)