Skip to content

Update python actions scripts to work with board alias and check board_id exists #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion check-boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@
metadata, content = frontmatter.parse(f.read())
acceptable_features = set(metadata['features'])

def verify_board_id(folder):
valid = True
for filename in Path(folder).glob("*.md"):
with open(filename, "rt") as f:
metadata, _ = frontmatter.parse(f.read())
downloads_display = metadata.get('downloads_display')
if downloads_display is None or downloads_display:
board_id = metadata.get('board_id')
if board_id == "unknown":
continue
if not board_id:
print(f"board_id should be set for {filename}")
valid = False

return valid

def valid_date(date):
date = str(date)
if date:
Expand Down Expand Up @@ -93,7 +109,7 @@ def verify_contribute_not_present(folder):
if not verify_features("_board", acceptable_features):
print("Non-standard features found. See https://learn.adafruit.com/how-to-add-a-new-board-to-the-circuitpython-org-website/adding-to-downloads for acceptable features")
raise SystemExit(True)

# Check Blinka Download Features
blinka_features = {
"Ethernet",
Expand All @@ -108,6 +124,14 @@ def verify_contribute_not_present(folder):
"Infrared Receiver",
}

if not verify_board_id("_board"):
print("board_id missing for some boards. This is a required field.")
raise SystemExit(True)

if not verify_board_id("_blinka"):
print("board_id missing for some boards. This is a required field.")
raise SystemExit(True)

if not verify_features("_blinka", blinka_features):
print("Non-standard features found. See https://learn.adafruit.com/how-to-add-a-new-board-to-the-circuitpython-org-website/adding-to-blinka for acceptable features")
raise SystemExit(True)
Expand Down
7 changes: 6 additions & 1 deletion generate-board-info.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def generate_boards(folder):
board_id = metadata.get("board_id").strip() or ()
if board_id == "unknown":
continue
board_alias = metadata.get("board_alias")
if not board_alias:
board_alias = board_id
else:
board_alias = board_alias.strip()
board["name"] = metadata.get("name").strip()
board["chipfamily"] = metadata.get("family").strip()
if board["chipfamily"] not in INCLUDED_CHIP_FAMILIES:
Expand All @@ -70,7 +75,7 @@ def generate_boards(folder):
board["bootloader"] = get_bootloader(
board["chipfamily"], bootloader_id
)
board["releases"] = get_releases(board_id)
board["releases"] = get_releases(board_alias)
boards[board_id] = board
print(f"Added {board_id}")
return boards
Expand Down