[build] surface failures from archive rules#17594
Conversation
Review Summary by QodoSurface failures from macOS archive rules with improved error handling
WalkthroughsDescription• Add error handling to macOS archive rules with proper failure reporting • Replace shared /tmp/firefox.zip with repository-local scratch file • Add cleanup trap and validation to convert_dmg.sh script • Delete intermediate artifacts after extraction to reduce cache size Diagramflowchart LR
A["Archive Rules<br/>dmg_archive.bzl<br/>pkg_archive.bzl"] -->|"Add _execute_or_fail<br/>helper"| B["Error Handling<br/>Check return codes<br/>Report stdout/stderr"]
A -->|"Delete intermediates<br/>after extract"| C["Cleanup<br/>Remove .dmg, .zip<br/>Remove .pkg files"]
D["convert_dmg.sh"] -->|"Add set -euo pipefail<br/>Local scratch file"| E["Robustness<br/>Validate mount point<br/>Cleanup on exit"]
D -->|"Replace /tmp/firefox.zip<br/>with repo-local path"| F["Concurrency<br/>Avoid race conditions<br/>between fetches"]
File Changes1. common/private/dmg_archive.bzl
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Pull request overview
This PR improves diagnosability and cleanup behavior for macOS-focused Bazel repository rules (dmg_archive, pkg_archive) by surfacing underlying command failures (with stdout/stderr) instead of later failing with a generic “archive path does not exist” message.
Changes:
- Add an
_execute_or_failhelper todmg_archive.bzlandpkg_archive.bzlto checkrepository_ctx.execute()return codes andfail()with captured output on errors. - Harden
convert_dmg.shwithset -euo pipefail, robust cleanup viatrap, and a per-invocation scratch zip path to avoid/tmpraces. - Delete large intermediate artifacts after extraction (
.dmg, converted.zip,.pkg.download, expanded.pkg/tree) to reduce cached repository size.
Note: after these changes, run ./go format to avoid CI failures from formatter checks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| common/private/pkg_archive.bzl | Check pkgutil/mv execution results and delete .pkg intermediates after moving payload files. |
| common/private/dmg_archive.bzl | Check DMG conversion execution results and delete .dmg/.zip intermediates after extraction. |
| common/private/convert_dmg.sh | Make DMG attach/zip/detach more reliable with strict mode, cleanup trap, and non-/tmp scratch output. |
|
Code review by qodo was updated up to the latest commit d3f051d |
Ran into an issue where the build failed but the error message wasn't helpful, this digs into it.
💥 What does this PR do?
Makes the macOS browser-fetch repository rules (
dmg_archive,pkg_archive) andconvert_dmg.shreport real failures.repository_ctx.execute()return codes are now checked; failures callfail()with the captured stdout/stderr. Previously a failingconvert_dmg.shorpkgutil --expand-fullsurfaced three steps downstream as the crypticArchive path … does not exist.convert_dmg.shruns withset -euo pipefail, validates thathdiutil attachproduced a mount point, and uses atrapto detach the volume and remove its scratch file on every exit path./tmp/firefox.zip(which raced between concurrentmac_firefox/mac_beta_firefoxfetches and could pick up stale state) into the repo's working directory..dmg, converted.zip,.pkg.download, expanded.pkg/tree) are deleted after extract — matching whatdeb_archive.bzlalready does and avoiding ~hundreds of MB of dead weight per cached snapshot.🔧 Implementation Notes
_execute_or_failhelper in bothdmg_archive.bzlandpkg_archive.bzlrather than extract to a separate file.deb_archive.bzlis unchanged — it was already correct (usesdownload_and_extract+repository_ctx.deleteand never shells out).🤖 AI assistance
🔄 Types of changes