@@ -279,42 +279,81 @@ jobs:
279
279
env :
280
280
UE_ROOT_PATH : /home/ue4/UnrealEngine
281
281
run : |
282
- # Ensure these mounts are owned by the user we'll run as
283
- for p in "$GITHUB_WORKSPACE" "$RUNNER_TEMP" "$RUNNER_TOOL_CACHE"; do
282
+
283
+ REPO="$GITHUB_WORKSPACE" # /__w/SpacetimeDB/SpacetimeDB
284
+ PARENT="$(dirname "$REPO")" # /__w/SpacetimeDB
285
+ GRAND="$(dirname "$PARENT")" # /__w
286
+
287
+ # 0) Make repo parents traversable for 1001
288
+ chmod a+rx "$GRAND" "$PARENT" || true
289
+
290
+ # 1) Ensure these mounts are owned by the user we'll run as
291
+ for p in "$REPO" "$RUNNER_TEMP" "$RUNNER_TOOL_CACHE"; do
284
292
[ -n "${p:-}" ] && [ -d "$p" ] && chown -R 1001:1001 "$p" || true
285
293
done
286
294
287
- # Create the build user if needed
295
+ # 2) Make the UE tree readable/executable for UID 1001 (so tests can stat/execute Build.sh)
296
+ apt-get update
297
+ apt-get install -y acl curl ca-certificates
298
+
299
+ UE_DIR="${UE_ROOT_PATH:-/home/ue4/UnrealEngine}"
300
+ if [ -d "$UE_DIR" ]; then
301
+ # allow traversal into /home/ue4 and UE dirs
302
+ setfacl -m u:1001:rx /home/ue4 || chmod o+rx /home/ue4
303
+ setfacl -R -m u:1001:rX "$UE_DIR" || chmod -R a+rX "$UE_DIR"
304
+ # ensure the specific script is executable by all
305
+ if [ -f "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" ]; then
306
+ chmod a+rx "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh"
307
+ fi
308
+ echo "UE perms check:"
309
+ namei -l "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" || true
310
+ else
311
+ echo "WARNING: UE_ROOT_PATH '$UE_DIR' not found"
312
+ fi
313
+
314
+ # 3) Fix the root repo's .git tree (read/traverse) just in case
315
+ if [ -d "$REPO/.git" ]; then
316
+ chown -R 1001:1001 "$REPO/.git" || true
317
+ find "$REPO/.git" -type d -exec chmod 755 {} \; || true
318
+ find "$REPO/.git" -type f -exec chmod 644 {} \; || true
319
+ mkdir -p "$REPO/.git/info"; : > "$REPO/.git/info/exclude"
320
+ chown 1001:1001 "$REPO/.git/info" "$REPO/.git/info/exclude" || true
321
+ chmod 755 "$REPO/.git/info"; chmod 644 "$REPO/.git/info/exclude" || true
322
+ fi
323
+
324
+ # 4) Create the build user if needed
288
325
getent group 1001 >/dev/null || groupadd -g 1001 runnergrp
289
326
getent passwd 1001 >/dev/null || useradd -u 1001 -g 1001 -m -s /bin/bash runnerusr
290
327
291
- # Use the runner's tool cache so Rust persists across runs
328
+ # 5) Persist Rust under the tool cache so it survives runs
292
329
export CARGO_HOME="${RUNNER_TOOL_CACHE:-/tmp}/cargo"
293
330
export RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/tmp}/rustup"
294
331
mkdir -p "$CARGO_HOME" "$RUSTUP_HOME"
295
332
chown -R 1001:1001 "$CARGO_HOME" "$RUSTUP_HOME"
296
333
297
- # Make sure curl exists
298
- apt-get update
299
- apt-get install -y curl ca-certificates
300
-
301
- # Install rustup + toolchain for the 1001 user (rust-toolchain.toml will be honored)
302
- sudo -E -H -u runnerusr bash -lc '
303
- set -euxo pipefail
304
- export CARGO_HOME='"$CARGO_HOME"'
305
- export RUSTUP_HOME='"$RUSTUP_HOME"'
306
- export PATH="$CARGO_HOME/bin:$PATH"
307
- if ! command -v cargo >/dev/null 2>&1; then
308
- curl -sSf https://sh.rustup.rs | sh -s -- -y
309
- fi
310
- # Preload the toolchain requested by rust-toolchain.toml
311
- cd "$GITHUB_WORKSPACE"
312
- export PATH="$CARGO_HOME/bin:$PATH"
313
- rustup show >/dev/null
314
- cd "$GITHUB_WORKSPACE/sdks/unreal"
315
- cargo --version
316
- cargo test
317
- '
334
+ # 6) Run as the unprivileged user with a clean HOME
335
+ sudo -E -H -u runnerusr env \
336
+ HOME=/home/runnerusr \
337
+ XDG_CONFIG_HOME=/home/runnerusr/.config \
338
+ CARGO_HOME="$CARGO_HOME" \
339
+ RUSTUP_HOME="$RUSTUP_HOME" \
340
+ PATH="$CARGO_HOME/bin:$PATH" \
341
+ bash -lc '
342
+ set -euxo pipefail
343
+ mkdir -p "$XDG_CONFIG_HOME"
344
+ if ! command -v cargo >/dev/null 2>&1; then
345
+ curl -sSf https://sh.rustup.rs | sh -s -- -y
346
+ fi
347
+ rustup show >/dev/null
348
+ git config --global --add safe.directory "$GITHUB_WORKSPACE" || true
349
+
350
+ # final sanity on the UE script as UID 1001
351
+ ls -l "$UE_ROOT_PATH/Engine/Build/BatchFiles/Linux/Build.sh" || true
352
+
353
+ cd "$GITHUB_WORKSPACE/sdks/unreal"
354
+ cargo --version
355
+ cargo test
356
+ '
318
357
cli_docs :
319
358
name : Check CLI docs
320
359
permissions : read-all
0 commit comments