hfudev / esp-idf-build-and-test-ci-template

3 stars 0 forks source link

Understanding Differences and Benefits: Docker Container vs. esp-idf-ci-action in CI/CD #2

Open hayschan opened 6 months ago

hayschan commented 6 months ago

Hello Hanxi Fu,

I'm currently exploring the best practices for implementing CI/CD in ESP32 projects and came across your repository "esp-idf-build-and-test-ci-template". I have also watched your video on Devcon. It's been incredibly helpful in understanding the CI/CD process for ESP-IDF.

I noticed that in your GitHub Action YAML, you've used the Docker container espressif/idf for building the target matrix:

runs-on: ubuntu-22.04
container:
  image: espressif/idf:${{ matrix.idf-branch }}

I've also observed another approach used in Uncle Rus's repository, where the GitHub Action espressif/esp-idf-ci-action is utilized:

- id: build_esp32
  name: Build
  uses: espressif/esp-idf-ci-action@v1
  with:
    esp_idf_version: ${{ matrix.esp_idf_version }}
    target: ${{ matrix.target }}

I'm keen to understand the differences and potential benefits of these two methods:

  1. Method One: Using the Docker container espressif/idf.
  2. Method Two: Using the espressif/esp-idf-ci-action.

Could you please provide insights into the following aspects:

Your insights would be incredibly valuable for the ESP32 developer community and those, like me, who are working to optimize our CI/CD pipelines.

Best regards, Hays Chan

hfudev commented 6 months ago

Hi @hayschan! no problem, I'm glad to help.

The key difference between the two options is that, the GH action espressif/esp-idf-ci-action is mainly for checking if the build process runs successfully, while the docker image espressif/idf, which includes the required toolchain and the idf repo, enables more flexible workflows.

Basically, there're two common scenarios:

  1. Running a single command like idf.py build for basic building.
  2. "build" first, then use the built binaries for testing on QEMU/ESP boards

If you just need to verify the build, the GH action is a straightforward choice. However, if you want to seamlessly integrate building and testing, the Docker image is the way to go. It'll significantly reduce the time spent on cloning the repo and running the install.sh script.

This template focuses on demonstrating the "build" and "test" process with our new tools, https://github.com/espressif/idf-build-apps and https://github.com/espressif/pytest-embedded. We recommend everyone adopt this CI/CD approach for smooth development cycles

I hope this clears things up! I'll also update the README to make the instructions clearer. Thank you for the feedback, it's always welcomed :)