PlatformIO on GitHub Actions with cache accelerate

Published: (December 30, 2025 at 08:56 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Sample on official documentation

Official documentation suggests an 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 the build with pio run. PlatformIO CLI is written in Python, so Python is installed first. Caching both Python packages and PlatformIO files reduces workflow duration when download speeds are unstable or the PlatformIO package is large.

Improving the workflow

The workflow above unpacks packages each run, which takes time. Caching the unpacked files can eliminate the unpack step. The .platformio/ directory in the home folder contains download cache files and unpacked packages.

- uses: actions/cache@v4
  with:
    path: |
      ~/.cache/pip
#      ~/.platformio/.cache
      ~/.platformio/
    key: ${{ runner.os }}-pio

Note: Packages will not be updated until the cache is refreshed.

Experiment

The following experiment compares three workflow patterns: No cache, Download cached, and Unpack cached.

  • Measured steps: cache restoring, PlatformIO installation, and building.
  • Average of 5 runs (first run ignored because the cache is not hit).
  • Target task: build (no unit tests).
  • Source code: int main() containing only while(1) and return 0;.
  • Build focuses on the NUCLEO‑F303K8 HAL library; other settings are defaults.

Results

RunNo cache (s)Download cached (s)Unpack cached (s)
1321812
2342213
3321711
4351712
5311910
Average32.818.611.6

Download caching reduces the duration by about 14 seconds, and unpack caching saves an additional 7 seconds.

Back to Blog

Related posts

Read more »

AI SEO agencies Nordic

!Cover image for AI SEO agencies Nordichttps://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads...