Skip to content

Commit f9ea0e5

Browse files
committed
fix: correct handling of Zephyr boards
1 parent 8002853 commit f9ea0e5

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

circfirm/backend/github.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"X-GitHub-Api-Version": "2022-11-28",
1818
}
1919

20-
BOARDS_REGEX = r"ports/.+/boards/([^/]+)"
20+
NONZEPHYR_BOARDS_REGEX = r"ports/(.+)/boards/([^/]+)"
21+
ZEPHYR_BOARDS_REGEX = r"ports/zephyr-cp/boards/(.+/[^/]+)"
2122

2223

2324
class RateLimit(TypedDict):
@@ -74,7 +75,15 @@ def get_board_id_list(token: str) -> list[str]:
7475
for tree_item in tree_items:
7576
if tree_item["type"] != "tree":
7677
continue
77-
result = re.match(BOARDS_REGEX, tree_item["path"])
78-
if result:
79-
boards.add(result[1])
78+
79+
# Zephyr boards are organized differently, and require some modifications to the name
80+
if zephyr_match := re.match(ZEPHYR_BOARDS_REGEX, tree_item["path"]):
81+
result = zephyr_match[1].replace("/", "_")
82+
boards.add(result)
83+
84+
# Non-Zephyr boards are all organized the same
85+
elif nonzephyr_match := re.match(NONZEPHYR_BOARDS_REGEX, tree_item["path"]):
86+
if nonzephyr_match[1] == "zephyr-cp":
87+
continue
88+
boards.add(nonzephyr_match[2])
8089
return sorted(boards)

tests/helpers.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,26 @@ def copy_boot_out() -> None:
8989
def get_board_ids_from_git() -> list[str]:
9090
"""Get a list of board IDs from the sandbox git repository."""
9191
ports_path = pathlib.Path("tests/sandbox/circuitpython")
92-
board_paths = ports_path.glob("ports/*/boards/*")
93-
return sorted(
94-
[board_path.name for board_path in board_paths if board_path.is_dir()]
95-
)
92+
93+
# Glob both Zephyr and non-Zephyr boards
94+
nonzephyr_board_paths = ports_path.glob("ports/*/boards/*")
95+
zephyr_board_paths = ports_path.glob("ports/zephyr-cp/boards/*/*")
96+
97+
# Remove Zephyr boards from the non-Zephyr list
98+
nonzephyr_board_paths = [
99+
board_path.name
100+
for board_path in nonzephyr_board_paths
101+
if "zephyr-cp" not in board_path.parts and board_path.is_dir()
102+
]
103+
104+
# Clean up the Zephyr boards
105+
zephyr_board_paths = [
106+
board_path.parent.name + "_" + board_path.name
107+
for board_path in zephyr_board_paths
108+
if board_path.is_dir()
109+
]
110+
111+
return sorted(nonzephyr_board_paths + zephyr_board_paths)
96112

97113

98114
def copy_default_config() -> str:

0 commit comments

Comments
 (0)