Skip to content

Commit c9eba1e

Browse files
committed
fix(ci): activate the ESP-IDF venv so idf.py runs
install-esp-idf-action only sets IDF_PATH; scripts/build.py then invoked idf.py with the system Python, which idf.py rejects ("not spawned within an ESP-IDF shell environment"), failing every board build. Source export.sh in setup-esp-idf and persist the venv-activated PATH/IDF_PYTHON_ENV_PATH to GITHUB_ENV so python and idf.py resolve to the ESP-IDF venv in later steps. Install littlefs-python into that venv for gen_staticfs.py (full compiledb build); leave esptool to idf.py's bundled copy. Keep the ~/.espressif tools cache (it also captures the venv, so the littlefs-python install is a no-op on a hit).
1 parent 32b8813 commit c9eba1e

1 file changed

Lines changed: 25 additions & 18 deletions

File tree

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: setup-esp-idf
22
description: >-
3-
Install a pinned native ESP-IDF toolchain plus the Python deps our build
4-
scripts need (gen_env_header.py / gen_staticfs.py). Shared by every job that
5-
runs idf.py. Replaces the PlatformIO pio-cache action.
3+
Install a pinned native ESP-IDF toolchain, activate its Python virtualenv for
4+
every later step, and install the build-time Python deps our scripts need.
5+
Shared by every job that runs idf.py. Replaces the PlatformIO pio-cache action.
66
inputs:
77
idf-version:
88
description: 'ESP-IDF version to install (EIM version tag).'
@@ -12,10 +12,10 @@ inputs:
1212
runs:
1313
using: composite
1414
steps:
15-
# Best-effort restore of the IDF tool store (compilers, openocd, ...). The
16-
# install action below still runs and is authoritative for PATH/IDF_PATH; a
17-
# warm ~/.espressif just lets it detect an existing install and skip the
18-
# multi-hundred-MB download. Keyed by version so a bump invalidates cleanly.
15+
# Cache the ESP-IDF tool store (toolchains, openocd, and the Python venv all
16+
# live under IDF_TOOLS_PATH=~/.espressif) so the install below reuses them
17+
# instead of re-downloading hundreds of MB. Keyed by version; the venv (with
18+
# littlefs-python) is captured at post-job save.
1919
- name: Cache ESP-IDF tools
2020
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
2121
with:
@@ -24,20 +24,27 @@ runs:
2424
restore-keys: |
2525
esp-idf-tools-${{ runner.os }}-
2626
27-
# Installs ESP-IDF and puts idf.py / esptool.py on PATH for later run steps
28-
# (no need to source export.sh). v1 is a moving branch (the repo publishes no
29-
# release tags), pinned by SHA per this repo's convention.
27+
# Installs ESP-IDF and sets IDF_PATH for later steps. v1 is a moving branch
28+
# (the repo publishes no release tags), pinned by SHA per this repo's convention.
3029
- name: Install ESP-IDF
3130
uses: espressif/install-esp-idf-action@8fc05d1470d5591417e7a3707a1f2bec178db4ae # v1
3231
with:
3332
version: ${{ inputs.idf-version }}
3433

35-
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
36-
with:
37-
cache: 'pip'
38-
39-
- name: Install Python dependencies
34+
# scripts/build.py runs idf.py through the current Python interpreter, which
35+
# MUST be the ESP-IDF venv (idf.py refuses to run otherwise). install-esp-idf
36+
# -action only sets IDF_PATH, so activate the venv here and persist it to
37+
# GITHUB_ENV so `python` / `idf.py` resolve to the venv in every later step.
38+
- name: Activate ESP-IDF environment
4039
shell: bash
41-
# littlefs-python (gen_staticfs.py) + GitPython/cryptography (env + cert
42-
# tooling). esptool ships inside ESP-IDF, so it is not reinstalled here.
43-
run: pip install -r requirements.txt
40+
run: |
41+
. "$IDF_PATH/export.sh"
42+
# gen_staticfs.py (invoked by CMake under the venv python during a full
43+
# build) needs littlefs-python. Install it INTO the venv. esptool is
44+
# deliberately not installed - idf.py bundles its own and a pip esptool
45+
# would clobber it (the standalone merge job installs esptool separately).
46+
python -m pip install --quiet "littlefs-python==0.14.0"
47+
{
48+
echo "PATH=$PATH"
49+
echo "IDF_PYTHON_ENV_PATH=${IDF_PYTHON_ENV_PATH:-}"
50+
} >> "$GITHUB_ENV"

0 commit comments

Comments
 (0)