Skip to content

Merge branch 'main' into deps/src/sentry-dotnet/4.5.0 #5356

Merge branch 'main' into deps/src/sentry-dotnet/4.5.0

Merge branch 'main' into deps/src/sentry-dotnet/4.5.0 #5356

Workflow file for this run

name: CI
on:
push:
paths-ignore:
- '**.md'
- '**.txt'
workflow_dispatch: # e.g. to manually trigger on foreign PRs
env:
LOWEST_SUPPORTED_UNITY_VERSION: 2019
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
defaults:
run:
shell: pwsh
jobs:
cancel-previous-workflow:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # pin@0.11.0
with:
access_token: ${{ github.token }}
sdk:
strategy:
matrix:
include:
- target: Android
host: ubuntu-latest
- target: iOS
host: macos-13
- target: Linux
host: ubuntu-latest
- target: macOS
host: macos-13
- target: Windows
host: windows-latest
uses: ./.github/workflows/sdk.yml
with:
target: ${{ matrix.target }}
runsOn: ${{ matrix.host }}
build:
name: Build - ${{ matrix.unity-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Building the SDK with Unity 2022 requires ns2.1 - skipping for now
unity-version: ['2019', '2020', '2021']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive src/sentry-dotnet
- name: Load env
id: env
run: echo "unityVersion=$(./scripts/ci-env.ps1 "unity${{ matrix.unity-version }}")" >> $env:GITHUB_OUTPUT
- run: echo "::add-mask::${{ secrets.LICENSE_SERVER_URL }}"
- name: Restore Unity Packages
uses: actions/cache@v3
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') }}
- name: Start the Unity docker container
# We must use the iOS version of the image instead of 'base' - Sentry.Unity.Editor.iOS.csproj requires some libraries.
# Maybe we could just cache the needed file instead of pulling the 1 GB larger image on every build...
run: ./scripts/ci-docker.sh '${{ matrix.unity-version }}' 'ios' '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}'
shell: bash
# Required by sentry-dotnet since 3.19.0
- name: Install Android dotnet workflow
run: dotnet workload install android --temp-dir "${{ runner.temp }}"
- name: Download CLI
run: ./scripts/download-sentry-cli.ps1
- uses: vaind/download-artifact@cbec071ac01e26699bc70c82f63ef724b3b0a91d
with:
name: Android-sdk
path: package-dev/Plugins/Android
wait-timeout: 3600
- uses: vaind/download-artifact@cbec071ac01e26699bc70c82f63ef724b3b0a91d
with:
name: Android-libraries
path: modules/sentry-java/sentry-android-ndk/build/intermediates/merged_native_libs/release/out/lib
wait-timeout: 3600
- uses: vaind/download-artifact@cbec071ac01e26699bc70c82f63ef724b3b0a91d
with:
name: iOS-sdk
path: package-dev/Plugins/iOS
wait-timeout: 3600
- uses: vaind/download-artifact@cbec071ac01e26699bc70c82f63ef724b3b0a91d
with:
name: macOS-sdk
path: package-dev/Plugins/macOS
wait-timeout: 3600
- uses: vaind/download-artifact@cbec071ac01e26699bc70c82f63ef724b3b0a91d
with:
name: Linux-sdk
path: package-dev/Plugins/Linux
wait-timeout: 3600
- uses: vaind/download-artifact@cbec071ac01e26699bc70c82f63ef724b3b0a91d
with:
name: Windows-sdk
path: package-dev/Plugins/Windows
wait-timeout: 3600
- name: Build Sentry.Unity Solution
run: docker exec unity dotnet build -c Release
- name: Install assemblyalias
run: docker exec unity dotnet tool install --global Alias --version 0.4.3
- name: Alias editor assemblies
run: docker exec unity /home/gh/.dotnet/tools/assemblyalias --target-directory "package-dev/Editor" --internalize --prefix "Sentry." --assemblies-to-alias "Microsoft*;Mono.Cecil*"
- name: Alias runtime assemblies
run: docker exec unity /home/gh/.dotnet/tools/assemblyalias --target-directory "package-dev/Runtime" --internalize --prefix "Sentry." --assemblies-to-alias "Microsoft*;System*"
- name: Package for release
if: ${{ matrix.unity-version == env.LOWEST_SUPPORTED_UNITY_VERSION }}
run: |
# Before packaging, we need to open & close Unity on the sample project to update .meta files in package-dev.
# We could add a new custom target but reusing UnityConfigureSentryOptions is good enough.
docker exec unity dotnet msbuild /t:UnityConfigureSentryOptions /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
./scripts/pack.ps1
- name: Upload release artifacts
uses: actions/upload-artifact@v3
if: ${{ matrix.unity-version == env.LOWEST_SUPPORTED_UNITY_VERSION }}
with:
name: ${{ github.sha }}
if-no-files-found: error
# Adding the native libraries so the symbol collector craft target can find/upload them
path: |
package-release.zip
modules/sentry-java/sentry-android-ndk/build/intermediates/merged_native_libs/release/out/lib/*
- 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
- name: Upload test artifacts (playmode)
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: Test results (playmode)
path: artifacts/test/playmode
- name: Run Unity tests (editmode)
run: docker exec unity dotnet msbuild /t:UnityEditModeTest /p:Configuration=Release /p:OutDir=other test/Sentry.Unity.Editor.Tests
- name: Upload test artifacts (editmode)
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: Test results (editmode)
path: artifacts/test/editmode
package-validation:
name: UPM Package validation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download UPM package
uses: vaind/download-artifact@cbec071ac01e26699bc70c82f63ef724b3b0a91d
with:
name: ${{ github.sha }}
wait-timeout: 3600
- name: Verify package content against snapshot
# If this step fails, you can accept the new file content by
# running the following script locally with 'accept' as an argument
# and committing the new snapshot file to your branch. i.e:
# ./test/Scripts.Tests/test-pack-contents.ps1 accept
run: ./test/Scripts.Tests/test-pack-contents.ps1
# This produces the `samples/IntegrationTest` as `smoke-test-${{ matrix.unity-version }}`. If running on the `main`
# branch, the project doesn't include Sentry SDK because in that case we test building with & without it.
# We could just create the project later in `smoke-test-build` but then it's executed for each job in the matrix
# and reduces concurrency because of Unity licence limits.
smoke-test-create:
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
name: ${{ matrix.unity-version }} Prepare Smoke Test
runs-on: ubuntu-latest
needs: [package-validation]
strategy:
fail-fast: false
matrix:
unity-version: ['2019', '2020', '2021', '2022']
env:
UNITY_PATH: docker exec unity unity-editor
steps:
- name: Checkout
uses: actions/checkout@v3
- run: echo "::add-mask::${{ secrets.LICENSE_SERVER_URL }}"
- name: Start the Unity docker container
run: ./scripts/ci-docker.sh '${{ matrix.unity-version }}' 'base' '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}'
shell: bash
- name: Create new Project
run: ./test/Scripts.Integration.Test/create-project.ps1 -UnityPath "${{ env.UNITY_PATH }}"
- name: Download UPM package
if: ${{ github.ref_name != 'main' }}
uses: actions/download-artifact@v3
with:
name: ${{ github.sha }}
- name: Extract UPM package
if: ${{ github.ref_name != 'main' }}
run: ./test/Scripts.Integration.Test/extract-package.ps1
- name: Add Sentry to the project
if: ${{ github.ref_name != 'main' }}
run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}"
# We create tar explicitly because upload-artifact is slow for many files.
- name: Create archive
run: tar -cvzf test-project.tar.gz samples/IntegrationTest
- name: Upload project
uses: actions/upload-artifact@v3
with:
name: smoke-test-${{ matrix.unity-version }}
if-no-files-found: error
path: test-project.tar.gz
# Lower retention period - we only need this to retry CI.
retention-days: 14
# A Linux, docker-based build to prepare a game ("player") for some platforms. The tests run in `smoke-test-run`.
smoke-test-build:
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
name: ${{ matrix.unity-version }} ${{ matrix.platform }} Build Smoke Test
needs: [smoke-test-create]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
unity-version: ['2019', '2020', '2021', '2022']
platform: ['Android', 'WebGL', 'Linux', 'iOS']
include:
- platform: Linux
image-suffix: '-il2cpp'
env:
UNITY_PATH: docker exec unity unity-editor
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8
with:
android: false
dotnet: false
haskell: true
large-packages: false
docker-images: false
swap-storage: true
- run: echo "::add-mask::${{ secrets.LICENSE_SERVER_URL }}"
- name: Start the Unity docker container
run: ./scripts/ci-docker.sh '${{ matrix.unity-version }}' '${{ matrix.platform }}${{ matrix.image-suffix }}' '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}'
shell: bash
# Workaround for missing libMonoPosixHelper.so
# See https://github.com/getsentry/sentry-unity/pull/1295
- name: Install mono-devel
if: ${{ matrix.unity-version == '2019' }}
run: |
docker exec --user root unity apt-get update
docker exec --user root unity apt-get -y -q install mono-devel
- name: Download IntegrationTest project
uses: actions/download-artifact@v3
with:
name: smoke-test-${{ matrix.unity-version }}
- name: Extract project archive
run: tar -xvzf test-project.tar.gz
- name: Build without Sentry SDK
# This hasn't broken for many months, so disabling on PRs to speed up CI. And also to test a clean build with Sentry SDK included.
if: ${{ github.ref_name == 'main' }}
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform "${{ matrix.platform }}"
- name: Download UPM package
uses: actions/download-artifact@v3
with:
name: ${{ github.sha }}
- name: Extract UPM package
run: ./test/Scripts.Integration.Test/extract-package.ps1
- name: Add Sentry to the project
if: ${{ github.ref_name == 'main' }}
run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}"
- name: Build with Sentry SDK
run: |
$platform = ('${{ matrix.platform }}' -eq 'Android') -and ('${{ github.ref_name }}' -ne 'main') ? 'Android-Export' : '${{ matrix.platform }}'
./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform $platform -CheckSymbols
- name:
run: |
$platform = '${{ matrix.platform }}'
if ($platform -eq 'iOS')
{
$checkSymbols = $false
}
elseif (($platform -eq 'Android') -and ('${{ github.ref_name }}' -ne 'main'))
{
$checkSymbols = $false
$platform = 'Android-Export'
}
else
{
$checkSymbols = $true
}
./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform $platform -CheckSymbols:$checkSymbols -UnityVersion "${{ matrix.unity-version }}"
# We create tar explicitly because upload-artifact is slow for many files.
- name: Create archive
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.tar.gz samples/IntegrationTest/Build
- name: Upload test app
uses: actions/upload-artifact@v3
with:
name: testapp-${{ matrix.platform }}-${{ matrix.unity-version }}
if-no-files-found: error
path: test-app.tar.gz
# Lower retention period - we only need this to retry CI.
retention-days: 14
- name: Upload IntegrationTest project on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: failed-project-${{ matrix.platform }}-${{ matrix.unity-version }}
path: |
samples/IntegrationTest
!samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
# Lower retention period - we only need this to retry CI.
retention-days: 14
desktop-smoke-test:
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
name: ${{ matrix.unity-version }} ${{ matrix.platform }} Run Smoke Test
needs: [smoke-test-create]
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
unity-version: ['2019', '2020', '2021', '2022']
os: ['windows', 'macos']
include:
- os: windows
unity-modules: windows-il2cpp
unity-config-path: C:/ProgramData/Unity/config/
- os: macos
unity-modules: mac-il2cpp
unity-config-path: /Library/Application Support/Unity/config/
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Load env
id: env
run: echo "unityVersion=$(./scripts/ci-env.ps1 "unity${{ matrix.unity-version }}")" >> $env:GITHUB_OUTPUT
- name: Setup Unity
uses: getsentry/setup-unity@d84ad1d1fb3020e48883c3ac8e87d64baf1135c7
with:
unity-version: ${{ steps.env.outputs.unityVersion }}
unity-modules: ${{ matrix.unity-modules }}
- run: echo "::add-mask::${{ secrets.LICENSE_SERVER_URL }}"
- name: Create Unity license config
run: |
New-Item -Path '${{ matrix.unity-config-path }}' -ItemType Directory
Set-Content -Path '${{ matrix.unity-config-path }}services-config.json' -Value '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}'
- name: Download IntegrationTest project
uses: actions/download-artifact@v3
with:
name: smoke-test-${{ matrix.unity-version }}
- name: Extract project archive
run: tar -xvzf test-project.tar.gz
- name: Build without Sentry SDK
# This hasn't broken for many months, so disabling on PRs to speed up CI. And also to test a clean build with Sentry SDK included.
if: ${{ github.ref_name == 'main' }}
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}"
- name: Download UPM package
uses: actions/download-artifact@v3
with:
name: ${{ github.sha }}
- name: Extract UPM package
run: ./test/Scripts.Integration.Test/extract-package.ps1
- name: Add Sentry to the project
if: ${{ github.ref_name == 'main' }}
run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}"
- name: Configure Sentry
run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "${{ env.UNITY_PATH }}" -CheckSymbols
- name: Build with Sentry SDK
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -CheckSymbols -UnityVersion "${{ matrix.unity-version }}"
- name: Run Smoke Test
run: ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Smoke
- name: Run Crash Test
run: ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Crash
android-smoke-test-run:
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
needs: [mobile-smoke-test-compile]
name: ${{ matrix.unity-version }} Android ${{ matrix.api-level }} Run Smoke Test
uses: ./.github/workflows/android-smoke-test-wrapper.yml
with:
unity-version: ${{ matrix.unity-version }}
api-level: ${{ matrix.api-level }}
strategy:
fail-fast: false
matrix:
api-level: [27, 28, 29, 30, 31] # last updated October 2022
unity-version: ['2019', '2020', '2021', '2022']
include:
# API 21 is barely used but let's check it as the minimum supported version for now.
- api-level: 21
unity-version: '2019'
exclude:
# Seems like there's an error in Unity with Android API 30 - disabling.
# https://github.com/getsentry/sentry-unity/issues/719#issuecomment-1129129952
- api-level: 30
unity-version: '2021'
- api-level: 30
unity-version: '2022'
mobile-smoke-test-compile:
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
needs: [smoke-test-build]
name: ${{ matrix.unity-version }} ${{ matrix.platform }} Compile Smoke Test
runs-on: ${{ matrix.platform == 'iOS' && 'macos' || 'ubuntu' }}-latest
strategy:
fail-fast: false
matrix:
unity-version: ['2019', '2020', '2021', '2022']
platform: ['Android', 'iOS']
include:
# See supported version in https://docs.unity3d.com/2022.2/Documentation/Manual/android-sdksetup.html
- unity-version: '2019'
ndk: 'r19'
- unity-version: '2020'
ndk: 'r19'
- unity-version: '2021'
ndk: 'r21d'
- unity-version: '2022'
ndk: 'r21d'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download app project
uses: actions/download-artifact@v3
with:
name: testapp-${{ matrix.platform }}-${{ matrix.unity-version }}
- name: Extract app project
run: tar -xvzf test-app.tar.gz
- uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc # pin@v2
if: ${{ matrix.platform == 'Android' && github.ref_name != 'main' }}
- uses: nttld/setup-ndk@8c3b609ff4d54576ea420551943fd34b4d03b0dc # pin@v1
if: ${{ matrix.platform == 'Android' && github.ref_name != 'main' }}
id: setup-ndk
with:
ndk-version: ${{ matrix.ndk }}
add-to-path: false
- name: Build app
if: ${{ matrix.platform != 'Android' || github.ref_name != 'main' }}
run: |
if ("${{ matrix.platform }}" -eq "Android")
{
# Replace local.properties so that it doesn't reference Unity built-in SDK & NDK (not available in this job).
@("sdk.dir=$($env:ANDROID_SDK_ROOT)", "ndk.dir=${{ steps.setup-ndk.outputs.ndk-path }}") | Out-File "samples/IntegrationTest/Build/local.properties"
# The template changed with 2022 to have set the 'ndkPath' directly in the build.gradle. Removing it fall back to the local.properties
if ("${{ matrix.unity-version }}" -eq "2022")
{
$file = "samples/IntegrationTest/Build/unityLibrary/build.gradle"
Get-Content $file | Where-Object { $_ -notmatch'ndkPath ".*/AndroidPlayer/NDK"' } | Set-Content $file 
}
}
./scripts/smoke-test-${{ matrix.platform == 'iOS' && 'ios' || 'android' }}.ps1 Build -IsIntegrationTest -UnityVersion "${{ matrix.unity-version }}"
- name: Upload app
uses: actions/upload-artifact@v3
with:
name: testapp-${{ matrix.platform }}-compiled-${{ matrix.unity-version }}
# Collect app but ignore the files that are not required for the test.
path: |
samples/IntegrationTest/Build/*.apk
samples/IntegrationTest/Build/archive/Unity-iPhone/Build/Products/Release-iphonesimulator/
!**/Release-iphonesimulator/*.dSYM
!**/Release-iphonesimulator/UnityFramework.framework/*
# Lower retention period - we only need this to retry CI.
retention-days: 14
ios-smoke-test-run:
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
needs: [mobile-smoke-test-compile]
name: ${{ matrix.unity-version }} iOS ${{ matrix.ios }} Run Smoke Test
runs-on: macos-12
strategy:
fail-fast: false
matrix:
unity-version: ['2019', '2020', '2021', '2022']
# Check https://support.apple.com/en-us/HT201222 for the latest minor version for a given major one.
# https://developer.apple.com/support/app-store/ shows that of all iOS devices
# - `iOS 16`: 71%
# - `iOS 15`: 20 %
# - the rest: 8 %
# as of May 2, 2023. Therefore, let's stick to testing iOS 15 and `latest` for now.
# Numbers as string otherwise GH will reformat the runtime numbers removing the fractions.
# Also make sure to match the versions available here:
# - https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
ios: ['15.4', latest] # last updated May 2023
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download app artifact
uses: actions/download-artifact@v3
with:
name: testapp-iOS-compiled-${{ matrix.unity-version }}
path: samples/IntegrationTest/Build
- name: Setup xcode-install
# Github Virtual machine already sets the runtime and simulator for the latest release.
if: ${{ matrix.ios != 'latest'}}
run: gem install xcode-install
- name: Setup ${{matrix.ios}} runtime
if: ${{ matrix.ios != 'latest'}}
run: xcversion simulators --install='iOS ${{matrix.ios}}'
- name: Setup ${{matrix.ios}} Simulator
if: ${{ matrix.ios != 'latest' }}
# We need to setup an simulator in order to xCode to populate the simulators for the given runtime.
run: xcrun simctl create InitialSimulator "iPhone 8" "iOS${{ matrix.ios }}"
- name: Smoke test
id: smoke-test-ios
timeout-minutes: 10
run: |
$runtime = "${{ matrix.ios }}"
If ($runtime -ne "latest")
{
$runtime = "iOS " + $runtime
}
./Scripts/smoke-test-ios.ps1 Test "$runtime" -IsIntegrationTest
smoke-test-run:
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
needs: [smoke-test-build]
name: ${{ matrix.unity-version }} ${{ matrix.platform }} Run Smoke Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
unity-version: ['2019', '2020', '2021', '2022']
platform: ['WebGL', 'Linux']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download test app artifact
uses: actions/download-artifact@v3
id: download
with:
name: testapp-${{ matrix.platform }}-${{ matrix.unity-version }}
- name: Extract test app
run: tar -xvzf test-app.tar.gz
- name: Run (WebGL)
if: ${{ matrix.platform == 'WebGL' }}
timeout-minutes: 10
run: |
pip3 install --upgrade --user selenium urllib3 requests
python3 scripts/smoke-test-webgl.py "samples/IntegrationTest/Build"
- name: Run Smoke Test (Linux)
if: ${{ matrix.platform == 'Linux' }}
run: ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Smoke
- name: Run Crash Test (Linux)
if: ${{ matrix.platform == 'Linux' }}
run: ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Crash