Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 17 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ jobs:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8 # v1.3.0
with:
android: true
dotnet: false
haskell: true
large-packages: false
docker-images: false
swap-storage: true

- name: Checkout submodules
run: git submodule update --init --recursive src/sentry-dotnet

Expand All @@ -38,17 +48,13 @@ jobs:
env:
UNITY_SCRIPT_ARG: unity${{ env.UNITY_VERSION }}

- run: echo "::add-mask::$LICENSE_SERVER_URL"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The masking does nothing

Can't add secret mask for empty string in ##[add-mask] command.

env:
LICENSE_SERVER_URL: ${{ secrets.LICENSE_SERVER_URL }}

- name: Restore Unity Packages
Copy link
Contributor Author

@bitsandfoxes bitsandfoxes Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't even remember why we were trying to cache the packages only. But it doesn't work in any case:

Cache not found for input keys

We're just caching the full Library like in the rest of CI instead. This lets us skip the full on creation of the assetdatabase with every single run.

uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # v3
- name: Cache Unity Library
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: |
samples/unity-of-bugs/Library/Packages
temp/unity-packages/Library/ScriptAssemblies/*.TestRunner.*
key: samples/unity-of-bugs|${{ steps.env.outputs.unityVersion }}-${{ hashFiles('samples/unity-of-bugs/Packages/packages-lock.json') }}
path: samples/unity-of-bugs/Library
key: Library-unity-of-bugs-${{ steps.env.outputs.unityVersion }}-v1
restore-keys: |
Library-unity-of-bugs-${{ steps.env.outputs.unityVersion }}-

- name: Docker Login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pinned v3
Expand All @@ -72,11 +78,6 @@ jobs:
- name: Restore .NET Workload
run: dotnet workload restore

- name: Install Android dotnet workflow
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet workload restore already does that for us

run: dotnet workload install android --temp-dir "$RUNNER_TEMP"
env:
RUNNER_TEMP: ${{ env.RUNNER_TEMP }}

- name: Download CLI
run: ./scripts/download-sentry-cli.ps1

Expand Down Expand Up @@ -134,9 +135,7 @@ jobs:
package-release.zip

- name: Run Unity tests (playmode)
run: |
docker exec unity dotnet msbuild /t:UnityConfigureSentryOptions /p:TestDsn= /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
docker exec unity dotnet msbuild /t:UnityPlayModeTest /p:Configuration=Release /p:OutDir=other test/Sentry.Unity.Tests
run: docker exec unity dotnet msbuild /t:UnityPlayModeTest /p:Configuration=Release /p:OutDir=other test/Sentry.Unity.Tests
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running it twice was a leftover from a time where we had to manually set/replace the TestDsn. That's no longer needed.


- name: Run Unity tests (editmode)
run: docker exec unity dotnet msbuild /t:UnityEditModeTest /p:Configuration=Release /p:OutDir=other test/Sentry.Unity.Editor.Tests
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ jobs:
docker-images: false
swap-storage: true

- run: echo "::add-mask::$LICENSE_SERVER_URL"
env:
LICENSE_SERVER_URL: ${{ secrets.LICENSE_SERVER_URL }}

- name: Docker Login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pinned v3
with:
Expand All @@ -162,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: Restore cached build without Sentry
id: cache-build-nosentry
uses: actions/cache@v4
Expand Down Expand Up @@ -393,10 +398,6 @@ jobs:
unity-version: ${{ steps.env.outputs.unityVersion }}
unity-modules: ${{ matrix.unity-modules }}

- run: echo "::add-mask::$LICENSE_SERVER_URL"
env:
LICENSE_SERVER_URL: ${{ secrets.LICENSE_SERVER_URL }}

- name: Create Unity license config
run: |
New-Item -Path "$env:UNITY_CONFIG_PATH" -ItemType Directory
Expand All @@ -413,6 +414,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: Restore cached build without Sentry
id: cache-build-nosentry
uses: actions/cache@v4
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ jobs:
DEBIAN_FRONTEND: noninteractive

- name: Install .NET SDK
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added missing skips if the cache was hit.

uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5
with:
global-json-file: global.json

- name: Restore .NET Workload
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: dotnet workload restore

- name: Build
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/smoke-test-build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ jobs:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3

- run: echo "::add-mask::$LICENSE_SERVER_URL"
env:
LICENSE_SERVER_URL: ${{ secrets.LICENSE_SERVER_URL }}

- name: Docker Login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pinned v3
with:
Expand All @@ -49,6 +45,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: Restore cached build without Sentry
id: cache-build-nosentry
uses: actions/cache@v4
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/smoke-test-build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3

- run: echo "::add-mask::$LICENSE_SERVER_URL"
env:
LICENSE_SERVER_URL: ${{ secrets.LICENSE_SERVER_URL }}

- name: Docker Login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pinned v3
with:
Expand All @@ -55,6 +51,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: Restore cached build without Sentry
id: cache-build-nosentry
uses: actions/cache@v4
Expand Down Expand Up @@ -96,21 +101,21 @@ jobs:
env:
BUILD_PLATFORM: ${{ matrix.build_platform }}

- name: Build Project
- name: Build Project with runtime initialization
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -CheckSymbols:$false -UnityVersion "$env:UNITY_VERSION"
env:
BUILD_PLATFORM: ${{ matrix.build_platform }}

# We create tar explicitly because upload-artifact is slow for many files.
- name: Create archive
- name: Create archive (runtime initialization)
shell: bash
run: |
# Note: remove local.properties file that contains Android SDK & NDK paths in the Unity installation.
rm -rf samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
tar -cvzf test-app-runtime.tar.gz samples/IntegrationTest/Build

# Upload runtime initialization build
- name: Upload test app
- name: Upload test app (runtime initialization)
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: testapp-ios-${{ env.UNITY_VERSION }}-runtime
Expand All @@ -125,7 +130,7 @@ jobs:
$content = $content -replace 'IosNativeInitializationType = NativeInitializationType.Runtime', 'IosNativeInitializationType = NativeInitializationType.BuildTime'
Set-Content $optionsPath $content

- name: Build Project for mobile platforms (build-time initialization)
- name: Build Project with build-time initialization
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -CheckSymbols:$false -UnityVersion "$env:UNITY_VERSION"
env:
BUILD_PLATFORM: ${{ matrix.build_platform }}
Expand Down
11 changes: 11 additions & 0 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
if: steps.cache-project.outputs.cache-hit != 'true'
run: ./scripts/ci-docker.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 Down
14 changes: 11 additions & 3 deletions scripts/ci-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ fi
echo "Starting up '$image' as '$container'"
suexec="docker exec --user root"

# Format: <job-name>-<image-variant>-<run-id>
uniqueHostname="${GITHUB_JOB:-local}-${imageVariant}-${GITHUB_RUN_ID:-0}"
# Sanitize hostname: replace underscores and spaces with hyphens, ensure lowercase
uniqueHostname=$(echo "$uniqueHostname" | tr '[:upper:]_ ' '[:lower:]--' | tr -s '-')

# We use the host dotnet installation - it's much faster than installing inside the docker container.
set -x
docker run -td --name $container \
--hostname $uniqueHostname \
--user $uid:$gid \
-v "$cwd":/sentry-unity \
-v $ANDROID_HOME:$ANDROID_HOME \
Expand All @@ -39,6 +45,10 @@ docker run -td --name $container \
-e GITHUB_ACTIONS="${GITHUB_ACTIONS}" \
--workdir /sentry-unity $image

# Generate unique machine-id to avoid any hardcoded values and license-fetch congestion
$suexec $container rm -f /etc/machine-id
$suexec $container dbus-uuidgen --ensure=/etc/machine-id

$suexec $container groupadd -g $gid $user
$suexec $container useradd -u $uid -g $gid --create-home $user

Expand All @@ -50,9 +60,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/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was failing with

./scripts/ci-docker.sh: line 53: [[: 6000.0: syntax error: invalid arithmetic operator (error token is ".0")

and we're running on 2021+ only anyway.


echo "Container started successfully: "
docker ps --filter "name=^/$container$"
12 changes: 12 additions & 0 deletions test/Scripts.Integration.Test/Editor/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ public static void BuildLinuxIl2CPPPlayer()
public static void BuildAndroidIl2CPPPlayer()
{
Debug.Log("Builder: Building Android IL2CPP Player");

#if UNITY_2021_2_OR_NEWER && !UNITY_6000_0_OR_NEWER
// Clean Android gradle cache to force regeneration of gradle files
// This prevents Unity from reusing gradle files that may contain Sentry symbol upload tasks from previous builds
var androidGradlePath = Path.Combine(Directory.GetCurrentDirectory(), "Library/Bee/Android");
if (Directory.Exists(androidGradlePath))
{
Debug.Log($"Builder: Cleaning Android gradle cache at '{androidGradlePath}'");
Directory.Delete(androidGradlePath, true);
}
#endif

BuildIl2CPPPlayer(BuildTarget.Android, BuildTargetGroup.Android, BuildOptions.StrictMode);
}
public static void BuildAndroidIl2CPPProject()
Expand Down
Loading