Skip to content

Commit 1ea21cc

Browse files
committed
refactor and simplify fetching port deps
1 parent 592fea6 commit 1ea21cc

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Fetch port deps
2+
3+
inputs:
4+
board:
5+
required: true
6+
type: string
7+
8+
outputs:
9+
port:
10+
value: ${{ steps.board-to-port.outputs.port }}
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Board to port
16+
id: board-to-port
17+
run: |
18+
PORT=$(find ports/*/boards/ -type d -name ${{ inputs.board }} | sed 's/^ports\///g;s/\/boards.*//g')
19+
if [ -z $PORT ]; then (exit 1); else echo >> $GITHUB_OUTPUT "port=$PORT"; fi
20+
shell: bash
21+
22+
- name: Set up espressif port
23+
if: steps.board-to-port.outputs.port == 'espressif'
24+
uses: ./.github/actions/deps/ports/espressif

.github/workflows/build-boards-custom.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,15 @@ jobs:
5151
if: inputs.debug || inputs.flags != ''
5252
run: |
5353
> custom-build && git add custom-build
54-
- name: Get port
55-
id: get-port
56-
run: |
57-
PORT=$(find ports/*/boards/ -type d -name ${{ inputs.board }} | sed 's/^ports\///g;s/\/boards.*//g')
58-
if [ -z $PORT ]; then (exit 1); else echo >> $GITHUB_OUTPUT "port=$PORT"; fi
59-
- name: Port to platform
60-
run: echo >> $GITHUB_ENV "PLATFORM=${{ env[format('PLATFORM_{0}', steps.get-port.outputs.port)] }}"
6154
- name: Set up python
6255
uses: actions/setup-python@v4
6356
with:
6457
python-version: 3.x
6558
- name: Set up port
66-
if: env.PLATFORM == 'esp'
67-
uses: ./.github/actions/deps/ports/espressif
59+
id: set-up-port
60+
uses: ./.github/actions/deps/ports
61+
with:
62+
board: ${{ inputs.board }}
6863
- name: Set up submodules
6964
id: set-up-submodules
7065
uses: ./.github/actions/deps/submodules
@@ -75,7 +70,7 @@ jobs:
7570
uses: ./.github/actions/deps/external
7671
with:
7772
action: cache
78-
platform: ${{ env.PLATFORM }}
73+
platform: ${{ env[format('PLATFORM_{0}', steps.set-up-port.outputs.port)] }}
7974
- name: Set up mpy-cross
8075
if: steps.set-up-submodules.outputs.frozen == 'True'
8176
uses: ./.github/actions/mpy_cross
@@ -96,9 +91,9 @@ jobs:
9691
mkfs.fat --version || true
9792
- name: Build board
9893
run: make -j2 ${{ inputs.flags }} BOARD=${{ inputs.board }} DEBUG=${{ inputs.debug && '1' || '0' }} TRANSLATION=${{ inputs.language }}
99-
working-directory: ports/${{ steps.get-port.outputs.port }}
94+
working-directory: ports/${{ steps.set-up-port.outputs.port }}
10095
- name: Upload artifact
10196
uses: actions/upload-artifact@v3
10297
with:
10398
name: ${{ inputs.board }}-${{ inputs.language }}-${{ inputs.version }}${{ inputs.flags != '' && '-custom' || '' }}${{ inputs.debug && '-debug' || '' }}
104-
path: ports/${{ steps.get-port.outputs.port }}/build-${{ inputs.board }}/firmware.*
99+
path: ports/${{ steps.set-up-port.outputs.port }}/build-${{ inputs.board }}/firmware.*

.github/workflows/build-boards.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ jobs:
3838
with:
3939
python-version: 3.x
4040
- name: Set up port
41-
if: inputs.platform == 'esp'
42-
uses: ./.github/actions/deps/ports/espressif
41+
uses: ./.github/actions/deps/ports
42+
with:
43+
board: ${{ matrix.board }}
4344
- name: Set up submodules
4445
id: set-up-submodules
4546
uses: ./.github/actions/deps/submodules

0 commit comments

Comments
 (0)