Skip to content

Commit 5cca880

Browse files
committed
add python script to return port directory name from board name for use in deps port action
takes an optional port value that will then be validated
1 parent 2af397e commit 5cca880

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

.github/actions/deps/ports/action.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,30 @@ inputs:
1111
runs:
1212
using: composite
1313
steps:
14+
steps:
15+
- name: Board to port
16+
id: board-to-port
17+
run: |
18+
PORT=$(python tools/board_to_port.py "${{ inputs.board }}" "${{ inputs.port }}")
19+
echo "port=$PORT" >> $GITHUB_OUTPUT
20+
shell: bash
21+
1422
- name: Set up broadcom
15-
if: inputs.port == 'broadcom'
23+
if: steps.board-to-port.outputs.port == 'broadcom'
1624
uses: ./.github/actions/deps/ports/broadcom
1725

1826
- name: Set up espressif
19-
if: inputs.port == 'espressif'
27+
if: steps.board-to-port.outputs.port == 'espressif'
2028
uses: ./.github/actions/deps/ports/espressif
2129

2230
- name: Set up litex
23-
if: inputs.port == 'litex'
31+
if: steps.board-to-port.outputs.port == 'litex'
2432
uses: ./.github/actions/deps/ports/litex
2533

2634
- name: Set up nordic
27-
if: inputs.port == 'nordic'
35+
if: steps.board-to-port.outputs.port == 'nordic'
2836
uses: ./.github/actions/deps/ports/nordic
2937

3038
- name: Set up Zephyr
31-
if: inputs.port == 'zephyr-cp'
39+
if: steps.board-to-port.outputs.port == 'zephyr-cp'
3240
uses: ./.github/actions/deps/ports/zephyr-cp

tools/board_to_port.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
from pathlib import Path
3+
4+
docs = Path(__file__).parent.parent / "docs"
5+
sys.path.append(str(docs))
6+
from shared_bindings_matrix import get_board_mapping
7+
8+
board = sys.argv[1]
9+
port = sys.argv[2]
10+
11+
if port.strip() != "":
12+
print(port)
13+
sys.exit(0)
14+
15+
board_mapping = get_board_mapping()
16+
if board in board_mapping:
17+
board_info = board_mapping[board]
18+
print(board_info["port"])
19+
sys.exit(0)
20+
21+
raise ValueError(f"No port directory associated with the board tag given {board}.")

0 commit comments

Comments
 (0)