From 339686a23cbd0692bb34a43c8bb702348ea6f03d Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 1 Jul 2024 13:43:06 +0100 Subject: [PATCH 1/3] Cache esp-idf and tools --- .github/workflows/ci-esp32.yml | 22 ++++++++++++++++++++-- Sming/Arch/Esp32/Tools/install.cmd | 8 +++++--- Sming/Arch/Esp32/Tools/install.sh | 3 +-- Tools/ci/setenv.ps1 | 9 ++------- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-esp32.yml b/.github/workflows/ci-esp32.yml index d0dda46259..90761f6979 100644 --- a/.github/workflows/ci-esp32.yml +++ b/.github/workflows/ci-esp32.yml @@ -32,7 +32,7 @@ jobs: - os: windows-latest idf_version: "5.0" - concurrency: + concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ toJson(matrix) }} cancel-in-progress: true @@ -62,8 +62,26 @@ jobs: "CI_BUILD_DIR=" + (Resolve-Path ".").path >> $env:GITHUB_ENV "SMING_HOME=" + (Resolve-Path "Sming").path >> $env:GITHUB_ENV + - name: Fix permissions + if: ${{ matrix.os != 'windows-latest' }} + run: | + sudo chown $USER /opt + + - name: Cache ESP-IDF + uses: actions/cache@v4 + with: + path: /opt/esp-idf-${{ matrix.idf_version }} + key: idf-${{ matrix.idf_version }} + enableCrossOsArchive: true + + - name: Cache build tools + uses: actions/cache@v4 + with: + path: /opt/esp32 + key: ${{ matrix.os }}-esp32-${{ matrix.idf_version }} + - name: Install build tools for Ubuntu - if: ${{ matrix.os == 'ubuntu-latest' }} + if: ${{ matrix.os == 'ubuntu-latest' }} run: | Tools/ci/install.sh diff --git a/Sming/Arch/Esp32/Tools/install.cmd b/Sming/Arch/Esp32/Tools/install.cmd index 8e758a62de..2d2ddd0205 100644 --- a/Sming/Arch/Esp32/Tools/install.cmd +++ b/Sming/Arch/Esp32/Tools/install.cmd @@ -3,18 +3,20 @@ REM Esp32 install.cmd if "%IDF_PATH%"=="" goto :EOF if "%IDF_TOOLS_PATH%"=="" goto :EOF +if exist "%IDF_PATH%" goto :setup + if "%IDF_REPO%"=="" set IDF_REPO="https://github.com/mikee47/esp-idf.git" if "%INSTALL_IDF_VER%"=="" set INSTALL_IDF_VER=5.2 set IDF_BRANCH="sming/release/v%INSTALL_IDF_VER%" git clone -b %IDF_BRANCH% %IDF_REPO% %IDF_PATH% +:setup + REM Install IDF tools and packages python "%IDF_PATH%\tools\idf_tools.py" --non-interactive install python -m pip install %SMINGTOOLS%/gevent-1.5.0-cp39-cp39-win_amd64.whl -set IDF_REQUIREMENTS="%IDF_PATH%\requirements.txt" -if not exist "%IDF_REQUIREMENTS%" set IDF_REQUIREMENTS="%IDF_PATH%\tools\requirements\requirements.core.txt" -python -m pip install -r "%IDF_REQUIREMENTS%" +python3 "%IDF_PATH%\tools\idf_tools.py" --non-interactive install-python-env if "%INSTALL_IDF_VER%" == "5.0" goto :install_python if "%INSTALL_IDF_VER%" == "5.2" goto :install_python diff --git a/Sming/Arch/Esp32/Tools/install.sh b/Sming/Arch/Esp32/Tools/install.sh index 20c1fae9ed..b19851174a 100755 --- a/Sming/Arch/Esp32/Tools/install.sh +++ b/Sming/Arch/Esp32/Tools/install.sh @@ -44,7 +44,7 @@ if [ ! -L "$IDF_PATH" ] && [ -d "$IDF_PATH" ]; then fi INSTALL_IDF_VER="${INSTALL_IDF_VER:=5.2}" -IDF_CLONE_PATH="$IDF_PATH/../esp-idf-${INSTALL_IDF_VER}" +IDF_CLONE_PATH="$(dirname $IDF_PATH)/esp-idf-${INSTALL_IDF_VER}" IDF_REPO="${IDF_REPO:=https://github.com/mikee47/esp-idf.git}" IDF_BRANCH="sming/release/v${INSTALL_IDF_VER}" @@ -54,7 +54,6 @@ else echo "git clone -b $IDF_BRANCH $IDF_REPO $IDF_CLONE_PATH" git clone -b "$IDF_BRANCH" "$IDF_REPO" "$IDF_CLONE_PATH" fi -IDF_CLONE_PATH=$(realpath "$IDF_CLONE_PATH") # Create link to clone rm -rf "$IDF_PATH" diff --git a/Tools/ci/setenv.ps1 b/Tools/ci/setenv.ps1 index 17b6cbf472..fb6837868d 100644 --- a/Tools/ci/setenv.ps1 +++ b/Tools/ci/setenv.ps1 @@ -1,9 +1,4 @@ -if($IsWindows) { - $TOOLS_DIR = "C:\tools" -} else { - $TOOLS_DIR = "/opt" - sudo chown appveyor:appveyor /opt -} +$TOOLS_DIR = "D:/opt" $env:CI_BUILD_DIR = (Resolve-Path "$PSScriptRoot/../..").Path $env:SMING_HOME = Join-Path $env:CI_BUILD_DIR "Sming" @@ -12,7 +7,7 @@ $env:SMING_HOME = Join-Path $env:CI_BUILD_DIR "Sming" $env:ESP_HOME = Join-Path $TOOLS_DIR "esp-quick-toolchain" # Esp32 -$env:IDF_PATH = Join-Path $TOOLS_DIR "esp-idf" +$env:IDF_PATH = Join-Path $TOOLS_DIR "esp-idf-$env:INSTALL_IDF_VER" $env:IDF_TOOLS_PATH = Join-Path $TOOLS_DIR "esp32" # Rp2040 From 1d6997cadf41153c29208baf07f01207e6ee66b2 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 1 Jul 2024 20:45:44 +0100 Subject: [PATCH 2/3] Shrink IDF size using shallow clone --- Sming/Arch/Esp32/Tools/install.cmd | 5 ++++- Sming/Arch/Esp32/Tools/install.sh | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Sming/Arch/Esp32/Tools/install.cmd b/Sming/Arch/Esp32/Tools/install.cmd index 2d2ddd0205..fec3dce891 100644 --- a/Sming/Arch/Esp32/Tools/install.cmd +++ b/Sming/Arch/Esp32/Tools/install.cmd @@ -9,7 +9,10 @@ if "%IDF_REPO%"=="" set IDF_REPO="https://github.com/mikee47/esp-idf.git" if "%INSTALL_IDF_VER%"=="" set INSTALL_IDF_VER=5.2 set IDF_BRANCH="sming/release/v%INSTALL_IDF_VER%" -git clone -b %IDF_BRANCH% %IDF_REPO% %IDF_PATH% +if "%CI_BUILD_DIR%" NEQ "" ( + set IDF_INSTALL_OPTIONS=--depth 1 --recurse-submodules --shallow-submodules +) +git clone -b %IDF_BRANCH% %IDF_REPO% %IDF_PATH% %IDF_INSTALL_OPTIONS% :setup diff --git a/Sming/Arch/Esp32/Tools/install.sh b/Sming/Arch/Esp32/Tools/install.sh index b19851174a..e0c3535b8c 100755 --- a/Sming/Arch/Esp32/Tools/install.sh +++ b/Sming/Arch/Esp32/Tools/install.sh @@ -51,8 +51,11 @@ IDF_BRANCH="sming/release/v${INSTALL_IDF_VER}" if [ -d "$IDF_CLONE_PATH" ]; then printf "\n\n** Skipping ESP-IDF clone: '%s' exists\n\n" "$IDF_CLONE_PATH" else + if [ -n "$CI_BUILD_DIR" ]; then + IDF_INSTALL_OPTIONS="--depth 1 --recurse-submodules --shallow-submodules" + fi echo "git clone -b $IDF_BRANCH $IDF_REPO $IDF_CLONE_PATH" - git clone -b "$IDF_BRANCH" "$IDF_REPO" "$IDF_CLONE_PATH" + git clone -b "$IDF_BRANCH" "$IDF_REPO" "$IDF_CLONE_PATH" $IDF_INSTALL_OPTIONS fi # Create link to clone From f2dec3616c27171c2fe0e2acb7de830793162dba Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 1 Jul 2024 21:42:05 +0100 Subject: [PATCH 3/3] Fix shellcheck issues --- Sming/Arch/Esp32/Tools/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sming/Arch/Esp32/Tools/install.sh b/Sming/Arch/Esp32/Tools/install.sh index e0c3535b8c..fa191f34ad 100755 --- a/Sming/Arch/Esp32/Tools/install.sh +++ b/Sming/Arch/Esp32/Tools/install.sh @@ -44,7 +44,7 @@ if [ ! -L "$IDF_PATH" ] && [ -d "$IDF_PATH" ]; then fi INSTALL_IDF_VER="${INSTALL_IDF_VER:=5.2}" -IDF_CLONE_PATH="$(dirname $IDF_PATH)/esp-idf-${INSTALL_IDF_VER}" +IDF_CLONE_PATH="$(dirname "$IDF_PATH")/esp-idf-${INSTALL_IDF_VER}" IDF_REPO="${IDF_REPO:=https://github.com/mikee47/esp-idf.git}" IDF_BRANCH="sming/release/v${INSTALL_IDF_VER}" @@ -59,7 +59,7 @@ else fi # Create link to clone -rm -rf "$IDF_PATH" +rm -f "$IDF_PATH" ln -s "$IDF_CLONE_PATH" "$IDF_PATH" # Install IDF tools and packages