Compare commits

..

3 commits

5 changed files with 48 additions and 14 deletions

View file

@ -16,5 +16,5 @@ jobs:
run: bash ./actions_install.sh run: bash ./actions_install.sh
- name: test platforms - name: test platforms
run: | run: |
python3 build_platform.py uno leonardo mega2560 zero esp8266 esp32 pico_rp2040 python3 build_platform.py uno leonardo mega2560 zero esp8266 esp32 pico_rp2040 feather_m4_express

View file

@ -3,9 +3,9 @@ import glob
import time import time
import os import os
import shutil import shutil
from distutils.dir_util import copy_tree
import subprocess import subprocess
import collections import collections
from contextlib import contextmanager
# optional wall option cause build failed if has warnings # optional wall option cause build failed if has warnings
BUILD_WALL = False BUILD_WALL = False
@ -208,10 +208,10 @@ print("INSTALLING ARDUINO BOARDS")
ColorPrint.print_info('#'*40) ColorPrint.print_info('#'*40)
run_or_die("arduino-cli core update-index --additional-urls "+BSP_URLS+ run_or_die("arduino-cli core update-index --additional-urls "+BSP_URLS+
" > /dev/null", "FAILED to update core indices") " > /dev/null", "FAILED to update core indecies")
print() print()
################################ Install dependencies ################################ Install dependancies
our_name=None our_name=None
try: try:
if IS_LEARNING_SYS: if IS_LEARNING_SYS:
@ -227,13 +227,13 @@ try:
dep = dep.strip() dep = dep.strip()
print("Installing "+dep) print("Installing "+dep)
run_or_die('arduino-cli lib install "'+dep+'" > /dev/null', run_or_die('arduino-cli lib install "'+dep+'" > /dev/null',
"FAILED to install dependency "+dep) "FAILED to install dependancy "+dep)
except OSError: except OSError:
print("No library dep or properties found!") print("No library dep or properties found!")
pass # no library properties pass # no library properties
# Delete the existing library if we somehow downloaded # Delete the existing library if we somehow downloaded
# due to dependencies # due to dependancies
if our_name: if our_name:
run_or_die("arduino-cli lib uninstall \""+our_name+"\"", "Could not uninstall") run_or_die("arduino-cli lib uninstall \""+our_name+"\"", "Could not uninstall")
@ -248,6 +248,12 @@ if not IS_LEARNING_SYS:
################################ UF2 Utils. ################################ UF2 Utils.
def glob01(pattern):
result = glob.glob(pattern)
if len(result) > 1:
raise RuntimeError(f"Required pattern {pattern} to match at most 1 file, got {result}")
return result[0] if result else None
def glob1(pattern): def glob1(pattern):
result = glob.glob(pattern) result = glob.glob(pattern)
if len(result) != 1: if len(result) != 1:
@ -276,11 +282,23 @@ def generate_uf2(example_path):
""" """
if not download_uf2_utils(): if not download_uf2_utils():
return None return None
cli_build_path = "build/*.*." + fqbn.split(':')[2] + "/*.hex"
input_file = glob1(os.path.join(example_path, cli_build_path)) cli_build_uf2_path = "build/*.*." + fqbn.split(':')[2] + "/*.uf2"
output_file = os.path.splitext(input_file)[0] + ".uf2" uf2_input_file = glob01(os.path.join(example_path, cli_build_uf2_path))
# Some platforms, like rp2040, directly generate a uf2 file, so no need to do it ourselves
if uf2_input_file is not None:
output_file = os.path.splitext(uf2_input_file)[0] + ".uf2"
ColorPrint.print_pass(CHECK)
ColorPrint.print_info("Used uf2 generated by arduino-cli")
return output_file
# For other uf2-supporting platforms, we can generate it from a hex file
cli_build_hex_path = "build/*.*." + fqbn.split(':')[2] + "/*.hex"
hex_input_file = glob1(os.path.join(example_path, cli_build_hex_path))
output_file = os.path.splitext(hex_input_file)[0] + ".uf2"
family_id = ALL_PLATFORMS[platform][1] family_id = ALL_PLATFORMS[platform][1]
cmd = ['python3', 'uf2conv.py', input_file, '-c', '-f', family_id, '-o', output_file] cmd = ['python3', 'uf2conv.py', hex_input_file, '-c', '-f', family_id, '-o', output_file]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
r = proc.wait(timeout=60) r = proc.wait(timeout=60)
out = proc.stdout.read() out = proc.stdout.read()
@ -311,6 +329,20 @@ for arg in sys.argv[1:]:
print("Unknown platform: ", arg) print("Unknown platform: ", arg)
exit(-1) exit(-1)
@contextmanager
def group_output(title):
sys.stdout.flush()
sys.stderr.flush()
print(f"::group::{title}")
try:
yield
finally:
sys.stdout.flush()
sys.stderr.flush()
print(f"::endgroup::")
sys.stdout.flush()
def test_examples_in_folder(folderpath): def test_examples_in_folder(folderpath):
global success global success
for example in sorted(os.listdir(folderpath)): for example in sorted(os.listdir(folderpath)):
@ -366,6 +398,7 @@ def test_examples_in_folder(folderpath):
ColorPrint.print_pass(CHECK) ColorPrint.print_pass(CHECK)
if err: if err:
# also print out warning message # also print out warning message
with group_output(f"{example} {fqbn} build output"):
ColorPrint.print_fail(err.decode("utf-8")) ColorPrint.print_fail(err.decode("utf-8"))
if os.path.exists(gen_file_name): if os.path.exists(gen_file_name):
if ALL_PLATFORMS[platform][1] == None: if ALL_PLATFORMS[platform][1] == None:
@ -383,6 +416,7 @@ def test_examples_in_folder(folderpath):
os.system("ls -lR "+BUILD_DIR+"/build") os.system("ls -lR "+BUILD_DIR+"/build")
else: else:
ColorPrint.print_fail(CROSS) ColorPrint.print_fail(CROSS)
with group_output(f"{example} {fqbn} built output"):
ColorPrint.print_fail(out.decode("utf-8")) ColorPrint.print_fail(out.decode("utf-8"))
ColorPrint.print_fail(err.decode("utf-8")) ColorPrint.print_fail(err.decode("utf-8"))
success = 1 success = 1

View file

@ -180,7 +180,7 @@ if [ -d "html" ] && [ -f "html/index.html" ]; then
-m "Commit: ${COMMIT_SHA1}"$'\n'"${BUILD_ID}" -m "Commit: ${COMMIT_SHA1}"$'\n'"${BUILD_ID}"
# Force push to the remote gh-pages branch. # Force push to the remote gh-pages branch.
# The output is redirected to /dev/null to hide any sensitive credential data # The ouput is redirected to /dev/null to hide any sensitive credential data
# that might otherwise be exposed. # that might otherwise be exposed.
echo 'Git pushing' echo 'Git pushing'
git push --force "https://${AUTH}@github.com/${REPO_SLUG}.git" > /dev/null 2>&1 git push --force "https://${AUTH}@github.com/${REPO_SLUG}.git" > /dev/null 2>&1

View file