ci: install Protoc for Linux, macOS, and Windows#13555
Conversation
Added installation steps for Protoc based on the OS. Signed-off-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📝 WalkthroughWalkthroughAdded Protobuf compiler installation to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/build-packages.yml:
- Around line 757-758: The workflow step named "Install Protoc" contains
trailing whitespace at the end of the run line; remove the trailing spaces after
"protobuf-compiler" in the run command so the line reads without any trailing
whitespace (update the run value in the Install Protoc step).
- Around line 577-587: In the "Install Protoc (Native)" GitHub Actions step the
hardcoded Windows path echo (the line echo "C:\Program Files\Protobuf\bin" >>
$GITHUB_PATH) is incorrect and redundant; remove that echo line from the step so
winget can manage PATH automatically, or alternatively replace the whole step
with a cross-platform setup action (e.g., arduino/setup-protoc) to ensure
reliable protoc installation across OSes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8b2009e8-1e39-4a19-9fe1-c19223de470b
📒 Files selected for processing (1)
.github/workflows/build-packages.yml
Remove redundant echo command for Protobuf path on Windows. Signed-off-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com>
failed per rabbit suggestions Signed-off-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/build-packages.yml (1)
584-586:⚠️ Potential issue | 🟠 MajorRemove the guessed Windows
protocpath.Line 586 hardcodes
C:\Program Files\Protobuf\bin, butGoogle.Protobufis published to winget as a ZIP/portable install whose nested binary isbin/protoc.exeand whose binaries depend on PATH. WinGet’s portable roots are under its...WinGet\Links/...WinGet\Packagesdirectories, and PATH propagation for portable installs has had edge cases, so this guessed directory can still leaveprotocunresolved in the next step. Please resolve the actual WinGet links directory or the installedprotoc.exeparent before appending to$GITHUB_PATH. (raw.githubusercontent.com)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/build-packages.yml around lines 584 - 586, The hardcoded path "C:\Program Files\Protobuf\bin" is unreliable after running winget install Google.Protobuf; instead, locate the actual installed protoc.exe and append its parent directory to $GITHUB_PATH: after the winget step, search the WinGet links/packages locations (or run a discovery like searching for protoc.exe in $env:ProgramData\Microsoft\Windows\Start Menu\Programs, the WinGet Links folder, or via where/proc-finding command) and then echo the discovered parent directory into $GITHUB_PATH (use the discovered path variable rather than the guessed literal). Ensure you reference the installed Google.Protobuf package and protoc.exe when implementing the discovery so PATH propagation is robust across portable WinGet installs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.github/workflows/build-packages.yml:
- Around line 584-586: The hardcoded path "C:\Program Files\Protobuf\bin" is
unreliable after running winget install Google.Protobuf; instead, locate the
actual installed protoc.exe and append its parent directory to $GITHUB_PATH:
after the winget step, search the WinGet links/packages locations (or run a
discovery like searching for protoc.exe in
$env:ProgramData\Microsoft\Windows\Start Menu\Programs, the WinGet Links folder,
or via where/proc-finding command) and then echo the discovered parent directory
into $GITHUB_PATH (use the discovered path variable rather than the guessed
literal). Ensure you reference the installed Google.Protobuf package and
protoc.exe when implementing the discovery so PATH propagation is robust across
portable WinGet installs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e837ec03-3995-4db7-bdf5-e597795f07bd
📒 Files selected for processing (1)
.github/workflows/build-packages.yml
Update Protobuf installation for Windows to find protoc.exe dynamically and set environment variables accordingly. Signed-off-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/build-packages.yml (1)
586-590:⚠️ Potential issue | 🟠 MajorRemove the invalid Windows fallback path.
Line 588 falls back to
/c/Program Files/Protobuf/bin/protoc.exe, but the documented default WinGet portable roots are%LOCALAPPDATA%/Microsoft/WinGet/Packages/and%PROGRAMFILES%/WinGet/Packages/. If the search on Line 586 misses, this branch exports a path WinGet does not document and the job fails later incargo buildinstead of here. Prefer failing immediately over keeping this fallback. (learn.microsoft.com)🛠️ Proposed fix
elif [ "$RUNNER_OS" == "Windows" ]; then winget install --id=Google.Protobuf -e --accept-package-agreements --accept-source-agreements PROTOC_PATH=$(find /c/Users/runneradmin/AppData/Local/Microsoft/WinGet/Packages -name protoc.exe | head -n 1) - if [ -z "$PROTOC_PATH" ]; then - PROTOC_PATH="/c/Program Files/Protobuf/bin/protoc.exe" - fi + if [ -z "$PROTOC_PATH" ] || [ ! -f "$PROTOC_PATH" ]; then + echo "protoc.exe not found after winget install" >&2 + exit 1 + fi echo "PROTOC=$PROTOC_PATH" >> $GITHUB_ENV echo "$(dirname "$PROTOC_PATH")" >> $GITHUB_PATH🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/build-packages.yml around lines 586 - 590, The fallback assignment that sets PROTOC_PATH to "/c/Program Files/Protobuf/bin/protoc.exe" is invalid and should be removed; instead, after running the find that sets PROTOC_PATH, detect if PROTOC_PATH is empty and fail early (print a clear error to stderr and exit non‑zero) rather than exporting a bogus path to $GITHUB_ENV. Update the logic around the PROTOC_PATH variable and the echo "PROTOC=$PROTOC_PATH" >> $GITHUB_ENV so the job aborts immediately with an explanatory error if the find command yields no result (reference: the PROTOC_PATH variable, the find invocation and the $GITHUB_ENV export).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.github/workflows/build-packages.yml:
- Around line 586-590: The fallback assignment that sets PROTOC_PATH to
"/c/Program Files/Protobuf/bin/protoc.exe" is invalid and should be removed;
instead, after running the find that sets PROTOC_PATH, detect if PROTOC_PATH is
empty and fail early (print a clear error to stderr and exit non‑zero) rather
than exporting a bogus path to $GITHUB_ENV. Update the logic around the
PROTOC_PATH variable and the echo "PROTOC=$PROTOC_PATH" >> $GITHUB_ENV so the
job aborts immediately with an explanatory error if the find command yields no
result (reference: the PROTOC_PATH variable, the find invocation and the
$GITHUB_ENV export).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: fae282f6-560f-4bc9-b675-0471eaafc02d
📒 Files selected for processing (1)
.github/workflows/build-packages.yml
Added installation steps for Protoc based on the OS.
Prepare
Description
Target issue
closes #13550
Implementation Details
Test and Document the changes
Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with
docs:to indicate documentation changes or if the below checklist is not selected.Summary by CodeRabbit