Skip to content

Andreas-Huber/platformio-docker-for-ci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PlatformIO Continuous Integration Docker Image

This Docker image can be used to create PlatformIO CI-Builds with a build service that supports Docker containers. We tested the image with Azure Pipelines and Github Actions but theoretically, it should work in GitLab CI, Circle CI, Travis CI, etc. The image does not contain an entry point because the build runner executes the tasks inside the container.

View it on Docker Hub

Azure Pipelines example

The following build script builds the ESP32 firmware in the example folder withing the infinitecoding/platformio-for-ci Docker container with Azure pipelines.

Build Status

example/azure-pipelines-example.yml

trigger:
- azure-pipelines

pool:
  vmImage: 'ubuntu-latest'

resources:
  containers:
  - container: platformio
    image: infinitecoding/platformio-for-ci:latest
    endpoint: personal-docker-hub-connection

container: platformio
steps:

- script: platformio run -d ./example/
  displayName: 'Build firmware'

- task: CopyFiles@2
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)/example/.pio/build/esp32dev/'
    Contents: 'firmware.bin'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  inputs:
    ArtifactName: 'Firmware $(Build.BuildNumber)'
    PathtoPublish: $(Build.ArtifactStagingDirectory)
    publishLocation: Container
    TargetPath: .

GitHub Actions example

The following build script builds the ESP32 firmware in the example folder withing the infinitecoding/platformio-for-ci Docker container with GitHub actions.

Example-CI

.github\workflows\platformio-example.yml

name: Example-CI

on:
  push:
    branches: [ github-actions ]

jobs:
  platformio-build:
    runs-on: ubuntu-latest
    container: infinitecoding/platformio-for-ci:latest

    steps:
      - uses: actions/checkout@v2

      - name: Build firmware
        run: platformio run -d ./example/

      - name: Upload firware artifact
        uses: actions/upload-artifact@v2
        with:
          name: firmware.elf
          path: example/.pio/build/esp32dev/firmware.elf

Run the container locally

To test if the PlatformIO build works with the container, you can also run it locally.

Linux & MAC

To build the project in the example folder on a UNIX system, run the following commands. Or run the runBuildInDocker.sh bash script.

# Set the example project folder as the working directory
cd example

# Run the build
docker run -v `pwd`:/opt/build --name pio-build infinitecoding/platformio-for-ci:latest platformio run -d /opt/build/.

# Delete the container
docker rm pio-build

Windows

To build the project in the example folder on a Windows system, run the following commands. Or run the runBuildInDocker.ps1 PowerShell script.

# Set the example project folder as the working directory
cd example

# Run the build
docker run -v ${pwd}:/opt/build --name pio-build infinitecoding/platformio-for-ci:latest platformio run -d /opt/build/.

# Delete the container
docker rm pio-build