Skip to content

Commit 18e0471

Browse files
tannevaledclaude
andcommitted
ci: check directories, not files, under \$HOME/.pkgx
The diagnostic ::warning:: annotations from ea4dab6 confirmed the install actually works: hyperfine landed under /home/runner/.pkgx/crates.io/hyperfine/v1.20.0/ with the privilege drop and HOME override both firing as intended (no "is not reachable as <user>" diagnostic on pkgm's stderr, only deno download lines). The remaining failure was the assertion itself: `find -type f -newer marker` returns empty because tar -x preserves the archive's original mtimes on extracted files, so the binary's mtime predates the marker. Only the directories pkgx mkdirs during extraction have a current mtime. Switch the positive check to `-type d` and drop the diagnostic warnings now that the failure mode is identified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ea4dab6 commit 18e0471

1 file changed

Lines changed: 16 additions & 29 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -123,48 +123,35 @@ jobs:
123123

124124
- name: sudo install drops privileges and overrides HOME
125125
run: |
126-
set -ux
127-
# marker to scope checks to files created by this install
126+
set -eux
127+
# marker to scope checks to entries created by this install
128128
touch /tmp/pkgm-sudo-marker
129-
# Run pkgm with PKGM_DEBUG so the "is not reachable as $USER"
130-
# diagnostic surfaces when pkgx_reachable_as falls through; we
131-
# tee stderr so the diagnostic is visible in the job log as well
132-
# as captured for the warning emission below.
133-
sudo PKGM_DEBUG=1 ./pkgm.ts i hyperfine 2> >(tee /tmp/pkgm-sudo.stderr >&2)
134-
rc=$?
135-
set -e
136-
test $rc -eq 0
129+
sudo ./pkgm.ts i hyperfine
137130
test -x /usr/local/bin/hyperfine
138131
139-
# Surface enough state as ::warning:: annotations to diagnose
140-
# which branch query_pkgx() took. Failure cases:
141-
# - "pkgx_reachable_as returned undefined" → privilege drop
142-
# skipped → pkgx runs as root with HOME=/root → cache lands
143-
# under /root/.pkgx, none under $HOME/.pkgx.
144-
# - "user_home() failed" → reachable_as falls through to its
145-
# /home/<user>/ rejection regex.
146-
echo "::warning::diag pkgx-via-sudo: $(sudo command -v pkgx 2>&1 || echo none)"
147-
echo "::warning::diag root-new-files: $(sudo find /root/.pkgx -newer /tmp/pkgm-sudo-marker -print 2>/dev/null | head -8 | tr '\n' '|' || echo none)"
148-
echo "::warning::diag user-new-files: $(sudo find $HOME/.pkgx -newer /tmp/pkgm-sudo-marker -print 2>/dev/null | head -8 | tr '\n' '|' || echo none)"
149-
echo "::warning::diag pkgm-stderr: $(tr '\n' '|' < /tmp/pkgm-sudo.stderr | head -c 500 || echo none)"
150-
151-
# HOME override + privilege drop are both validated via the pkg
152-
# cache under $HOME/.pkgx. We deliberately do NOT assert that
132+
# HOME override + privilege drop are validated via the pkg cache
133+
# under $HOME/.pkgx. We deliberately do NOT assert that
153134
# /root/.pkgx is empty: the shebang's `pkgx --quiet deno^2.1 run …`
154135
# runs as root before any pkgm.ts code executes, and that outer
155136
# pkgx caches under $HOME/.pkgx which resolves to /root/.pkgx
156137
# under sudo. That cache is unavoidable and unrelated to whether
157138
# pkgm's *inner* pkgx call dropped privileges.
158-
159-
new_files=$(sudo find "$HOME/.pkgx" -newer /tmp/pkgm-sudo-marker -type f -print 2>/dev/null | head -1 || true)
160-
if [ -z "$new_files" ]; then
161-
echo "::error::no new files under \$HOME/.pkgx — inner pkgx did not cache to invoking user's tree"
139+
#
140+
# We check for newly created entries (directories specifically),
141+
# not files: tar -x preserves the archive's original mtimes on
142+
# extracted files, so file mtimes are typically *older* than the
143+
# marker. Directories are created fresh by `mkdir` during
144+
# extraction and reliably have a current mtime.
145+
146+
new_dirs=$(sudo find "$HOME/.pkgx" -newer /tmp/pkgm-sudo-marker -type d -print 2>/dev/null | head -1 || true)
147+
if [ -z "$new_dirs" ]; then
148+
echo "::error::no new directories under \$HOME/.pkgx — inner pkgx did not cache to invoking user's tree"
162149
exit 1
163150
fi
164151
165152
owned_by_root=$(sudo find "$HOME/.pkgx" -newer /tmp/pkgm-sudo-marker -user root -print 2>/dev/null || true)
166153
if [ -n "$owned_by_root" ]; then
167-
echo "::error::pkgx cache files created as root under \$HOME/.pkgx — privilege drop failed:"
154+
echo "::error::pkgx cache entries created as root under \$HOME/.pkgx — privilege drop failed:"
168155
echo "$owned_by_root"
169156
exit 1
170157
fi

0 commit comments

Comments
 (0)