-
Notifications
You must be signed in to change notification settings - Fork 93
115 lines (96 loc) · 3.06 KB
/
reusable-platformio-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Reusable PlatformIO CI
# Controls when this action will run.
on:
workflow_call:
inputs:
ros_distro:
description: 'ROS_DISTRO variable'
required: true
type: string
reference:
description: 'Branch or tag of repo to checkout for build.'
default: ''
required: false
type: string
jobs:
# This job is used to build the calibration firmware
build-calibration:
name: Build Calibration
runs-on: ubuntu-latest
steps:
# Check out the repository
- uses: actions/checkout@v3
with:
ref: ${{ inputs.reference }}
path: repo
# Cache dependencies to speed up workflows
- uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- name: Install environment
uses: ./repo/.github/actions/platformio-env
- name: Build Calibration
run: |
export PATH=$PATH:~/.platformio/penv/bin
cd repo/calibration
pio run
# This job parses the firmware/platformio.ini file
pio-fw-matrix:
name: Parse firmware/platformio.ini
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
# check out the repository
- uses: actions/checkout@v3
with:
ref: ${{ inputs.reference }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
# run the python script to parse the platformio.ini file and output as json to a matrix
# pass the ros distros desired as arguments
- name: Parse platformio.ini
id: set-matrix
run: |
echo "matrix=$(python .github/parse_platformio.py)" >> $GITHUB_OUTPUT
# This job builds the firmware for each environment parsed from the platformio.ini file
build-firmware:
# require the pio-fw-matrix job to complete before running
needs: pio-fw-matrix
runs-on: ubuntu-latest
name: Build ${{ matrix.env }} firmware on ROS ${{ inputs.ros_distro }}
strategy:
# don't stop all jobs if one fails
fail-fast: false
# Build the firmware for each environment from parsing job in parallel
matrix:
include: ${{fromJson(needs.pio-fw-matrix.outputs.matrix)}}
steps:
# Check out the repository
- uses: actions/checkout@v3
with:
ref: ${{ inputs.reference }}
path: repo
# Cache dependencies to speed up workflows
- uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- name: Install environment
uses: ./repo/.github/actions/platformio-env
# Build the firmware for each environment in parallel
- name: Build Firmware
env:
ROS_DISTRO: ${{ inputs.ros_distro }}
shell: bash
run: |
export PATH=$PATH:~/.platformio/penv/bin
cd repo/firmware
pio run -e ${{ matrix.env }}