Skip to content

Commit 33c6f0a

Browse files
committed
chore(sccache): add debugging for CI permission and cache errors
1 parent 3fccc41 commit 33c6f0a

File tree

3 files changed

+67
-16
lines changed

3 files changed

+67
-16
lines changed

.github/actions/nix-install-ephemeral/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ runs:
5454
${{ inputs.push-to-cache == 'true' && 'post-build-hook = /etc/nix/upload-to-cache.sh' || '' }}
5555
${{ inputs.enable-sccache-sandbox-path == 'true' && 'extra-sandbox-paths = /nix/var/cache/sccache?' || '' }}
5656
max-jobs = 4
57+
auto-allocate-uids = true
58+
use-cgroups = true
59+
experimental-features = nix-command flakes cgroups auto-allocate-uids

.github/workflows/nix-build.yml

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ jobs:
5757
- name: Allow sccache cache write access
5858
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
5959
run: |
60-
sudo chgrp nixbld /nix/var/cache/sccache
61-
sudo chmod 777 /nix/var/cache/sccache
62-
sudo chmod g+s /nix/var/cache/sccache
63-
sudo setfacl -d -m u::rwX,g::rwX,o::rwX /nix/var/cache/sccache
60+
# With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
61+
sudo chown -R 872415232 /nix/var/cache/sccache
62+
sudo chmod -R 2777 /nix/var/cache/sccache
63+
echo "=== sccache debug: outside sandbox ==="
64+
echo "Current user: $(id)"
65+
echo "Cache dir ownership:"
66+
ls -lan /nix/var/cache/sccache | head -10
67+
echo "Sample cache files (numeric):"
68+
find /nix/var/cache/sccache -type f 2>/dev/null | head -3 | xargs ls -lan 2>/dev/null || echo "No cache files"
69+
echo "=== end outside sandbox debug ==="
6470
- name: nix build
6571
if: ${{ matrix.attr != '' }}
6672
shell: bash
@@ -102,10 +108,16 @@ jobs:
102108
- name: Allow sccache cache write access
103109
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
104110
run: |
105-
sudo chgrp nixbld /nix/var/cache/sccache
106-
sudo chmod 777 /nix/var/cache/sccache
107-
sudo chmod g+s /nix/var/cache/sccache
108-
sudo setfacl -d -m u::rwX,g::rwX,o::rwX /nix/var/cache/sccache
111+
# With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
112+
sudo chown -R 872415232 /nix/var/cache/sccache
113+
sudo chmod -R 2777 /nix/var/cache/sccache
114+
echo "=== sccache debug: outside sandbox ==="
115+
echo "Current user: $(id)"
116+
echo "Cache dir ownership:"
117+
ls -lan /nix/var/cache/sccache | head -10
118+
echo "Sample cache files (numeric):"
119+
find /nix/var/cache/sccache -type f 2>/dev/null | head -3 | xargs ls -lan 2>/dev/null || echo "No cache files"
120+
echo "=== end outside sandbox debug ==="
109121
- name: nix build
110122
if: ${{ matrix.attr != '' }}
111123
shell: bash
@@ -190,10 +202,16 @@ jobs:
190202
- name: Allow sccache cache write access
191203
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
192204
run: |
193-
sudo chgrp nixbld /nix/var/cache/sccache
194-
sudo chmod 777 /nix/var/cache/sccache
195-
sudo chmod g+s /nix/var/cache/sccache
196-
sudo setfacl -d -m u::rwX,g::rwX,o::rwX /nix/var/cache/sccache
205+
# With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
206+
sudo chown -R 872415232 /nix/var/cache/sccache
207+
sudo chmod -R 2777 /nix/var/cache/sccache
208+
echo "=== sccache debug: outside sandbox ==="
209+
echo "Current user: $(id)"
210+
echo "Cache dir ownership:"
211+
ls -lan /nix/var/cache/sccache | head -10
212+
echo "Sample cache files (numeric):"
213+
find /nix/var/cache/sccache -type f 2>/dev/null | head -3 | xargs ls -lan 2>/dev/null || echo "No cache files"
214+
echo "=== end outside sandbox debug ==="
197215
- name: nix build
198216
if: ${{ matrix.attr != '' }}
199217
shell: bash
@@ -232,10 +250,16 @@ jobs:
232250
- name: Allow sccache cache write access
233251
if: ${{ matrix.attr != '' && matrix.runs_on.group != 'self-hosted-runners-nix' }}
234252
run: |
235-
sudo chgrp nixbld /nix/var/cache/sccache
236-
sudo chmod 777 /nix/var/cache/sccache
237-
sudo chmod g+s /nix/var/cache/sccache
238-
sudo setfacl -d -m u::rwX,g::rwX,o::rwX /nix/var/cache/sccache
253+
# With auto-allocate-uids, UID 872415232 (0x34000000) maps to nixbld inside sandbox
254+
sudo chown -R 872415232 /nix/var/cache/sccache
255+
sudo chmod -R 2777 /nix/var/cache/sccache
256+
echo "=== sccache debug: outside sandbox ==="
257+
echo "Current user: $(id)"
258+
echo "Cache dir ownership:"
259+
ls -lan /nix/var/cache/sccache | head -10
260+
echo "Sample cache files (numeric):"
261+
find /nix/var/cache/sccache -type f 2>/dev/null | head -3 | xargs ls -lan 2>/dev/null || echo "No cache files"
262+
echo "=== end outside sandbox debug ==="
239263
- name: nix build
240264
if: ${{ matrix.attr != '' }}
241265
shell: bash

nix/cargo-pgrx/buildPgrxExtension.nix

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,31 @@ let
148148
export RUSTC_WRAPPER="${sccache}/bin/sccache"
149149
export SCCACHE_DIR="/nix/var/cache/sccache"
150150
export SCCACHE_CACHE_SIZE="500G"
151+
export SCCACHE_LOG=debug
152+
export SCCACHE_ERROR_LOG=/tmp/sccache-error.log
153+
154+
echo "=== sccache debug: build user ==="
155+
id
156+
echo "=== sccache debug: uid_map (inside outside count) ==="
157+
cat /proc/self/uid_map || echo "No uid_map"
158+
cat /proc/self/gid_map || echo "No gid_map"
159+
echo "=== sccache debug: cache dir from sandbox ==="
160+
ls -la /nix/var/cache/sccache | head -10
161+
echo "=== sccache debug: sample cache files ==="
162+
find /nix/var/cache/sccache -type f 2>/dev/null | head -3 | xargs ls -la 2>/dev/null || echo "No cache files"
163+
echo "=== sccache debug: test file creation ==="
164+
touch /nix/var/cache/sccache/test-$$
165+
ls -la /nix/var/cache/sccache/test-$$
166+
rm -f /nix/var/cache/sccache/test-$$
167+
echo "=== end sccache debug ==="
151168
else
152169
echo "sccache: cache directory not available, skipping"
153170
fi
154171
155172
173+
174+
175+
156176
echo "Executing cargo-pgrx buildPhase"
157177
${preBuildAndTest}
158178
${maybeEnterBuildAndTestSubdir}
@@ -169,6 +189,10 @@ let
169189
if [[ -n "''${RUSTC_WRAPPER:-}" ]]; then
170190
echo "sccache stats:"
171191
${sccache}/bin/sccache --show-stats
192+
if [[ -f /tmp/sccache-error.log ]]; then
193+
echo "sccache error log (last 500 lines):"
194+
tail -500 /tmp/sccache-error.log || true
195+
fi
172196
fi
173197
174198
${maybeLeaveBuildAndTestSubdir}

0 commit comments

Comments
 (0)