-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Detter
committed
Oct 30, 2024
1 parent
f78a4eb
commit 31350e9
Showing
5 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
name: Unity Test Suite | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Grab the branch name from the PR description. If it's not found, master will be used instead. | ||
- name: Extract SpacetimeDB branch name or PR link from PR description | ||
id: extract-branch | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
description=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
${{ github.event.pull_request.url }} | jq -r '.body') | ||
# Check if description contains a branch name or a PR link | ||
branch_or_pr=$(echo "$description" | grep -oP '(?<=SpacetimeDB branch name:\s).+') | ||
echo "Branch or PR found: $branch_or_pr" | ||
if [[ -z "$branch_or_pr" ]]; then | ||
branch="master" | ||
elif [[ "$branch_or_pr" =~ ^https://github.com/.*/pull/[0-9]+$ ]]; then | ||
# If it's a PR link, extract the branch name from the PR | ||
pr_number=$(echo "$branch_or_pr" | grep -oP '[0-9]+$') | ||
branch=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
https://api.github.com/repos/clockworklabs/SpacetimeDB/pulls/$pr_number | jq -r '.head.ref') | ||
else | ||
# It's already a branch name | ||
branch="$branch_or_pr" | ||
fi | ||
echo "branch=$branch" >> $GITHUB_OUTPUT | ||
echo "Final branch name: $branch" | ||
- name: Replace com.clockworklabs.spacetimedbsdk in manifest.json | ||
run: | | ||
# Get the branch name from the environment variable | ||
branch_name="${{ github.head_ref }}" | ||
# Replace any reference to com.clockworklabs.spacetimedbsdk with the correct GitHub URL using the current branch | ||
sed -i "s|\"com.clockworklabs.spacetimedbsdk\":.*|\"com.clockworklabs.spacetimedbsdk\": \"https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk.git#$branch_name\",|" unity-tests~/client/Packages/manifest.json | ||
cat unity-tests~/client/Packages/manifest.json | ||
- name: Replace spacetimedb dependency in Cargo.toml | ||
run: | | ||
# Get the branch name from the environment variable | ||
branch_name="${{ github.head_ref }}" | ||
# Make sure we're using the correct bindings when building the module TODO | ||
sed -i "s|spacetimedb.*=|spacetimedb = \{ path = \"../SpacetimeDB/crates/bindings\"\}|" unity-tests~/server/Cargo.toml | ||
cat unity-tests~/server/Cargo.toml | ||
exit 1 | ||
- name: Install Rust toolchain | ||
run: | | ||
curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
source $HOME/.cargo/env | ||
rustup install stable | ||
rustup default stable | ||
- name: Install SpacetimeDB CLI from specific branch | ||
run: | | ||
cd unity-tests~ | ||
git clone https://github.com/clockworklabs/SpacetimeDB.git | ||
cd SpacetimeDB | ||
# Sanitize the branch name by trimming any newlines or spaces | ||
branch_name=$(echo "${{ steps.extract-branch.outputs.branch }}" | tr -d '[:space:]') | ||
# If the branch name is not found, default to master | ||
if [ -z "$branch_name" ]; then | ||
branch_name="master" | ||
fi | ||
git checkout "$branch_name" | ||
echo "Checked out branch: $branch_name" | ||
cargo build --release -p spacetimedb-cli | ||
sudo mv target/release/spacetime /usr/bin/spacetime | ||
- name: Generate client bindings | ||
run: | | ||
cd unity-tests~/server | ||
bash ./generate.sh -y | ||
- name: Start SpacetimeDB | ||
run: | | ||
spacetime start & | ||
disown | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
unity-tests~/server/target | ||
~/.cargo | ||
key: server-target-SpacetimeDBUnityTestsuite-Linux-x86-${{ runner.os }}-${{ hashFiles('unity-tests~/server/Cargo.lock') }} | ||
restore-keys: | | ||
server-target-SpacetimeDBUnityTestsuite-Linux-x86-${{ runner.os }}- | ||
server-target-SpacetimeDBUnityTestsuite- | ||
- name: Publish module to SpacetimeDB | ||
run: | | ||
cd unity-tests~/server | ||
bash ./publish.sh | ||
- uses: actions/cache@v3 | ||
with: | ||
path: unity-tests~/client/Library | ||
key: Library-SpacetimeDBUnityTestsuite-Linux-x86 | ||
restore-keys: | | ||
Library-SpacetimeDBUnityTestsuite- | ||
Library- | ||
- name: Set up Unity | ||
uses: game-ci/unity-test-runner@v4 | ||
with: | ||
unityVersion: 2022.3.32f1 # Adjust Unity version to a valid tag | ||
projectPath: unity-tests~/client # Path to the Unity project subdirectory | ||
githubToken: ${{ secrets.GITHUB_TOKEN }} | ||
testMode: playmode | ||
useHostNetwork: true | ||
env: | ||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | ||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | ||
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Check Unity Testsuite Bindings | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Replace spacetimedb dependency in Cargo.toml | ||
run: | | ||
# Get the branch name from the environment variable | ||
branch_name="${{ github.head_ref }}" | ||
# Make sure we're using the correct bindings when building the module TODO | ||
sed -i "s|spacetimedb.*=|spacetimedb = \{ path = \"../SpacetimeDB/crates/bindings\"\}|" unity-tests~/server/Cargo. toml | ||
cat unity-tests~/server/Cargo.toml | ||
# Grab the branch name from the PR description. If it's not found, master will be used instead. | ||
- name: Extract SpacetimeDB branch name or PR link from PR description | ||
id: extract-branch | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
description=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
${{ github.event.pull_request.url }} | jq -r '.body') | ||
# Check if description contains a branch name or a PR link | ||
branch_or_pr=$(echo "$description" | grep -oP '(?<=SpacetimeDB branch name:\s).+') | ||
echo "Branch or PR found: $branch_or_pr" | ||
if [[ -z "$branch_or_pr" ]]; then | ||
branch="master" | ||
elif [[ "$branch_or_pr" =~ ^https://github.com/.*/pull/[0-9]+$ ]]; then | ||
# If it's a PR link, extract the branch name from the PR | ||
pr_number=$(echo "$branch_or_pr" | grep -oP '[0-9]+$') | ||
branch=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
https://api.github.com/repos/clockworklabs/SpacetimeDB/pulls/$pr_number | jq -r '.head.ref') | ||
else | ||
# It's already a branch name | ||
branch="$branch_or_pr" | ||
fi | ||
echo "branch=$branch" >> $GITHUB_OUTPUT | ||
echo "Final branch name: $branch" | ||
- name: Install Rust toolchain | ||
run: | | ||
curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
source $HOME/.cargo/env | ||
rustup install stable | ||
rustup default stable | ||
- name: Install SpacetimeDB CLI from specific branch | ||
run: | | ||
cd unity-tests~ | ||
git clone https://github.com/clockworklabs/SpacetimeDB.git | ||
cd SpacetimeDB | ||
# Sanitize the branch name by trimming any newlines or spaces | ||
branch_name=$(echo "${{ steps.extract-branch.outputs.branch }}" | tr -d '[:space:]') | ||
# If the branch name is not found, default to master | ||
if [ -z "$branch_name" ]; then | ||
branch_name="master" | ||
fi | ||
git checkout "$branch_name" | ||
echo "Checked out branch: $branch_name" | ||
cargo build --release -p spacetimedb-cli | ||
sudo mv target/release/spacetime /usr/bin/spacetime | ||
- name: Generate client bindings | ||
run: | | ||
cd unity-tests~/server | ||
bash ./generate.sh -y | ||
- name: Check for changes | ||
run: | | ||
git diff --exit-code | ||
continue-on-error: true | ||
|
||
- name: Fail if there are changes | ||
if: ${{ steps.check-for-changes.outcome == 'failure' }} | ||
run: | | ||
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch." | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "SpacetimeDBCircleGame"] | ||
path = unity-tests~ | ||
url = ssh://[email protected]/clockworklabs/SpacetimeDBCircleGame |
Submodule unity-tests~
added at
75047b