From e50572b7c00bf0673faa2233987effdb26c71261 Mon Sep 17 00:00:00 2001 From: Austin Date: Fri, 24 Jul 2026 13:47:27 -0400 Subject: [PATCH] Save/Restore seperately in MacOS/Windows caching workflows. (#11199) Only *save* cache on the default branch (develop), restore it everywhere it fits --- .github/workflows/build_macos_bin.yml | 28 ++++++++++++++++++---- .github/workflows/build_portduino_wasm.yml | 2 +- .github/workflows/build_windows_bin.yml | 16 +++++++++++-- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_macos_bin.yml b/.github/workflows/build_macos_bin.yml index a0f6328dc..a8c6bf766 100644 --- a/.github/workflows/build_macos_bin.yml +++ b/.github/workflows/build_macos_bin.yml @@ -14,6 +14,10 @@ permissions: jobs: build-MacOS: runs-on: macos-${{ inputs.macos_ver }} + # Only pushes to the default branch (develop) populate the cache; PR / merge_group runs + # restore it but never save, so they stop filling up the repo's Actions cache storage. + env: + SAVE_CACHE: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }} steps: - name: Checkout code uses: actions/checkout@v7 @@ -24,8 +28,9 @@ jobs: id: r_image run: echo "ver=$ImageVersion" >> "$GITHUB_OUTPUT" - - name: Cache Homebrew downloads - uses: actions/cache@v6 + - name: Restore Homebrew cache + id: brew-cache + uses: actions/cache/restore@v6 with: path: ~/Library/Caches/Homebrew key: brew-macos-${{ inputs.macos_ver }}-${{ steps.r_image.outputs.ver }} @@ -41,13 +46,21 @@ jobs: brew install platformio yaml-cpp libuv openssl@3 libusb argp-standalone pkg-config ulfius jsoncpp + - name: Save Homebrew cache + if: env.SAVE_CACHE == 'true' && steps.brew-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ~/Library/Caches/Homebrew + key: brew-macos-${{ inputs.macos_ver }}-${{ steps.r_image.outputs.ver }} + - name: Get release version string run: | echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT id: version - - name: Cache PlatformIO packages - uses: actions/cache@v6 + - name: Restore PlatformIO cache + id: pio-cache + uses: actions/cache/restore@v6 with: path: ~/.platformio/.cache key: pio-macos-${{ inputs.macos_ver }}-${{ hashFiles('platformio.ini', 'variants/native/portduino.ini') }} @@ -60,6 +73,13 @@ jobs: env: PKG_VERSION: ${{ steps.version.outputs.long }} + - name: Save PlatformIO cache + if: env.SAVE_CACHE == 'true' && steps.pio-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ~/.platformio/.cache + key: pio-macos-${{ inputs.macos_ver }}-${{ hashFiles('platformio.ini', 'variants/native/portduino.ini') }} + - name: List output files run: ls -lah .pio/build/native-macos/ diff --git a/.github/workflows/build_portduino_wasm.yml b/.github/workflows/build_portduino_wasm.yml index c6c32583a..0ec744332 100644 --- a/.github/workflows/build_portduino_wasm.yml +++ b/.github/workflows/build_portduino_wasm.yml @@ -29,7 +29,7 @@ jobs: uses: ./.github/actions/setup-native - name: Setup Emscripten SDK - uses: emscripten-core/setup-emsdk@v16 + uses: emscripten-core/setup-emsdk@0822153d7a5488b70a269cfa0a631b2a86ab4da2 # 'v17' main with: version: 6.0.1 actions-cache-folder: emsdk-cache diff --git a/.github/workflows/build_windows_bin.yml b/.github/workflows/build_windows_bin.yml index 29449ea0e..d0ee7b1d8 100644 --- a/.github/workflows/build_windows_bin.yml +++ b/.github/workflows/build_windows_bin.yml @@ -14,6 +14,10 @@ permissions: jobs: build-Windows: runs-on: windows-${{ inputs.windows_ver }} + # Only pushes to the default branch (develop) populate the cache; PR / merge_group runs + # restore it but never save, so they stop filling up the repo's Actions cache storage. + env: + SAVE_CACHE: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }} defaults: run: # UCRT64 is the MinGW-w64 environment native-windows targets; the `msys` @@ -71,8 +75,9 @@ jobs: python -m pip install --upgrade pip pip install platformio - - name: Cache PlatformIO packages - uses: actions/cache@v6 + - name: Restore PlatformIO cache + id: pio-cache + uses: actions/cache/restore@v6 with: path: ~/.platformio/.cache key: pio-windows-${{ inputs.windows_ver }}-${{ hashFiles('platformio.ini', 'variants/native/portduino.ini') }} @@ -94,6 +99,13 @@ jobs: env: PKG_VERSION: ${{ steps.version.outputs.long }} + - name: Save PlatformIO cache + if: env.SAVE_CACHE == 'true' && steps.pio-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ~/.platformio/.cache + key: pio-windows-${{ inputs.windows_ver }}-${{ hashFiles('platformio.ini', 'variants/native/portduino.ini') }} + - name: List output files run: ls -lah .pio/build/native-windows/