Skip to content

Commit fdc0405

Browse files
therealalephclaude
andcommitted
ci(release): heal root-owned target/ + always-chown after mipsel docker
Two related fixes for the self-hosted Linux jobs failing on `actions/checkout@v4` with `EACCES: permission denied unlink target/.rustc_info.json`: 1. Pre-checkout cleanup. The previous mipsel docker step left root- owned files in target/ when its `cargo +nightly build` failed — the post-step `sudo chown -R …` line was AFTER the docker run, and bash -e short-circuited on docker non-zero, so chown never executed. Once those root-owned files exist on the runner, every subsequent self-hosted job's `actions/checkout@v4` clean step fails because it can't unlink them. Add a guarded pre-checkout step that uses `sudo rm -rf` to clear root-owned leftovers from $GITHUB_WORKSPACE. Gated on `contains(matrix.os, 'self-hosted')` so GitHub-hosted runners (macOS, Windows) skip it — they get fresh VMs anyway. 2. Always-chown trap. The mipsel docker step now uses `trap '…chown…' EXIT` so the chown runs whether the inner `cargo build` succeeded or failed. A transient mipsel compile regression (tier-3 target, occasional std-build breakage) no longer poisons the runner's workspace for the next run. Together: (1) recovers from the existing broken state on next run, (2) prevents the same poisoned state from recurring. Triggered for the v1.4.0 redeploy that's trying to publish the missing mhrv-rs-openwrt-mipsel-softfloat artifact. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dc74a3f commit fdc0405

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ jobs:
9696
continue-on-error: ${{ matrix.mipsel_softfloat == true }}
9797

9898
steps:
99+
# Heal any root-owned leftovers from a previous mipsel docker
100+
# build that failed before its post-step chown could run. The
101+
# docker container writes target/ as root, and if cargo errors
102+
# inside the container the outer `sudo chown -R` line never
103+
# executes (bash -e exits on the docker non-zero), leaving root-
104+
# owned files that fail every subsequent `actions/checkout@v4`
105+
# workspace clean with `EACCES: permission denied unlink`. This
106+
# step is a no-op on a clean runner, so cheap to keep always-on.
107+
# Self-hosted only; GitHub-hosted runners get a fresh VM each run.
108+
- name: Pre-checkout — clean root-owned files (self-hosted only)
109+
if: contains(matrix.os, 'self-hosted')
110+
run: |
111+
if [ -d "$GITHUB_WORKSPACE/target" ]; then
112+
sudo rm -rf "$GITHUB_WORKSPACE/target" || true
113+
fi
114+
# Stale .rustc_info.json at the workspace root is the
115+
# specific file `actions/checkout` errors on; nuke any
116+
# other root-owned scraps that may be sitting there too.
117+
sudo find "$GITHUB_WORKSPACE" -maxdepth 2 -uid 0 -exec rm -rf {} + 2>/dev/null || true
118+
99119
- uses: actions/checkout@v4
100120

101121
# Skip the host-level rustup install for mipsel-softfloat — that
@@ -234,6 +254,16 @@ jobs:
234254
# silently at the post-docker chown. Heredoc-style single
235255
# quotes preserve newlines verbatim; no comment collapse.
236256
run: |
257+
# Always chown back, even if docker exits non-zero. The previous
258+
# form (`docker run …; sudo chown …`) ran chown only on success
259+
# because bash -e short-circuits on the docker failure; that
260+
# left target/ root-owned and broke `actions/checkout@v4` on
261+
# every subsequent self-hosted run with EACCES on
262+
# target/.rustc_info.json. The `trap … EXIT` runs the chown
263+
# whether docker succeeded or failed, so a transient mipsel
264+
# compile regression never poisons the runner workspace.
265+
set +e
266+
trap 'sudo chown -R "$(id -u):$(id -g)" target 2>/dev/null || true' EXIT
237267
docker run --rm -v "$PWD":/src -w /src \
238268
-e RUSTFLAGS='-C target-feature=+soft-float' \
239269
messense/rust-musl-cross:mipsel-musl \
@@ -252,7 +282,11 @@ jobs:
252282
--target mipsel-unknown-linux-musl \
253283
--bin mhrv-rs
254284
'
255-
sudo chown -R "$(id -u):$(id -g)" target
285+
rc=$?
286+
# `trap … EXIT` will fire the chown on shell exit — the explicit
287+
# exit here just propagates the docker exit code as the step
288+
# status (success vs continue-on-error path).
289+
exit $rc
256290
257291
# UI build: we try to build the UI binary on every platform. If it fails
258292
# on cross-compile for linux-arm64 (missing arm64 system libs cross),

0 commit comments

Comments
 (0)