refactor and simplify fetching port deps

This commit is contained in:
MicroDev 2023-02-22 20:11:38 +05:30
parent 592fea6822
commit 1ea21cc8fc
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
3 changed files with 34 additions and 14 deletions

24
.github/actions/deps/ports/action.yml vendored Normal file
View File

@ -0,0 +1,24 @@
name: Fetch port deps
inputs:
board:
required: true
type: string
outputs:
port:
value: ${{ steps.board-to-port.outputs.port }}
runs:
using: composite
steps:
- name: Board to port
id: board-to-port
run: |
PORT=$(find ports/*/boards/ -type d -name ${{ inputs.board }} | sed 's/^ports\///g;s/\/boards.*//g')
if [ -z $PORT ]; then (exit 1); else echo >> $GITHUB_OUTPUT "port=$PORT"; fi
shell: bash
- name: Set up espressif port
if: steps.board-to-port.outputs.port == 'espressif'
uses: ./.github/actions/deps/ports/espressif

View File

@ -51,20 +51,15 @@ jobs:
if: inputs.debug || inputs.flags != ''
run: |
> custom-build && git add custom-build
- name: Get port
id: get-port
run: |
PORT=$(find ports/*/boards/ -type d -name ${{ inputs.board }} | sed 's/^ports\///g;s/\/boards.*//g')
if [ -z $PORT ]; then (exit 1); else echo >> $GITHUB_OUTPUT "port=$PORT"; fi
- name: Port to platform
run: echo >> $GITHUB_ENV "PLATFORM=${{ env[format('PLATFORM_{0}', steps.get-port.outputs.port)] }}"
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Set up port
if: env.PLATFORM == 'esp'
uses: ./.github/actions/deps/ports/espressif
id: set-up-port
uses: ./.github/actions/deps/ports
with:
board: ${{ inputs.board }}
- name: Set up submodules
id: set-up-submodules
uses: ./.github/actions/deps/submodules
@ -75,7 +70,7 @@ jobs:
uses: ./.github/actions/deps/external
with:
action: cache
platform: ${{ env.PLATFORM }}
platform: ${{ env[format('PLATFORM_{0}', steps.set-up-port.outputs.port)] }}
- name: Set up mpy-cross
if: steps.set-up-submodules.outputs.frozen == 'True'
uses: ./.github/actions/mpy_cross
@ -96,9 +91,9 @@ jobs:
mkfs.fat --version || true
- name: Build board
run: make -j2 ${{ inputs.flags }} BOARD=${{ inputs.board }} DEBUG=${{ inputs.debug && '1' || '0' }} TRANSLATION=${{ inputs.language }}
working-directory: ports/${{ steps.get-port.outputs.port }}
working-directory: ports/${{ steps.set-up-port.outputs.port }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.board }}-${{ inputs.language }}-${{ inputs.version }}${{ inputs.flags != '' && '-custom' || '' }}${{ inputs.debug && '-debug' || '' }}
path: ports/${{ steps.get-port.outputs.port }}/build-${{ inputs.board }}/firmware.*
path: ports/${{ steps.set-up-port.outputs.port }}/build-${{ inputs.board }}/firmware.*

View File

@ -38,8 +38,9 @@ jobs:
with:
python-version: 3.x
- name: Set up port
if: inputs.platform == 'esp'
uses: ./.github/actions/deps/ports/espressif
uses: ./.github/actions/deps/ports
with:
board: ${{ matrix.board }}
- name: Set up submodules
id: set-up-submodules
uses: ./.github/actions/deps/submodules