Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Start the Unity docker container
run: ./scripts/ci-docker.sh "$UNITY_VERSION" 'ios' "$UNITY_LICENSE_SERVER_CONFIG"
run: ./scripts/ci-docker-start.sh "$UNITY_VERSION" 'ios' "$UNITY_LICENSE_SERVER_CONFIG"
shell: bash
env:
UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}
Expand Down Expand Up @@ -148,3 +148,8 @@ jobs:
with:
name: Test results (editmode) - ${{ env.UNITY_VERSION }}
path: artifacts/test/editmode

- name: Cleanup Unity container and return license
if: always()
run: ./scripts/ci-docker-stop.sh
shell: bash
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Start the Unity docker container
run: ./scripts/ci-docker.sh "$UNITY_VERSION" "$PLATFORM_WITH_SUFFIX" "$UNITY_LICENSE_SERVER_CONFIG"
run: ./scripts/ci-docker-start.sh "$UNITY_VERSION" "$PLATFORM_WITH_SUFFIX" "$UNITY_LICENSE_SERVER_CONFIG"
shell: bash
env:
UNITY_VERSION: ${{ matrix.unity-version }}
Expand All @@ -158,6 +158,15 @@ jobs:
- name: Extract project archive
run: tar -xvzf test-project.tar.gz

- name: Cache Unity Library
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: samples/IntegrationTest/Library
key: Library-IntegrationTest-${{ matrix.platform }}-${{ matrix.unity-version }}-v1
restore-keys: |
Library-IntegrationTest-${{ matrix.platform }}-${{ matrix.unity-version }}-
Library-IntegrationTest-${{ matrix.platform }}-

# - name: Build without Sentry SDK
# run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform "${{ matrix.platform }}"

Expand Down Expand Up @@ -213,6 +222,11 @@ jobs:
# Lower retention period - we only need this to retry CI.
retention-days: 14

- name: Cleanup Unity container and return license
if: always()
run: ./scripts/ci-docker-stop.sh
shell: bash

smoke-test-build-android:
name: Build Android ${{ matrix.unity-version }} Smoke Test
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
Expand Down Expand Up @@ -386,6 +400,15 @@ jobs:
- name: Extract project archive
run: tar -xvzf test-project.tar.gz

- name: Cache Unity Library
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: samples/IntegrationTest/Library
key: Library-IntegrationTest-${{ matrix.os }}-${{ matrix.unity-version }}-v1
restore-keys: |
Library-IntegrationTest-${{ matrix.os }}-${{ matrix.unity-version }}-
Library-IntegrationTest-${{ matrix.os }}-

- name: Build without Sentry SDK
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH"

Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/smoke-test-build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Start the Unity docker container
run: ./scripts/ci-docker.sh "$UNITY_VERSION" 'android' "$UNITY_LICENSE_SERVER_CONFIG"
run: ./scripts/ci-docker-start.sh "$UNITY_VERSION" 'android' "$UNITY_LICENSE_SERVER_CONFIG"
shell: bash
env:
UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}
Expand All @@ -49,6 +49,15 @@ jobs:
- name: Extract project archive
run: tar -xvzf test-project.tar.gz

- name: Cache Unity Library
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: samples/IntegrationTest/Library
key: Library-IntegrationTest-Android-${{ env.UNITY_VERSION }}-v1
restore-keys: |
Library-IntegrationTest-Android-${{ env.UNITY_VERSION }}-
Library-IntegrationTest-Android-

- name: Download UPM package
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848 # v4-with-wait-timeout
with:
Expand Down Expand Up @@ -101,3 +110,8 @@ jobs:
!samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
retention-days: 14 # Lower retention period - we only need this to retry CI.

- name: Cleanup Unity container and return license
if: always()
run: ./scripts/ci-docker-stop.sh
shell: bash

