Skip to content

Commit b333acf

Browse files
authored
Merge pull request #1182 from makermelissa/main
Update python actions scripts to work with board alias and check board_id exists
2 parents 23a6c04 + 82dd2ce commit b333acf

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

check-boards.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@
1010
metadata, content = frontmatter.parse(f.read())
1111
acceptable_features = set(metadata['features'])
1212

13+
def verify_board_id(folder):
14+
valid = True
15+
for filename in Path(folder).glob("*.md"):
16+
with open(filename, "rt") as f:
17+
metadata, _ = frontmatter.parse(f.read())
18+
downloads_display = metadata.get('downloads_display')
19+
if downloads_display is None or downloads_display:
20+
board_id = metadata.get('board_id')
21+
if board_id == "unknown":
22+
continue
23+
if not board_id:
24+
print(f"board_id should be set for {filename}")
25+
valid = False
26+
27+
return valid
28+
1329
def valid_date(date):
1430
date = str(date)
1531
if date:
@@ -93,7 +109,7 @@ def verify_contribute_not_present(folder):
93109
if not verify_features("_board", acceptable_features):
94110
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")
95111
raise SystemExit(True)
96-
112+
97113
# Check Blinka Download Features
98114
blinka_features = {
99115
"Ethernet",
@@ -108,6 +124,14 @@ def verify_contribute_not_present(folder):
108124
"Infrared Receiver",
109125
}
110126

127+
if not verify_board_id("_board"):
128+
print("board_id missing for some boards. This is a required field.")
129+
raise SystemExit(True)
130+
131+
if not verify_board_id("_blinka"):
132+
print("board_id missing for some boards. This is a required field.")
133+
raise SystemExit(True)
134+
111135
if not verify_features("_blinka", blinka_features):
112136
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")
113137
raise SystemExit(True)

generate-board-info.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def generate_boards(folder):
6161
board_id = metadata.get("board_id").strip() or ()
6262
if board_id == "unknown":
6363
continue
64+
board_alias = metadata.get("board_alias")
65+
if not board_alias:
66+
board_alias = board_id
67+
else:
68+
board_alias = board_alias.strip()
6469
board["name"] = metadata.get("name").strip()
6570
board["chipfamily"] = metadata.get("family").strip()
6671
if board["chipfamily"] not in INCLUDED_CHIP_FAMILIES:
@@ -70,7 +75,7 @@ def generate_boards(folder):
7075
board["bootloader"] = get_bootloader(
7176
board["chipfamily"], bootloader_id
7277
)
73-
board["releases"] = get_releases(board_id)
78+
board["releases"] = get_releases(board_alias)
7479
boards[board_id] = board
7580
print(f"Added {board_id}")
7681
return boards

0 commit comments

Comments
 (0)