@@ -103,9 +103,10 @@ jobs:
103103 run : |
104104 sudo mkdir /stdb
105105 sudo chmod 777 /stdb
106-
106+
107107 - name : Run cargo test
108- run : cargo test --all
108+ # Note: Unreal tests will be run separately
109+ run : cargo test --all -- --skip unreal
109110
110111 - name : Check that the test outputs are up-to-date
111112 run : bash tools/check-diff.sh
@@ -243,6 +244,90 @@ jobs:
243244 cargo run --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update -- self-install --root-dir="${ROOT_DIR}" --yes
244245 "${ROOT_DIR}"/spacetime --root-dir="${ROOT_DIR}" help
245246
247+ unreal_engine_tests :
248+ name : Unreal Engine Tests
249+ # This can't go on e.g. ubuntu-latest because that runner runs out of disk space. ChatGPT suggested that the general solution tends to be to use
250+ # a custom runner.
251+ runs-on : spacetimedb-runner
252+ container :
253+ image : ghcr.io/epicgames/unreal-engine:dev-5.6
254+ credentials :
255+ # Note(bfops): I don't think that `github.actor` needs to match the user that the token is for, because I'm using a token for my account and
256+ # it seems to be totally happy.
257+ # However, the token needs to be for a user that has access to the EpicGames org (see
258+ # https://dev.epicgames.com/documentation/en-us/unreal-engine/downloading-source-code-in-unreal-engine?application_version=5.6)
259+ username : ${{ github.actor }}
260+ password : ${{ secrets.GHCR_TOKEN }}
261+ # Run as root because otherwise we get permission denied for various directories inside the container. I tried doing dances to allow it to run
262+ # without this (reassigning env vars and stuff), but was unable to get it to work and it felt like an uphill battle.
263+ options : --user 0:0
264+ steps :
265+ # Uncomment this before merging so that it will run properly if run manually through the GH actions flow. It was playing weird with rolled back
266+ # commits though.
267+ # - name: Find Git ref
268+ # env:
269+ # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
270+ # shell: bash
271+ # run: |
272+ # PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
273+ # if test -n "${PR_NUMBER}"; then
274+ # GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
275+ # else
276+ # GIT_REF="${{ github.ref }}"
277+ # fi
278+ # echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
279+ - name : Checkout sources
280+ uses : actions/checkout@v4
281+ with :
282+ ref : ${{ env.GIT_REF }}
283+ - uses : dsherret/rust-toolchain-file@v1
284+ - name : Run Unreal Engine tests
285+ working-directory : sdks/unreal
286+ env :
287+ UE_ROOT_PATH : /home/ue4/UnrealEngine
288+ run : |
289+
290+ apt-get update
291+ apt-get install -y acl curl ca-certificates
292+
293+ REPO="$GITHUB_WORKSPACE"
294+ # Let ue4 read/write the workspace & tool caches without changing ownership
295+ for p in "$REPO" "${RUNNER_TEMP:-/__t}" "${RUNNER_TOOL_CACHE:-/__t}"; do
296+ [ -d "$p" ] && setfacl -R -m u:ue4:rwX -m d:u:ue4:rwX "$p" || true
297+ done
298+
299+ # Rust tool caches live under the runner tool cache so they persist
300+ export CARGO_HOME="${RUNNER_TOOL_CACHE:-/__t}/cargo"
301+ export RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/__t}/rustup"
302+ mkdir -p "$CARGO_HOME" "$RUSTUP_HOME"
303+ chown -R ue4:ue4 "$CARGO_HOME" "$RUSTUP_HOME"
304+
305+ # Make sure the UE build script is executable (and parents traversable)
306+ UE_DIR="${UE_ROOT_PATH:-/home/ue4/UnrealEngine}"
307+ chmod a+rx "$UE_DIR" "$UE_DIR/Engine" "$UE_DIR/Engine/Build" "$UE_DIR/Engine/Build/BatchFiles/Linux" || true
308+ chmod a+rx "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" || true
309+
310+ # Run the build & tests as ue4 (who owns the UE tree)
311+ sudo -E -H -u ue4 env \
312+ HOME=/home/ue4 \
313+ XDG_CONFIG_HOME=/home/ue4/.config \
314+ CARGO_HOME="$CARGO_HOME" \
315+ RUSTUP_HOME="$RUSTUP_HOME" \
316+ PATH="$CARGO_HOME/bin:$PATH" \
317+ bash -lc '
318+ set -euxo pipefail
319+ # Install rustup for ue4 if needed (uses the shared caches)
320+ if ! command -v cargo >/dev/null 2>&1; then
321+ curl -sSf https://sh.rustup.rs | sh -s -- -y
322+ fi
323+ rustup show >/dev/null
324+ git config --global --add safe.directory "$GITHUB_WORKSPACE" || true
325+
326+ cd "$GITHUB_WORKSPACE/sdks/unreal"
327+ cargo --version
328+ cargo test
329+ '
330+
246331 cli_docs :
247332 name : Check CLI docs
248333 permissions : read-all
@@ -277,7 +362,6 @@ jobs:
277362
278363 - name : Get pnpm store directory
279364 shell : bash
280- working-directory : sdks/typescript
281365 run : |
282366 echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
283367
0 commit comments