18 changes: 16 additions & 2 deletions .github/workflows/smoke-test-build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Start the Unity docker container
run: ./scripts/ci-docker.sh "$UNITY_VERSION" "iOS" "$UNITY_LICENSE_SERVER_CONFIG"
run: ./scripts/ci-docker-start.sh "$UNITY_VERSION" "iOS" "$UNITY_LICENSE_SERVER_CONFIG"
shell: bash
env:
UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}
Expand All @@ -55,6 +55,15 @@ jobs:
- name: Extract project archive
run: tar -xvzf test-project.tar.gz

- name: Cache Unity Library
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: samples/IntegrationTest/Library
key: Library-IntegrationTest-iOS-${{ env.UNITY_VERSION }}-v1
restore-keys: |
Library-IntegrationTest-iOS-${{ env.UNITY_VERSION }}-
Library-IntegrationTest-iOS-

- name: Download UPM package
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848 # v4-with-wait-timeout
with:
Expand Down Expand Up @@ -130,4 +139,9 @@ jobs:
samples/IntegrationTest
!samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
# Lower retention period - we only need this to retry CI.
retention-days: 14
retention-days: 14

- name: Cleanup Unity container and return license
if: always()
run: ./scripts/ci-docker-stop.sh
shell: bash
20 changes: 18 additions & 2 deletions .github/workflows/smoke-test-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,24 @@ jobs:
username: ${{ env.GITHUB_ACTOR }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache IntegrationTest Project
id: cache-project
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: samples/IntegrationTest
key: IntegrationTest-Project-${{ env.UNITY_VERSION }}-${{ hashFiles('test/Scripts.Integration.Test/**') }}-v1
restore-keys: |
IntegrationTest-Project-${{ env.UNITY_VERSION }}-

- name: Start the Unity docker container
run: ./scripts/ci-docker.sh "$UNITY_VERSION" 'base' "$UNITY_LICENSE_SERVER_CONFIG"
if: steps.cache-project.outputs.cache-hit != 'true'
run: ./scripts/ci-docker-start.sh "$UNITY_VERSION" 'base' "$UNITY_LICENSE_SERVER_CONFIG"
shell: bash
env:
UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}

- name: Create new Project
if: steps.cache-project.outputs.cache-hit != 'true'
run: ./test/Scripts.Integration.Test/create-project.ps1 -UnityPath "$env:UNITY_PATH"

# We create tar explicitly because upload-artifact is slow for many files.
Expand All @@ -54,4 +65,9 @@ jobs:
if-no-files-found: error
path: test-project.tar.gz
# Lower retention period - we only need this to retry CI.
retention-days: 14
retention-days: 14

- name: Cleanup Unity container and return license
if: always()
run: ./scripts/ci-docker-stop.sh
shell: bash
4 changes: 1 addition & 3 deletions scripts/ci-docker.sh → scripts/ci-docker-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ echo $licenseConfig | $suexec -i $container sh -c "cat > /usr/share/unity3d/conf
$suexec $container chown -R $uid /usr/share/unity3d/config/

# Unity 2021+ tries to write to this directory during asset import...
if [[ $unityPrefix -ge 2021 ]]; then
$suexec $container chmod -R 755 /opt/unity/Editor/Data/UnityReferenceAssemblies/
fi
$suexec $container chmod -R 755 /opt/unity/Editor/Data/UnityReferenceAssemblies/

echo "Container started successfully: "
docker ps --filter "name=^/$container$"
25 changes: 25 additions & 0 deletions scripts/ci-docker-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -uo pipefail

container="unity"

# Check if container exists and is running
if [[ $(docker ps --filter "name=^/$container$" --format '{{.Names}}') == "$container" ]]; then
echo "Returning Unity license..."
# Try to return the license gracefully, but don't fail if it doesn't work
docker exec $container unity-editor -quit -batchmode -returnlicense || echo "License return command failed, but continuing cleanup..."

# Give Unity a moment to finish returning the license
sleep 2

echo "Stopping container '$container' gracefully..."
# docker stop sends SIGTERM and waits for graceful shutdown (default 10s timeout)
docker stop $container

echo "Removing container '$container'..."
docker rm $container

echo "Cleanup completed successfully"
else
echo "Container '$container' is not running, nothing to clean up"
fi
Loading