diff --git a/ansible/roles/gitea-actions/defaults/main.yml b/ansible/roles/gitea-actions/defaults/main.yml index 47684fe..d182741 100644 --- a/ansible/roles/gitea-actions/defaults/main.yml +++ b/ansible/roles/gitea-actions/defaults/main.yml @@ -28,6 +28,12 @@ gitea_ci_image: localhost/gitea-ci:latest # ESP-IDF firmware image tag tracks the upstream espressif/idf release we build from. esp_idf_version: v5.4.1 gitea_ci_espidf_image: "localhost/gitea-ci-espidf:{{ esp_idf_version }}" +# PlatformIO image for Arduino-framework ESP32 builds (esp32-web-interface). +# Tag tracks the pre-baked espressif32 platform version; both pins match the +# hardware-validated local build. +platformio_core_version: "6.1.19" +pio_espressif32_version: "7.0.1" +gitea_ci_platformio_image: "localhost/gitea-ci-platformio:{{ pio_espressif32_version }}" # Default labels for every runner — map runs-on values to the local CI image. # Firmware jobs opt into the ESP-IDF image per-job via `container:` in their workflow. diff --git a/ansible/roles/gitea-actions/tasks/images.yml b/ansible/roles/gitea-actions/tasks/images.yml index dcd10e5..e33b5e4 100644 --- a/ansible/roles/gitea-actions/tasks/images.yml +++ b/ansible/roles/gitea-actions/tasks/images.yml @@ -41,6 +41,16 @@ XDG_RUNTIME_DIR: "/run/user/{{ gitea_runner_uid }}" tags: gitea-actions +- name: stage PlatformIO CI Containerfile + become: true + become_user: "{{ gitea_runner_user }}" + ansible.builtin.template: + src: Containerfile.platformio.j2 + dest: "{{ gitea_runner_home }}/ci-images/Containerfile.platformio" + mode: "0644" + register: platformio_containerfile + tags: gitea-actions + - name: build ESP-IDF CI image ({{ gitea_ci_espidf_image }}) become: true become_user: "{{ gitea_runner_user }}" @@ -53,3 +63,16 @@ environment: XDG_RUNTIME_DIR: "/run/user/{{ gitea_runner_uid }}" tags: gitea-actions + +- name: build PlatformIO CI image ({{ gitea_ci_platformio_image }}) + become: true + become_user: "{{ gitea_runner_user }}" + containers.podman.podman_image: + name: "{{ gitea_ci_platformio_image }}" + path: "{{ gitea_runner_home }}/ci-images" + build: + file: "{{ gitea_runner_home }}/ci-images/Containerfile.platformio" + force: "{{ platformio_containerfile is changed }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ gitea_runner_uid }}" + tags: gitea-actions diff --git a/ansible/roles/gitea-actions/templates/Containerfile.platformio.j2 b/ansible/roles/gitea-actions/templates/Containerfile.platformio.j2 new file mode 100644 index 0000000..acbd763 --- /dev/null +++ b/ansible/roles/gitea-actions/templates/Containerfile.platformio.j2 @@ -0,0 +1,29 @@ +# PlatformIO firmware job image (managed by ansible: roles/gitea-actions). +# For Arduino-framework ESP32 projects (e.g. Skudak/esp32-web-interface) that +# build with PlatformIO rather than raw ESP-IDF. Node is required by +# actions/checkout and other JS actions. +# The espressif32 platform, xtensa toolchain and Arduino framework are +# pre-baked into PLATFORMIO_CORE_DIR via a throwaway seed project so ephemeral +# job containers download nothing at build time. Versions are pinned to what +# was validated on hardware — bump pio_espressif32_version / +# platformio_core_version in defaults/main.yml to upgrade (the image tag +# tracks the platform version). +FROM python:3.12-slim-bookworm + +ENV PLATFORMIO_CORE_DIR=/opt/platformio + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git curl ca-certificates unzip \ + && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get install -y --no-install-recommends nodejs \ + && rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache-dir platformio=={{ platformio_core_version }} + +# Seed project mirroring the real projects' platformio.ini so `pio pkg install` +# pulls the platform + toolchain + framework packages into the core dir. +RUN mkdir -p /tmp/seed/src \ + && printf '[env:seed]\nplatform = espressif32@{{ pio_espressif32_version }}\nframework = arduino\nboard = esp32dev\nboard_build.filesystem = spiffs\n' > /tmp/seed/platformio.ini \ + && pio pkg install -d /tmp/seed \ + && rm -rf /tmp/seed \ + && chmod -R a+rX ${PLATFORMIO_CORE_DIR}