Skip to content
Draft
128 changes: 92 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
include:
- { runner: spacetimedb-runner, smoketest_args: --docker }
- { runner: windows-latest, smoketest_args: --no-build-cli }
runner: [ spacetimedb-runner, windows-latest ]
runner: [spacetimedb-runner, windows-latest]
runs-on: ${{ matrix.runner }}
steps:
- name: Find Git ref
Expand All @@ -44,10 +44,6 @@ jobs:
- uses: actions/setup-dotnet@v4
with:
global-json-file: modules/global.json
- name: Install psql (Windows)
if: runner.os == 'Windows'
run: choco install psql -y --no-progress
shell: powershell
- name: Build and start database (Linux)
if: runner.os == 'Linux'
run: docker compose up -d
Expand All @@ -58,13 +54,11 @@ jobs:
Start-Process target/debug/spacetimedb-cli.exe start
cd modules
# the sdk-manifests on windows-latest are messed up, so we need to update them
dotnet workload config --update-mode manifests
dotnet workload config --update-mode workload-set
dotnet workload update
- uses: actions/setup-python@v5
with: { python-version: '3.12' }
if: runner.os == 'Windows'
- name: Install psycopg2
run: python -m pip install psycopg2-binary
- name: Run smoketests
# Note: clear_database and replication only work in private
run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication
Expand Down Expand Up @@ -243,6 +237,91 @@ jobs:
cargo run --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update -- self-install --root-dir="${ROOT_DIR}" --yes
"${ROOT_DIR}"/spacetime --root-dir="${ROOT_DIR}" help

unreal_engine_tests:
name: Unreal Engine Tests
# 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
# a custom runner.
runs-on: spacetimedb-runner
container:
image: ghcr.io/epicgames/unreal-engine:dev-5.6
credentials:
# 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
# it seems to be totally happy.
# However, the token needs to be for a user that has access to the EpicGames org (see
# https://dev.epicgames.com/documentation/en-us/unreal-engine/downloading-source-code-in-unreal-engine?application_version=5.6)
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
# Run as root because otherwise we get permission denied for various directories inside the container. I tried doing dances to allow it to run
# without this (reassigning env vars and stuff), but was unable to get it to work and it felt like an uphill battle.
options: --user 0:0
steps:
# 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
# commits though.
# - name: Find Git ref
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# shell: bash
# run: |
# PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
# if test -n "${PR_NUMBER}"; then
# GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
# else
# GIT_REF="${{ github.ref }}"
# fi
# echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- uses: dsherret/rust-toolchain-file@v1
- name: Run Unreal Engine tests
working-directory: sdks/unreal
env:
UE_ROOT_PATH: /home/ue4/UnrealEngine
run: |

REPO="$GITHUB_WORKSPACE"
UE_DIR="${UE_ROOT_PATH:-/home/ue4/UnrealEngine}"
CARGO_HOME="${RUNNER_TOOL_CACHE:-/__t}/cargo"
RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/__t}/rustup"

# 1) Only chown what ue4 must write to (not RUNNER_TEMP)
mkdir -p "$CARGO_HOME" "$RUSTUP_HOME" /tmp/cargo-target
chown -R ue4:ue4 "$CARGO_HOME" "$RUSTUP_HOME" /tmp/cargo-target

# If your tests write under sdks/unreal (Saved/, Intermediate/, etc), chown just that subtree:
chown -R ue4:ue4 "$REPO/sdks/unreal"

# 2) Ensure UE build script is executable/traversable
if [ -d "$UE_DIR" ]; then
chmod a+rx "$UE_DIR" || true
chmod -R a+X "$UE_DIR/Engine/Build/BatchFiles" || true
[ -f "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" ] && chmod a+rx "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" || true
fi

# 3) Run tests as ue4 (don’t touch RUNNER_TEMP)
sudo -E -H -u ue4 env \
HOME=/home/ue4 \
XDG_CONFIG_HOME=/home/ue4/.config \
CARGO_HOME="$CARGO_HOME" \
RUSTUP_HOME="$RUSTUP_HOME" \
PATH="$CARGO_HOME/bin:$PATH" \
TMPDIR=/tmp \
bash -lc '
set -euxo pipefail
command -v curl >/dev/null || (sudo apt-get update && sudo apt-get install -y curl ca-certificates)

if ! command -v cargo >/dev/null 2>&1; then
curl -sSf https://sh.rustup.rs | sh -s -- -y
fi
rustup show >/dev/null
git config --global --add safe.directory "$GITHUB_WORKSPACE" || true

cd "$GITHUB_WORKSPACE/sdks/unreal"
cargo --version
cargo test
'

cli_docs:
name: Check CLI docs
permissions: read-all
Expand All @@ -260,46 +339,23 @@ jobs:
GIT_REF="${{ github.ref }}"
fi
echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"

- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- uses: pnpm/action-setup@v4
with:
run_install: true

- name: Get pnpm store directory
shell: bash
working-directory: sdks/typescript
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- uses: dsherret/rust-toolchain-file@v1

- name: Check for docs change
run: |
cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md
pnpm format
cd docs
# This is needed because our website doesn't render markdown quite properly.
# See the README in docs for more details.
sed -i'' -E 's!^(##) `(.*)`$!\1 \2!' docs/cli-reference.md
sed -i'' -E 's!^(######) \*\*(.*)\*\*$!\1 <b>\2</b>!' docs/cli-reference.md
git status
if git diff --exit-code HEAD; then
echo "No docs changes detected"
else
echo "It looks like the CLI docs have changed:"
exit 1
fi

Loading