@@ -279,42 +279,54 @@ 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
284
- [ -n "${p:-}" ] && [ -d "$p" ] && chown -R 1001:1001 "$p" || true
282
+
283
+ # Paths
284
+ REPO="$GITHUB_WORKSPACE"
285
+ UE_DIR="${UE_ROOT_PATH:-/home/ue4/UnrealEngine}"
286
+ CARGO_HOME="${RUNNER_TOOL_CACHE:-/__t}/cargo"
287
+ RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/__t}/rustup"
288
+
289
+ # 1) Hand ownership to ue4 where it needs to read/write
290
+ for p in "$REPO" "${RUNNER_TEMP:-/__t}" "${RUNNER_TOOL_CACHE:-/__t}"; do
291
+ [ -d "$p" ] && chown -R ue4:ue4 "$p" || true
285
292
done
286
293
287
- # Create the build user if needed
288
- getent group 1001 >/dev/null || groupadd -g 1001 runnergrp
289
- getent passwd 1001 >/dev/null || useradd -u 1001 -g 1001 -m -s /bin/bash runnerusr
294
+ # 2) Ensure UE build script is executable (parents traversable)
295
+ if [ -d "$UE_DIR" ]; then
296
+ chmod a+rx "$UE_DIR" || true
297
+ chmod -R a+X "$UE_DIR/Engine/Build/BatchFiles" || true
298
+ [ -f "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" ] && chmod a+rx "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" || true
299
+ fi
290
300
291
- # Use the runner's tool cache so Rust persists across runs
292
- export CARGO_HOME="${RUNNER_TOOL_CACHE:-/tmp}/cargo"
293
- export RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/tmp}/rustup"
301
+ # 3) Persist Rust under the tool cache owned by ue4
294
302
mkdir -p "$CARGO_HOME" "$RUSTUP_HOME"
295
- chown -R 1001:1001 "$CARGO_HOME" "$RUSTUP_HOME"
296
-
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
- '
303
+ chown -R ue4:ue4 "$CARGO_HOME" "$RUSTUP_HOME"
304
+
305
+ # 4) Run tests as ue4
306
+ sudo -E -H -u ue4 env \
307
+ HOME=/home/ue4 \
308
+ XDG_CONFIG_HOME=/home/ue4/.config \
309
+ CARGO_HOME="$CARGO_HOME" \
310
+ RUSTUP_HOME="$RUSTUP_HOME" \
311
+ PATH="$CARGO_HOME/bin:$PATH" \
312
+ bash -lc '
313
+ set -euxo pipefail
314
+ command -v curl >/dev/null || (sudo apt-get update && sudo apt-get install -y curl ca-certificates)
315
+
316
+ # Install rustup/cargo for ue4 if missing (uses shared caches)
317
+ if ! command -v cargo >/dev/null 2>&1; then
318
+ curl -sSf https://sh.rustup.rs | sh -s -- -y
319
+ fi
320
+ rustup show >/dev/null
321
+
322
+ # Some Git setups are picky about ownership; silence that if it crops up
323
+ git config --global --add safe.directory "$GITHUB_WORKSPACE" || true
324
+
325
+ cd "$GITHUB_WORKSPACE/sdks/unreal"
326
+ cargo --version
327
+ cargo test
328
+ '
329
+
318
330
cli_docs :
319
331
name : Check CLI docs
320
332
permissions : read-all
0 commit comments