improve ci, run examples with pool to speed up compile time
skip TinyUSB lib examples
This commit is contained in:
1 parent
98136d36de
commit
ac28683781
2 files changed
+92
-74
No files matched your search
@@ -2,8 +2,13 @@ name: Build
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -16,8 +21,6 @@ jobs:
|
||||
- 'feather52840sense'
|
||||
- 'itsybitsy52840'
|
||||
- 'ledglasses_nrf52840'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Setup Python
|
||||
@@ -58,18 +61,11 @@ jobs:
|
||||
|
||||
# Install library dependency
|
||||
arduino-cli lib install "Adafruit AHRS" "Adafruit APDS9960 Library" "Adafruit Arcada Library" "Adafruit BMP280 Library" "Adafruit Circuit Playground" "Adafruit EPD" "Adafruit GFX Library" "Adafruit HX8357 Library" "Adafruit ILI9341" "Adafruit LIS3MDL" "Adafruit LSM6DS" "Adafruit NeoPixel" "Adafruit NeoMatrix" "Adafruit Sensor Calibration" "Adafruit SHT31 Library" "Adafruit SSD1306" "Adafruit ST7735 and ST7789 Library" "SdFat - Adafruit Fork"
|
||||
arduino-cli lib install "MIDI Library"
|
||||
arduino-cli lib install "MIDI Library" "Firmata"
|
||||
|
||||
# Arduino_TensorFlowLite is removed per maintainer request https://github.com/arduino/library-registry/pull/1748
|
||||
# Find a way to compile later, skip TFL example for now
|
||||
# arduino-cli lib install "Arduino_TensorFlowLite"
|
||||
|
||||
# TODO use firmata master to prevent build error with gcc v9 (should be remove after 2.5.9 is released)
|
||||
# https://github.com/firmata/arduino/pull/438
|
||||
git clone --depth 1 https://github.com/firmata/arduino.git $HOME/Arduino/libraries/firmata
|
||||
|
||||
# TODO temporarily remove TinyUSB pre-1.0.0 version install by arduino-cli
|
||||
rm -r $HOME/Arduino/libraries/Adafruit_TinyUSB_Library
|
||||
|
||||
# Library summary
|
||||
arduino-cli lib list
|
||||
|
||||
+86
-64
@@ -2,98 +2,120 @@ import os
|
||||
import glob
|
||||
import sys
|
||||
import subprocess
|
||||
from subprocess import Popen, PIPE
|
||||
import time
|
||||
from multiprocessing import Pool
|
||||
|
||||
SUCCEEDED = "\033[32msucceeded\033[0m"
|
||||
FAILED = "\033[31mfailed\033[0m"
|
||||
SKIPPED = "\033[35mskipped\033[0m"
|
||||
WARNING = "\033[33mwarnings\033[0m "
|
||||
|
||||
exit_status = 0
|
||||
success_count = 0
|
||||
fail_count = 0
|
||||
skip_count = 0
|
||||
|
||||
build_format = '| {:25} | {:35} | {:18} | {:6} |'
|
||||
build_separator = '-' * 88
|
||||
|
||||
default_boards = [ 'cluenrf52840', 'cplaynrf52840', 'feather52832', 'feather52840', 'feather52840sense', 'itsybitsy52840' ]
|
||||
default_boards = [
|
||||
'cluenrf52840',
|
||||
'cplaynrf52840',
|
||||
'feather52832',
|
||||
'feather52840',
|
||||
'feather52840sense',
|
||||
'itsybitsy52840'
|
||||
]
|
||||
build_boards = []
|
||||
|
||||
# build all variants if input not existed
|
||||
if len(sys.argv) > 1:
|
||||
build_boards.append(sys.argv[1])
|
||||
else:
|
||||
build_boards = default_boards
|
||||
|
||||
all_examples = list(glob.iglob('libraries/**/*.ino', recursive=True))
|
||||
all_examples.sort()
|
||||
def build_a_example(arg):
|
||||
variant = arg[0]
|
||||
sketch = arg[1]
|
||||
|
||||
def build_examples(variant):
|
||||
global exit_status, success_count, fail_count, skip_count, build_format, build_separator
|
||||
fqbn = "adafruit:nrf52:{}:softdevice={},debug=l0".format(variant,
|
||||
's140v6' if variant != 'feather52832' else 's132v6')
|
||||
# succeeded, failed, skipped
|
||||
ret = [0, 0, 0]
|
||||
|
||||
start_time = time.monotonic()
|
||||
|
||||
# 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 + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'):
|
||||
success = SKIPPED
|
||||
ret[2] = 1
|
||||
elif glob.glob(sketchdir + "/.*.test.only") and not os.path.exists(sketchdir + '/.' + variant + '.test.only'):
|
||||
success = SKIPPED
|
||||
ret[2] = 1
|
||||
else:
|
||||
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
# get stderr into a form where warning/error was output to stderr
|
||||
if build_result.returncode != 0:
|
||||
ret[1] = 1
|
||||
success = FAILED
|
||||
else:
|
||||
ret[0] = 1
|
||||
if build_result.stderr:
|
||||
success = WARNING
|
||||
else:
|
||||
success = SUCCEEDED
|
||||
|
||||
build_duration = time.monotonic() - start_time
|
||||
print(build_format.format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success,
|
||||
'{:5.2f}s'.format(build_duration)))
|
||||
|
||||
if success != SKIPPED:
|
||||
# Build failed
|
||||
if build_result.returncode != 0:
|
||||
print(build_result.stdout.decode("utf-8"))
|
||||
|
||||
# Build with warnings
|
||||
if build_result.stderr:
|
||||
print(build_result.stderr.decode("utf-8"))
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def build_all_examples(variant):
|
||||
print('\n')
|
||||
print(build_separator)
|
||||
print('| {:^84} |'.format('Board ' + variant))
|
||||
print(build_separator)
|
||||
print(build_format.format('Library', 'Example', '\033[39mResult\033[0m', 'Time'))
|
||||
print(build_separator)
|
||||
|
||||
fqbn = "adafruit:nrf52:{}:softdevice={},debug=l0".format(variant, 's140v6' if variant != 'feather52832' else 's132v6')
|
||||
|
||||
for sketch in all_examples:
|
||||
# skip TinyUSB library examples for nRF52832
|
||||
if variant == 'feather52832' and "libraries/Adafruit_TinyUSB_Arduino" in sketch:
|
||||
continue
|
||||
args = [[variant, s] for s in all_examples]
|
||||
with Pool() as pool:
|
||||
result = pool.map(build_a_example, args)
|
||||
# sum all element of same index (column sum)
|
||||
return list(map(sum, list(zip(*result))))
|
||||
|
||||
start_time = time.monotonic()
|
||||
|
||||
# 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 + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'):
|
||||
success = SKIPPED
|
||||
skip_count += 1
|
||||
elif glob.glob(sketchdir+"/.*.test.only") and not os.path.exists(sketchdir + '/.' + variant + '.test.only'):
|
||||
success = SKIPPED
|
||||
skip_count += 1
|
||||
else:
|
||||
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=PIPE, stderr=PIPE)
|
||||
if __name__ == "__main__":
|
||||
# build all variants if input not existed
|
||||
if len(sys.argv) > 1:
|
||||
build_boards.append(sys.argv[1])
|
||||
else:
|
||||
build_boards = default_boards
|
||||
|
||||
# get stderr into a form where warning/error was output to stderr
|
||||
if build_result.returncode != 0:
|
||||
exit_status = build_result.returncode
|
||||
success = FAILED
|
||||
fail_count += 1
|
||||
else:
|
||||
success_count += 1
|
||||
if build_result.stderr:
|
||||
success = WARNING
|
||||
else:
|
||||
success = SUCCEEDED
|
||||
# All examples in libraries except TinyUSB which has its own ci to build
|
||||
all_examples = list(glob.iglob('libraries/**/*.ino', recursive=True))
|
||||
all_examples = [i for i in all_examples if "Adafruit_TinyUSB_Arduino" not in i]
|
||||
all_examples.sort()
|
||||
|
||||
build_duration = time.monotonic() - start_time
|
||||
build_time = time.monotonic()
|
||||
|
||||
print(build_format.format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, '{:5.2f}s'.format(build_duration)))
|
||||
# succeeded, failed, skipped
|
||||
total_result = [0, 0, 0]
|
||||
|
||||
if success != SKIPPED:
|
||||
# Build failed
|
||||
if build_result.returncode != 0:
|
||||
print(build_result.stdout.decode("utf-8"))
|
||||
|
||||
# Build with warnings
|
||||
if build_result.stderr:
|
||||
print(build_result.stderr.decode("utf-8"))
|
||||
for board in build_boards:
|
||||
fret = build_all_examples(board)
|
||||
if len(fret) == len(total_result):
|
||||
total_result = [total_result[i] + fret[i] for i in range(len(fret))]
|
||||
|
||||
build_time = time.monotonic()
|
||||
build_time = time.monotonic() - build_time
|
||||
|
||||
for board in build_boards:
|
||||
build_examples(board)
|
||||
print(build_separator)
|
||||
print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(total_result[0], SUCCEEDED, total_result[1], FAILED, total_result[2], SKIPPED, build_time))
|
||||
print(build_separator)
|
||||
|
||||
print(build_separator)
|
||||
build_time = time.monotonic() - build_time
|
||||
print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, build_time))
|
||||
print(build_separator)
|
||||
|
||||
sys.exit(exit_status)
|
||||
sys.exit(total_result[1])
|
||||
Reference in new issue
Block a user