Skip to content

Update pipeline

Update pipeline #257

Workflow file for this run

name: ESP32
on:
workflow_dispatch:
push:
branches:
- '**'
paths:
- 'src/**'
- '.github/workflows/*.yml'
tags-ignore:
- 'v*'
pull_request:
branches:
- master
paths:
- 'src/**'
- '.github/workflows/*.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
setup-environment:
runs-on: ubuntu-24.04
steps:
# Get the latest MicroPython release
- name: Get MicroPython latest release
run: |
MPY_RELEASE=$(curl --silent "https://api.github.com/repos/micropython/micropython/releases/latest" | jq -r .tag_name)
echo "MPY_RELEASE=${MPY_RELEASE}" >> $GITHUB_ENV
# Cache ESP-IDF dependencies and MicroPython
- name: Cache ESP-IDF and MicroPython
id: cache_esp_idf
uses: actions/cache@v4
with:
lookup-only: true
path: |
~/esp-idf/
~/.espressif/
!~/.espressif/dist/
~/.cache/pip/
~/micropython/
key: mpy-${{ env.MPY_RELEASE }}
restore-keys: mpy-
# Install ESP-IDF dependencies (if not cached)
- name: Install dependencies
if: steps.cache_esp_idf.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
# Download and set up ESP-IDF (if not cached)
- name: Set up ESP-IDF
id: export-idf
if: steps.cache_esp_idf.outputs.cache-hit != 'true'
run: |
cd ~
git clone --depth 1 --branch v5.4 https://github.com/espressif/esp-idf.git
# git clone --depth 1 --branch ${{ env.IDF_VER }} https://github.com/espressif/esp-idf.git
git -C esp-idf submodule update --init --recursive --filter=tree:0
cd esp-idf
./install.sh all
cd components
# latest_cam_driver=$(curl -s https://api.github.com/repos/espressif/esp32-camera/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
# git clone --depth 1 --branch $latest_cam_driver https://github.com/espressif/esp32-camera.git
git clone https://github.com/cnadler86/esp32-camera.git
cd ~/esp-idf/
source ./export.sh
cd ~
git clone https://github.com/espressif/esp-adf-libs.git
cp -r ~/esp-adf-libs/esp_new_jpeg ~/esp-idf/components/
# Clone the latest MicroPython release (if not cached)
- name: Clone MicroPython latest release
id: clone-micropython
if: steps.cache_esp_idf.outputs.cache-hit != 'true'
run: |
echo "Cloning MicroPython release: $MPY_RELEASE"
cd ~/esp-idf/
source ./export.sh
cd ~
git clone --branch ${{ env.MPY_RELEASE }} https://github.com/micropython/micropython.git
echo "Micropython cloned successfully"
source ~/micropython/tools/ci.sh && echo "IDF_VER=$IDF_VER" >> $GITHUB_ENV
# Dynamically create jobs for each commit
build:
needs: setup-environment
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
commit_offset: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
steps:
# Get the latest MicroPython release
- name: Get MicroPython latest release
run: |
MPY_RELEASE=$(curl --silent "https://api.github.com/repos/micropython/micropython/releases/latest" | jq -r .tag_name)
echo "MPY_RELEASE=${MPY_RELEASE}" >> $GITHUB_ENV
# Cache ESP-IDF dependencies and MicroPython
- name: Cache ESP-IDF and MicroPython
uses: actions/cache@v4
with:
path: |
~/esp-idf/
~/.espressif/
!~/.espressif/dist/
~/.cache/pip/
~/micropython/
key: mpy-${{ env.MPY_RELEASE }}
restore-keys: mpy-
- name: Checkout repository
uses: actions/checkout@v4
- name: Install ESP-IDF dependencies
run: |
sudo apt-get update
sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 build-essential pkg-config
# Setup MicroPython for specific commit
- name: Setup MicroPython for commit
run: |
cd ~/esp-idf/
source ./export.sh
cd ~/micropython
# Get the commit hash that is N commits before the release tag
COMMIT_HASH=$(git rev-list --reverse HEAD~${{ matrix.commit_offset }}..HEAD | head -1)
if [ -z "$COMMIT_HASH" ]; then
COMMIT_HASH=$(git rev-parse HEAD~${{ matrix.commit_offset }})
fi
echo "Testing commit: $COMMIT_HASH (offset: ${{ matrix.commit_offset }})"
git checkout $COMMIT_HASH
git submodule update --init --depth 1
cd mpy-cross
make
cd ~/micropython/ports/esp32
make submodules
echo "Micropython setup successfully for commit $COMMIT_HASH"
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV
# Build MicroPython for ESP32_GENERIC_S3-SPIRAM_OCT
- name: Build MicroPython
run: |
cd ${{ github.workspace }}
git clone https://github.com/cnadler86/mp_jpeg.git
cd ~/esp-idf/components/esp32-camera
CAM_DRIVER=$(git describe --tags --always --dirty)
cd ~/micropython/ports/esp32
source ~/esp-idf/export.sh
# Fixed board configuration for ESP32_GENERIC_S3-SPIRAM_OCT
BOARD_NAME="ESP32_GENERIC_S3"
BOARD_VARIANT="SPIRAM_OCT"
BUILD_TARGET="ESP32_GENERIC_S3-SPIRAM_OCT"
IDF_CMD="idf.py -D MICROPY_BOARD=$BOARD_NAME -D USER_C_MODULES=${{ github.workspace }}/src/micropython.cmake -D MICROPY_BOARD_VARIANT=$BOARD_VARIANT -B build-$BUILD_TARGET -D MP_CAMERA_DRIVER_VERSION=$CAM_DRIVER -D MP_JPEG_DIR=${{ github.workspace }}/mp_jpeg"
FINAL_CMD="${IDF_CMD} build"
make USER_C_MODULES=${{ github.workspace }}/src/micropython.cmake BOARD=$BOARD_NAME submodules
echo "Running command: $FINAL_CMD"
eval $FINAL_CMD
cd ~/micropython/ports/esp32/build-${BUILD_TARGET}
python ../makeimg.py sdkconfig bootloader/bootloader.bin partition_table/partition-table.bin micropython.bin firmware.bin micropython.uf2
mkdir -p ~/artifacts
mv ~/micropython/ports/esp32/build-${BUILD_TARGET}/firmware.bin ~/artifacts/firmware.bin
# Get binary size info
ls -lh ~/artifacts/firmware.bin
FIRMWARE_SIZE=$(stat -c%s ~/artifacts/firmware.bin)
echo "Firmware size: $FIRMWARE_SIZE bytes"
echo "FIRMWARE_SIZE=$FIRMWARE_SIZE" >> $GITHUB_ENV
- name: Upload firmware artifact
uses: actions/upload-artifact@v4
with:
name: mpy_cam-${{ env.MPY_RELEASE }}-commit-${{ matrix.commit_offset }}-${{ env.COMMIT_HASH }}-ESP32_GENERIC_S3-SPIRAM_OCT
path: ~/artifacts/**
retention-days: 1