Merge pull request #1182 from makermelissa/main

Update python actions scripts to work with board alias and check board_id exists
This commit is contained in:
Kattni 2023-04-04 17:32:17 -04:00 committed by GitHub
commit b333acfa60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View file

@ -10,6 +10,22 @@ with open('template.md', "rt") as f:
metadata, content = frontmatter.parse(f.read()) metadata, content = frontmatter.parse(f.read())
acceptable_features = set(metadata['features']) 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): def valid_date(date):
date = str(date) date = str(date)
if date: if date:
@ -93,7 +109,7 @@ def verify_contribute_not_present(folder):
if not verify_features("_board", acceptable_features): 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") 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) raise SystemExit(True)
# Check Blinka Download Features # Check Blinka Download Features
blinka_features = { blinka_features = {
"Ethernet", "Ethernet",
@ -108,6 +124,14 @@ blinka_features = {
"Infrared Receiver", "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): 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") 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) raise SystemExit(True)

View file

@ -61,6 +61,11 @@ def main():
board_id = metadata.get("board_id").strip() or () board_id = metadata.get("board_id").strip() or ()
if board_id == "unknown": if board_id == "unknown":
continue 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["name"] = metadata.get("name").strip()
board["chipfamily"] = metadata.get("family").strip() board["chipfamily"] = metadata.get("family").strip()
if board["chipfamily"] not in INCLUDED_CHIP_FAMILIES: if board["chipfamily"] not in INCLUDED_CHIP_FAMILIES:
@ -70,7 +75,7 @@ def main():
board["bootloader"] = get_bootloader( board["bootloader"] = get_bootloader(
board["chipfamily"], bootloader_id board["chipfamily"], bootloader_id
) )
board["releases"] = get_releases(board_id) board["releases"] = get_releases(board_alias)
boards[board_id] = board boards[board_id] = board
print(f"Added {board_id}") print(f"Added {board_id}")
return boards return boards