Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions .github/workflows/build_macos_bin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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') }}
Expand All @@ -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/

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_portduino_wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/build_windows_bin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Comment on lines +17 to +20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow file =="
if [ -f .github/workflows/build_windows_bin.yml ]; then
  nl -ba .github/workflows/build_windows_bin.yml | sed -n '1,140p'
else
  echo "missing .github/workflows/build_windows_bin.yml"
fi

echo
echo "== relevant workflow references =="
rg -n "SAVE_CACHE|msys2/setup-msys2|setup-python|cache:|platformio ci|restore|save" .github/workflows/build_windows_bin.yml .github/workflows 2>/dev/null || true

echo
echo "== changed files/stat =="
git diff --stat HEAD~1..HEAD 2>/dev/null || git diff --stat 2>/dev/null || true

Repository: meshtastic/firmware

Length of output: 217


🌐 Web query:

msys2/setup-msys2 v2 cache true restore-only-save-cache branch PR documentation

💡 Result:

The msys2/setup-msys2 action does not provide a specific restore-only-save-cache parameter or feature. The official cache option accepts a boolean value (true or false) [1][2][3], where true (the default) automatically handles both restoring and saving the package cache during workflow runs [1][4][5]. Research into the action's development history reveals the following context regarding caching behavior: 1. Automatic Management: The action was designed to manage caching automatically to avoid complexity for users [6]. It implements internal logic to determine when to restore, prune, and save caches based on environment configuration and package changes [4][7]. 2. Alternative Approaches: There is no documented native parameter to restrict the action to "restore-only" behavior. Previous discussions regarding granular cache control (such as separating restore and save phases) have generally been addressed by the maintainers through the current automated system [4][8][6]. 3. Current Implementation: The action uses GitHub Actions caching to store and retrieve packages [7][3]. If you require specific cache behavior not supported by the action, users typically manage this by setting cache: false and implementing custom cache steps using the official actions/cache action [1][8]. If you are looking for this feature due to issues with cache size or race conditions, note that the action includes built-in safeguards, such as pruning caches before saving and avoiding redundant saves if the cache has not changed [4][7].

Citations:


🌐 Web query:

actions/setup-python v6 cache pip restore-default branch PR documentation

💡 Result:

The actions/setup-python action (v6+) provides built-in dependency caching for pip, pipenv, and poetry [1][2]. By default, this action uses the hash of your dependency file (e.g., requirements.txt or pyproject.toml) to create a unique cache key [1][2]. When a workflow runs, the action searches for a cache match based on this key [3]. If an exact match is not found, it can fall back to partial matches using restore keys if they were configured [3][4]. Regarding your specific interest in "restore-default" branch behavior or PR-related caching: 1. Cache Scope and PRs: Caches are scoped by the branch and the repository [3]. For pull requests, the action attempts to restore the cache from the current branch. If no cache is found for the feature branch, GitHub Actions automatically falls back to searching for a cache from the base branch (e.g., main or master) [3]. This ensures that PRs can benefit from existing dependencies installed on the default branch without needing to build from scratch. 2. Read-Only Cache Mode: To prevent issues like "cache poisoning" (where an untrusted PR might upload malicious packages to the cache), you can use the cache-write input [5]. By setting cache-write to false (e.g., cache-write: ${{ github.event_name != 'pull_request' }}), you can allow PRs to restore existing caches in read-only mode while preventing them from writing new cache entries [5]. 3. Advanced Configuration: You can use cache-dependency-path if you need to point to specific dependency files, including multiple files or wildcard patterns, especially if they are located outside the workspace root [1][6][7]. In summary, the "restore" logic for branches happens automatically: the runner looks for a cache on the current branch first, and if that fails, it looks for one on the parent/default branch [3]. You do not need to manually configure "restore-default" branch logic, as this is standard behavior of the underlying GitHub Actions cache service [3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow file =="
if [ -f .github/workflows/build_windows_bin.yml ]; then
  awk '{printf "%4d\t%s\n", NR, $0}' .github/workflows/build_windows_bin.yml | sed -n '1,140p'
else
  echo "missing .github/workflows/build_windows_bin.yml"
fi

echo
echo "== relevant workflow references =="
rg -n "SAVE_CACHE|msys2/setup-msys2|setup-python|cache:|platformio ci|restore|save" .github/workflows/build_windows_bin.yml .github/workflows 2>/dev/null || true

echo
echo "== changed files/stat =="
git diff --stat HEAD~1..HEAD 2>/dev/null || git diff --stat 2>/dev/null || true

Repository: meshtastic/firmware

Length of output: 10184


Gate the built-in dependency caches too.

SAVE_CACHE only skips the PlatformIO save step, but this workflow still allows msys2/setup-msys2@v2 with cache: true and actions/setup-python@v6 with cache: pip to save caches on PR/merge_group runs. That contradicts the comment policy; use cache: false or explicit actions/cache/restore + gated actions/cache/save steps for both package managers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build_windows_bin.yml around lines 17 - 20, Gate the
built-in caches of msys2/setup-msys2@v2 and actions/setup-python@v6 using the
existing SAVE_CACHE policy, preventing cache saves on PR and merge_group runs.
Configure both steps with caching disabled or replace them with explicit restore
and conditionally gated save steps, while preserving dependency installation
behavior.

defaults:
run:
# UCRT64 is the MinGW-w64 environment native-windows targets; the `msys`
Expand Down Expand Up @@ -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') }}
Expand All @@ -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/

Expand Down
Loading