Skip to content

Save/Restore seperately in MacOS/Windows caching workflows. - #11199

Merged
vidplace7 merged 1 commit into
developfrom
cache-harder
Jul 24, 2026
Merged

Save/Restore seperately in MacOS/Windows caching workflows.#11199
vidplace7 merged 1 commit into
developfrom
cache-harder

Conversation

@vidplace7

@vidplace7 vidplace7 commented Jul 24, 2026

Copy link
Copy Markdown
Member

Only save cache on the default branch (develop), restore it everywhere it fits

Summary by CodeRabbit

  • Build & Reliability
    • Improved macOS and Windows build caching to reuse existing caches while avoiding unnecessary cache writes during pull request builds.
    • Updated the WebAssembly build environment to use a pinned Emscripten SDK setup version for more consistent builds.

Only *save* cache on the default branch (develop), restore it everywhere it fits
@vidplace7 vidplace7 added the github_actions Pull requests that update GitHub Actions code label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updates macOS and Windows CI cache handling to separate restore and save operations, restricts cache writes to default-branch pushes, and pins the Emscripten setup action used by the PortDuino WASM build.

Changes

CI workflow maintenance

Layer / File(s) Summary
Conditional cache restore and save flow
.github/workflows/build_macos_bin.yml, .github/workflows/build_windows_bin.yml
Homebrew and PlatformIO caches use separate restore and save steps, with saves restricted to default-branch pushes and cache misses.
Pinned Emscripten setup action
.github/workflows/build_portduino_wasm.yml
The Emscripten SDK setup action is changed from v16 to a pinned commit reference annotated as v17.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: github_actions

Suggested reviewers: thebentern

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is too sparse and does not follow the repository template or include the required attestations/testing details. Replace it with the template sections, especially the attestations checkboxes, testing notes, and any affected-device regression details.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: separating cache save and restore behavior in macOS/Windows workflows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cache-harder

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Note

Building this pull request… the flash button, badges and supported-board
list will appear here automatically once CI finishes.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with 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.

Inline comments:
In @.github/workflows/build_windows_bin.yml:
- Around line 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.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 63414347-1cb8-4517-8bc5-7a4bcfbfc6d3

📥 Commits

Reviewing files that changed from the base of the PR and between 88e287f and 838f701.

📒 Files selected for processing (3)
  • .github/workflows/build_macos_bin.yml
  • .github/workflows/build_portduino_wasm.yml
  • .github/workflows/build_windows_bin.yml

Comment on lines +17 to +20
# 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 }}

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.

@vidplace7
vidplace7 merged commit e50572b into develop Jul 24, 2026
19 of 97 checks passed
@vidplace7
vidplace7 deleted the cache-harder branch July 24, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant