Sample on official doc available
Official documentation suggests example workflow of using PlatformIO on GitHub Actions.
name: PlatformIO CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Build PlatformIO Project
run: pio run
Setup PlatformIO CLI pio, then run build by pio run. PlatformIO CLI is made with Python. So, it setups Python at first.
Additionally, Python and PlatformIO caching is there. Sometimes downloading speed will be unstable, and PlatformIO package size is a little heavy. So, caching them makes short workflow duration.
Improve more
That workflow has unpacking step, and it takes some time. So, caching unpacked filed, you can cut step of unpacking.
.platformio/ on home directory including download cache files and unpacked packages.
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
- ~/.platformio/.cache
+ ~/.platformio/
key: ${{ runner.os }}-pio
Note: But the packages will not be updated until same cache using.
Experiment
Let's check difference of duration of 3 pattern workflows: 'No cache', 'Download cached' and 'Unpack cached'
- Target steps to measure: Cache restoring, PlatformIO installing and building
- Take average of 5 times attempt
- Ignore first attempt due to cache won't be hit
- Target task: build (not unit-test)
- ソースは
int main()にwhile(1)とreturn 0;のみでほぼ空 - 実質 NUCLEO-F303K8 の HAL ライブラリのビルドだけ
- それ以外の設定などはデフォルト値のまま
- ソースは
Source on GitHub repository:
aKuad
/
pio-actions-exp
Experiment of PlatformIO on GitHub Actions
Result:
| # | No cache | Download cached | Unpack cached |
|---|---|---|---|
| 1 | 32 | 18 | 12 |
| 2 | 34 | 22 | 13 |
| 3 | 32 | 17 | 11 |
| 4 | 35 | 17 | 12 |
| 5 | 31 | 19 | 10 |
| Ave. | 32.8 | 18.6 | 11.6 |
Download caching cuts 14 sec、unpack caching cuts more 7 sec duration.
Top comments (0)