I’m aiming to set up a build stage in an AWS pipeline where the source code is a PlatformIO project that I develop here in VSCode for ESP32’s. I’d like this build stage to compile the project and output a firmware binary that can be flashed to the ESP32’s (via OTA).
I am stuck trying to figure out how I could create a buildspec.yml file that set’s up the PlatformIO environment needed to compile the source code to a flashable binary. Can anyone point me in the right direction or share any similar examples?
In other words, if I gave you a PlatformIO project folder and a fresh VM (Ubuntu or Windows), how could the PlatformIO dev environment be setup in a few CLI commands so that you could compile the source over CLI.
Perhaps I should be manually setting up a container first with VSCode & PlatformIO, and then launching instances of that custom container from codebuild? The buildspec can instruct the container to unzip source code, open that folder with VSCode, compile with PlatformIO.
Alternatively, I could skip this step by compiling the new binary here in my local environment, pushing that binary to the repo and setting up my pipeline to source from only that binary file. Rather than the whole git branch. Is this a better option?
(Optional: Cache PlatformIO and PIP for faster reinstall times next time)
It really doesn’t get simpler than that.
Other people have setup Docker containers that have PlatformIO preinstalled: New Docker Image.
Of course, using a rather simple Dockerfile, you could also fork from the official Python image, pip install platformio in there and be done.
I see 0 reason why one would need a graphical VSCode install in the CI. Use the PIO core standalone, that’s all you need to build stuff. (And upload. And test. And do code checks. And remote-upload and remote-test. The core has all the needed logic.)