diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94ca1885c..3a232c37d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,517 +1,25 @@ name: "CI" + on: push: branches: - main - release/* + - fix/linux-6.5-line-numbers pull_request: paths-ignore: - "**.md" - "**.txt" - workflow_dispatch: # e.g. to manually trigger on foreign PRs - -env: - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_NOLOGO: 1 - -defaults: - run: - shell: pwsh + workflow_dispatch: jobs: - cancel-previous-workflow: - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@d07a454dad7609a92316b57b23c9ccfd4f59af66 # 0.13.1 - with: - access_token: ${{ github.token }} - - create-unity-matrix: - uses: ./.github/workflows/create-unity-matrix.yml + linux-il2cpp-diagnostics: + name: Linux IL2CPP diagnostics + uses: ./.github/workflows/linux-il2cpp-line-number-diagnostics.yml with: - event-name: ${{ github.event_name }} - head-ref: ${{ github.head_ref }} - - sdk: - strategy: - matrix: - include: - - target: Android - host: ubuntu-latest - - target: Linux - host: ubuntu-latest - - target: LinuxNative - host: ubuntu-latest - - target: Windows - host: windows-latest - - target: WindowsNative - host: windows-latest - - target: Cocoa - host: macos-latest - - target: MacOSNative - host: macos-latest - uses: ./.github/workflows/sdk.yml - with: - target: ${{ matrix.target }} - runsOn: ${{ matrix.host }} - - build-unity-sdk: - name: Build Unity SDK - secrets: - UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} - permissions: - actions: read - checks: write - contents: read - strategy: - fail-fast: false - matrix: - # Building the SDK with Unity 2022 and newer requires ns2.1 - skipping for now - unity-version: ["2021.3"] - uses: ./.github/workflows/build.yml - with: - unity-version: ${{ matrix.unity-version }} - - package-validation: - name: UPM Package validation - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: ${{ github.head_ref || github.ref }} - ssh-key: ${{ secrets.CI_DEPLOY_KEY }} - - - name: Download UPM package - uses: ./.github/actions/wait-for-artifact - with: - name: package-release - - - name: Check snapshot - id: snapshot-check - shell: pwsh - run: | - $ErrorActionPreference = 'Continue' - & ./test/Scripts.Tests/test-pack-contents.ps1 - "result=$LASTEXITCODE" >> $env:GITHUB_OUTPUT - - - name: Update snapshot for dependency bumps - if: steps.snapshot-check.outputs.result != '0' && github.event_name == 'pull_request' && startsWith(github.head_ref, 'deps/') - run: | - ./test/Scripts.Tests/test-pack-contents.ps1 accept - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add test/Scripts.Tests/package-release.zip.snapshot - git commit -m "Update package release snapshot" - git push - - - name: Fail on unexpected snapshot changes - if: steps.snapshot-check.outputs.result != '0' && !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'deps/')) - run: | - Write-Error "Package contents do not match snapshot. Run './test/Scripts.Tests/test-pack-contents.ps1 accept' locally and commit the update." - exit 1 - - # This produces the `samples/IntegrationTest` as `test-${{ matrix.unity-version }}`. - test-create: - name: Create ${{ matrix.unity-version }} Test Project - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [create-unity-matrix] + backend: native + unitylinker-additional-args: "" secrets: UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} - strategy: - fail-fast: false - matrix: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix) }} - uses: ./.github/workflows/test-create.yml - with: - unity-version: ${{ matrix.unity-version }} - - # A Linux, docker-based build to prepare a WebGL player. The tests run in `test-run-webgl`. - test-build-webgl: - name: Build ${{ matrix.platform }} ${{ matrix.unity-version }} Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-create, create-unity-matrix] - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - platform: ["WebGL"] - include: - - platform: WebGL - build_platform: WebGL - env: - UNITY_PATH: docker exec unity unity-editor - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - 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: Docker Login - uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Start the Unity docker container - run: ./scripts/ci-docker.sh "$UNITY_VERSION" "$PLATFORM_WITH_SUFFIX" "$UNITY_LICENSE_SERVER_CONFIG" - shell: bash - env: - UNITY_VERSION: ${{ matrix.unity-version }} - PLATFORM: ${{ matrix.platform }} - IMAGE_SUFFIX: ${{ matrix.image-suffix }} - PLATFORM_WITH_SUFFIX: ${{ matrix.platform }}${{ matrix.image-suffix }} - UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} - - - name: Download IntegrationTest project - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: test-${{ matrix.unity-version }} - - - name: Extract project archive - run: tar -xvzf test-project.tar.gz - - - name: Restore Unity Library cache - uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: samples/IntegrationTest/Library - key: it-library-ubuntu-${{ matrix.unity-version }}-${{ github.run_id }} - restore-keys: | - it-library-ubuntu-${{ matrix.unity-version }}- - - - name: Restore cached build without Sentry - id: cache-build-nosentry - uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: samples/IntegrationTest/Build-NoSentry - key: build-nosentry-${{ matrix.build_platform }}-${{ matrix.unity-version }} - - - name: Build without Sentry SDK - if: steps.cache-build-nosentry.outputs.cache-hit != 'true' - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -BuildDirName "Build-NoSentry" - env: - BUILD_PLATFORM: ${{ matrix.build_platform }} - - - name: Save cached build without Sentry - if: github.ref == 'refs/heads/main' && steps.cache-build-nosentry.outputs.cache-hit != 'true' - uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 - with: - path: samples/IntegrationTest/Build-NoSentry - key: build-nosentry-${{ matrix.build_platform }}-${{ matrix.unity-version }} - - - name: Download UPM package - uses: ./.github/actions/wait-for-artifact - with: - name: package-release - - - name: Extract UPM package - run: ./test/Scripts.Integration.Test/extract-package.ps1 - - - name: Add Sentry to the project - run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "$env:UNITY_PATH" -PackagePath "test-package-release" - - - name: Download DependencyConflict package - uses: ./.github/actions/wait-for-artifact - with: - name: dependency-conflict-package - path: dependency-conflict-package - - - name: Add DependencyConflict to the project - if: ${{ !startsWith(matrix.unity-version, '2021') }} - run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -PackagePath "dependency-conflict-package" - - - name: Disable DependencyConflict (WebGL 2021) - if: ${{ startsWith(matrix.unity-version, '2021') }} - run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -Disable - - - name: Configure Sentry - run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" - env: - BUILD_PLATFORM: ${{ matrix.build_platform }} - SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} - - - name: Build Project - run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -UnityVersion "$env:UNITY_VERSION" - env: - BUILD_PLATFORM: ${{ matrix.build_platform }} - UNITY_VERSION: ${{ matrix.unity-version }} - - - name: Compare build sizes - run: ./test/Scripts.Integration.Test/measure-build-size.ps1 -Path1 "samples/IntegrationTest/Build-NoSentry" -Path2 "samples/IntegrationTest/Build" -Platform "$env:BUILD_PLATFORM" -UnityVersion "$env:UNITY_VERSION" - env: - BUILD_PLATFORM: ${{ matrix.build_platform }} - UNITY_VERSION: ${{ matrix.unity-version }} - - - name: Upload build size measurement - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: build-size-${{ matrix.platform }}-${{ matrix.unity-version }} - path: build-size-measurements/*.json - retention-days: 1 - - # We create tar explicitly because upload-artifact is slow for many files. - - name: Create archive - run: | - Remove-Item -Recurse -Force samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame -ErrorAction SilentlyContinue - Copy-Item -Force unity.log samples/IntegrationTest/Build/ -ErrorAction SilentlyContinue - tar -cvzf test-app-webgl.tar.gz samples/IntegrationTest/Build - - - name: Upload test app - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: testapp-webgl-compiled-${{ matrix.unity-version }} - if-no-files-found: error - path: test-app-webgl.tar.gz - retention-days: 14 - - # Library cache for the shared `ubuntu` flavour is written only by the Linux job - # (see test-build-linux.yml) - the other ubuntu targets are restore-only. - - name: Upload IntegrationTest project on failure - if: ${{ failure() }} - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - 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 - - test-build-android: - name: Build Android ${{ matrix.unity-version }} Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-create, create-unity-matrix] - secrets: - UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix) }} - uses: ./.github/workflows/test-build-android.yml - with: - unity-version: ${{ matrix.unity-version }} - - test-run-android: - name: Run Android ${{ matrix.unity-version }} Integration Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-build-android, create-unity-matrix] - secrets: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - uses: ./.github/workflows/test-run-android.yml - with: - unity-version: ${{ matrix.unity-version }} - api-level: ${{ matrix.api-level }} - init-type: ${{ matrix.init-type }} - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - # api-level: [30, 31, 34] - api-level: [30] - init-type: ["runtime", "buildtime"] - - test-build-ios: - name: Build iOS ${{ matrix.unity-version }} Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-create, create-unity-matrix] - secrets: - UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix) }} - uses: ./.github/workflows/test-build-ios.yml - with: - unity-version: ${{ matrix.unity-version }} - - test-compile-ios: - name: Compile iOS ${{ matrix.unity-version }} Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-build-ios, create-unity-matrix] - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - init-type: ["runtime", "buildtime"] - uses: ./.github/workflows/test-compile-ios.yml - with: - unity-version: ${{ matrix.unity-version }} - init-type: ${{ matrix.init-type }} - - test-run-ios: - name: Run iOS ${{ matrix.unity-version }} Integration Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-compile-ios, create-unity-matrix] - uses: ./.github/workflows/test-run-ios.yml - with: - unity-version: ${{ matrix.unity-version }} - ios-version: ${{ matrix.ios-version }} - init-type: ${{ matrix.init-type }} - secrets: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - # On PRs only the newest simulator runs; `17.0` is an OS-compat axis (not SDK behavior) and runs on main. - ios-version: ${{ github.event_name == 'pull_request' && fromJSON('["latest"]') || fromJSON('["17.0", "latest"]') }} - init-type: ["runtime", "buildtime"] - # 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 18`: 88 % - # - `iOS 17`: 17 % - # - the rest: 4 % - # as of August, 2025. Therefore, let's stick to testing iOS 17 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-14-Readme.md - - test-run-webgl: - name: Run WebGL ${{ matrix.unity-version }} Integration Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-build-webgl, create-unity-matrix] - secrets: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - uses: ./.github/workflows/test-run-webgl.yml - with: - unity-version: ${{ matrix.unity-version }} - - test-build-linux: - name: Build Linux ${{ matrix.unity-version }} Integration Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-create, create-unity-matrix] - secrets: - UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - uses: ./.github/workflows/test-build-linux.yml - with: - unity-version: ${{ matrix.unity-version }} - - test-build-windows: - name: Build Windows ${{ matrix.unity-version }} Integration Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-create, create-unity-matrix] - secrets: - UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - uses: ./.github/workflows/test-build-windows.yml - with: - unity-version: ${{ matrix.unity-version }} - - test-build-macos: - name: Build macOS ${{ matrix.unity-version }} Integration Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-create, create-unity-matrix] - secrets: - UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - uses: ./.github/workflows/test-build-macos.yml - with: - unity-version: ${{ matrix.unity-version }} - - test-run-linux: - name: Run Linux ${{ matrix.backend }} ${{ matrix.unity-version }} Integration Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-build-linux, create-unity-matrix] - secrets: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - backend: ["breakpad", "native"] - uses: ./.github/workflows/test-run-desktop.yml - with: - unity-version: ${{ matrix.unity-version }} - platform: linux - backend: ${{ matrix.backend }} - - test-run-windows: - name: Run Windows ${{ matrix.backend }} ${{ matrix.unity-version }} Integration Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-build-windows, create-unity-matrix] - secrets: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - backend: ["crashpad", "native"] - uses: ./.github/workflows/test-run-desktop.yml - with: - unity-version: ${{ matrix.unity-version }} - platform: windows - backend: ${{ matrix.backend }} - - test-run-macos: - name: Run macOS ${{ matrix.backend }} ${{ matrix.unity-version }} Integration Test - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-build-macos, create-unity-matrix] - secrets: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }} - strategy: - fail-fast: false - matrix: - unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} - backend: ["cocoa", "native"] - uses: ./.github/workflows/test-run-desktop.yml - with: - unity-version: ${{ matrix.unity-version }} - platform: macos - backend: ${{ matrix.backend }} - - build-size-summary: - name: Build Size - runs-on: ubuntu-latest - if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} - needs: [test-build-webgl, test-build-android, test-compile-ios, test-build-linux, test-build-windows, test-build-macos] - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Download all build size measurements - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - pattern: build-size-* - path: build-size-measurements - - - name: Create consolidated summary - shell: pwsh - run: ./scripts/create-build-size-summary.ps1 \ No newline at end of file diff --git a/.github/workflows/linux-il2cpp-line-number-diagnostics.yml b/.github/workflows/linux-il2cpp-line-number-diagnostics.yml new file mode 100644 index 000000000..c56e53329 --- /dev/null +++ b/.github/workflows/linux-il2cpp-line-number-diagnostics.yml @@ -0,0 +1,260 @@ +name: "Linux IL2CPP Line Number Diagnostics" + +on: + workflow_call: + inputs: + backend: + description: "Linux crash-reporting backend to include in the build" + required: false + default: native + type: string + unitylinker-additional-args: + description: "Value supplied to the Unity editor process as UNITYLINKER_ADDITIONAL_ARGS" + required: false + default: "" + type: string + secrets: + UNITY_LICENSE_SERVER_CONFIG: + required: true + SENTRY_AUTH_TOKEN: + required: true + SENTRY_TEST_DSN: + required: true + +env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_NOLOGO: 1 + UNITY_VERSION: "6000.5" + +defaults: + run: + shell: pwsh + +jobs: + sdk: + name: Build Linux ${{ inputs.backend }} SDK + uses: ./.github/workflows/sdk.yml + with: + target: ${{ inputs.backend == 'native' && 'LinuxNative' || 'Linux' }} + runsOn: ubuntu-latest + + package: + name: Build package + needs: sdk + runs-on: ubuntu-22.04 + env: + GITHUB_ACTOR: ${{ github.actor }} + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Free Disk Space + 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 + + - name: Log into Docker + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 + with: + registry: ghcr.io + username: ${{ env.GITHUB_ACTOR }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Start the Unity docker container + run: ./scripts/ci-docker.sh "2021.3" ios "$UNITY_LICENSE_SERVER_CONFIG" + shell: bash + env: + UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} + + - name: Install .NET SDK + uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 + with: + global-json-file: global.json + + - name: Restore .NET workload + run: dotnet workload restore + + - name: Download CLI + run: ./scripts/download-sentry-cli.ps1 + + - name: Download Linux ${{ inputs.backend }} SDK + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: ${{ inputs.backend == 'native' && 'LinuxNative-sdk' || 'Linux-sdk' }} + path: ${{ inputs.backend == 'native' && 'package-dev/Plugins/Linux/SentryNative~' || 'package-dev/Plugins/Linux/Sentry~' }} + + - name: Build Sentry.Unity solution + run: docker exec unity dotnet build -c Release -v:d + + - name: Install assembly alias tool + run: docker exec unity dotnet tool install --global Sentry.AssemblyAlias --version 0.5.0 --allow-roll-forward + + - name: Alias assemblies + run: docker exec unity pwsh scripts/alias-assemblies.ps1 -AssemblyAlias /home/gh/.dotnet/tools/assemblyalias + + - name: Package for diagnostics + run: | + docker exec unity dotnet msbuild /t:UnityConfigureSentryOptions /p:Configuration=Release /p:OutDir=other src/Sentry.Unity + ./scripts/pack.ps1 + + - name: Upload package + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: diagnostic-package-release + if-no-files-found: error + path: package-release.zip + + create-project: + name: Create Unity 6000.5 project + needs: package + runs-on: ubuntu-latest + env: + GITHUB_ACTOR: ${{ github.actor }} + UNITY_PATH: docker exec unity unity-editor + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Log into Docker + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 + with: + registry: ghcr.io + username: ${{ env.GITHUB_ACTOR }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Restore IntegrationTest project cache + id: cache-project + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + 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" + + - name: Create project archive + run: tar -cvzf test-project.tar.gz samples/IntegrationTest + + - name: Upload project + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: diagnostic-test-6000.5 + if-no-files-found: error + path: test-project.tar.gz + + build: + name: Build Linux IL2CPP + needs: [package, create-project] + runs-on: ubuntu-latest + env: + GITHUB_ACTOR: ${{ github.actor }} + UNITY_PATH: docker exec unity unity-editor + UNITYLINKER_ADDITIONAL_ARGS: ${{ inputs.unitylinker-additional-args }} + SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Free Disk Space + 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: Log into Docker + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 + with: + registry: ghcr.io + username: ${{ env.GITHUB_ACTOR }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Start the Unity docker container + run: ./scripts/ci-docker.sh "$UNITY_VERSION" Linux-il2cpp "$UNITY_LICENSE_SERVER_CONFIG" + shell: bash + env: + UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} + + - name: Download IntegrationTest project + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: diagnostic-test-6000.5 + + - name: Extract project archive + run: tar -xvzf test-project.tar.gz + + - name: Restore Unity Library cache + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: samples/IntegrationTest/Library + key: it-library-ubuntu-${{ env.UNITY_VERSION }}-${{ github.run_id }} + restore-keys: | + it-library-ubuntu-${{ env.UNITY_VERSION }}- + + - name: Download UPM package + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: diagnostic-package-release + + - name: Extract UPM package + run: ./test/Scripts.Integration.Test/extract-package.ps1 + + - name: Add Sentry to the project + run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "$env:UNITY_PATH" -PackagePath test-package-release + + - name: Disable DependencyConflict fixture + run: ./test/Scripts.Integration.Test/add-dependency-conflict.ps1 -Disable + + - name: Select Linux backend + run: | + if ('${{ inputs.backend }}' -eq 'native') { + $optionsPath = 'samples/IntegrationTest/Assets/Scripts/IntegrationOptionsConfiguration.cs' + (Get-Content $optionsPath -Raw) -replace 'LinuxBackend = LinuxBackend.Breakpad', 'LinuxBackend = LinuxBackend.Native' | Set-Content $optionsPath + } + + - name: Configure Sentry + run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform Linux + + - name: Build Linux IL2CPP player + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform Linux -UnityVersion "$env:UNITY_VERSION" + + - name: Verify UnityLinker received --link-symbols + run: | + if (-not (Select-String -Path unity.log -SimpleMatch '--link-symbols' -Quiet)) { + throw 'UnityLinker command did not contain --link-symbols.' + } + + - name: Upload diagnostic artifacts + if: ${{ always() }} + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: linux-il2cpp-diagnostics-${{ inputs.backend }} + if-no-files-found: warn + path: | + unity.log + samples/IntegrationTest/Build/**/LineNumberMappings.json + samples/IntegrationTest/Build/**/GameAssembly.debug + samples/IntegrationTest/Library/Bee/artifacts/**/il2cppOutput/** + retention-days: 14 diff --git a/scripts/ci-docker.sh b/scripts/ci-docker.sh index a9330c0b1..27b922888 100755 --- a/scripts/ci-docker.sh +++ b/scripts/ci-docker.sh @@ -44,6 +44,7 @@ docker run -td --name $container \ -e UNITY_VERSION=$unityVersion \ -e GITHUB_ACTIONS="${GITHUB_ACTIONS}" \ -e SENTRY_AUTH_TOKEN="${SENTRY_AUTH_TOKEN:-}" \ + -e UNITYLINKER_ADDITIONAL_ARGS="${UNITYLINKER_ADDITIONAL_ARGS:-}" \ --workdir /sentry-unity $image # Generate unique machine-id to avoid any hardcoded values and license-fetch congestion diff --git a/src/Sentry.Unity.Editor/Il2CppBuildPreProcess.cs b/src/Sentry.Unity.Editor/Il2CppBuildPreProcess.cs index ccda18949..3d0ed5354 100644 --- a/src/Sentry.Unity.Editor/Il2CppBuildPreProcess.cs +++ b/src/Sentry.Unity.Editor/Il2CppBuildPreProcess.cs @@ -3,6 +3,7 @@ using UnityEditor; using UnityEditor.Build; using UnityEditor.Build.Reporting; +using UnityEditor.UnityLinker; namespace Sentry.Unity.Editor; @@ -42,11 +43,6 @@ public void OnPreprocessBuild(BuildReport report) { return; } - - UnityLinkerArgumentsBeforeBuild = Environment.GetEnvironmentVariable(UnityLinkerAdditionalArgumentsEnvironmentVariable); - UnityLinkerArgumentsChanged = AddUnityLinkerArgument( - () => UnityLinkerArgumentsBeforeBuild, - arguments => Environment.SetEnvironmentVariable(UnityLinkerAdditionalArgumentsEnvironmentVariable, arguments)); } public void OnPostprocessBuild(BuildReport report) @@ -104,4 +100,41 @@ internal static bool AddUnityLinkerArgument(Func getArguments, Action UnityLinkerArgumentsBeforeBuild, + arguments => Environment.SetEnvironmentVariable(UnityLinkerAdditionalArgumentsEnvironmentVariable, arguments)); + } +} + +public sealed class SentryUnityLinkerProcessor : IUnityLinkerProcessor +{ + public int callbackOrder => 0; + + public string GenerateAdditionalLinkXmlFile(BuildReport report, UnityLinkerBuildPipelineData data) + { + Il2CppBuildPreProcess.AddUnityLinkerArgument(report); + return string.Empty; + } }