diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05e8ba325..f64c3dc5a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,9 +43,9 @@ jobs: - name: Load env id: env - run: echo "unityVersion=$(./scripts/ci-env.ps1 "$env:UNITY_SCRIPT_ARG")" >> $env:GITHUB_OUTPUT - env: - UNITY_SCRIPT_ARG: unity${{ env.UNITY_VERSION }} + run: | + $v = (Get-Content scripts/unity-versions.json -Raw | ConvertFrom-Json).'${{ env.UNITY_VERSION }}'.version + "unityVersion=$v" >> $env:GITHUB_OUTPUT - name: Cache Unity Library uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a9357fc6..0414c8868 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -379,6 +379,19 @@ jobs: 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: inherit + 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.unity-version }} Integration Test if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} @@ -407,11 +420,25 @@ jobs: unity-version: ${{ matrix.unity-version }} platform: windows + test-run-macos: + name: Run macOS ${{ matrix.unity-version }} Integration Test + if: ${{ !startsWith(github.ref, 'refs/heads/release/') }} + needs: [test-build-macos, create-unity-matrix] + secrets: inherit + strategy: + fail-fast: false + matrix: + unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }} + uses: ./.github/workflows/test-run-desktop.yml + with: + unity-version: ${{ matrix.unity-version }} + platform: macos + 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] + 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 diff --git a/.github/workflows/test-build-macos.yml b/.github/workflows/test-build-macos.yml new file mode 100644 index 000000000..300b9f517 --- /dev/null +++ b/.github/workflows/test-build-macos.yml @@ -0,0 +1,126 @@ +name: "Test: Build macOS" +on: + workflow_call: + inputs: + unity-version: + required: true + type: string + +defaults: + run: + shell: pwsh + +jobs: + build: + name: macOS ${{ inputs.unity-version }} + runs-on: macos-latest + env: + UNITY_VERSION: ${{ inputs.unity-version }} + BUILD_PLATFORM: MacOS + + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Load env + id: env + run: | + $u = (Get-Content scripts/unity-versions.json -Raw | ConvertFrom-Json).'${{ env.UNITY_VERSION }}' + "unityVersion=$($u.version)" >> $env:GITHUB_OUTPUT + "unityChangeset=$($u.changeset)" >> $env:GITHUB_OUTPUT + + - name: Setup Unity + uses: getsentry/setup-unity@1bbd385ae3b0505069aacc56d47f0a16366f10b1 + with: + unity-version: ${{ steps.env.outputs.unityVersion }} + unity-version-changeset: ${{ steps.env.outputs.unityChangeset }} + unity-modules: mac-il2cpp + + - name: Create Unity license config + run: | + sudo mkdir -p "/Library/Application Support/Unity/config" + echo "$env:UNITY_LICENSE_SERVER_CONFIG" | sudo tee "/Library/Application Support/Unity/config/services-config.json" > /dev/null + env: + UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} + + - name: Download IntegrationTest project + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: test-${{ env.UNITY_VERSION }} + + - name: Extract project archive + run: tar -xvzf test-project.tar.gz + + - name: Cache Unity Library + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: samples/IntegrationTest/Library + key: Library-IntegrationTest-macos-${{ env.UNITY_VERSION }}-v1 + restore-keys: | + Library-IntegrationTest-macos-${{ env.UNITY_VERSION }}- + Library-IntegrationTest-macos- + + - name: Restore cached build without Sentry + id: cache-build-nosentry + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: samples/IntegrationTest/Build-NoSentry + key: build-nosentry-MacOS-${{ inputs.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 MacOS -BuildDirName "Build-NoSentry" + + - 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: Configure Sentry + run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS + env: + SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} + + - name: Build with Sentry SDK + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS -UnityVersion "$env: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 MacOS -UnityVersion "$env:UNITY_VERSION" + + - name: Upload build size measurement + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: build-size-MacOS-${{ env.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 + tar -cvzf test-app-desktop.tar.gz samples/IntegrationTest/Build + + - name: Upload test app + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: testapp-desktop-compiled-${{ env.UNITY_VERSION }}-macos + if-no-files-found: error + path: test-app-desktop.tar.gz + retention-days: 14 + + - name: Upload IntegrationTest project on failure + if: ${{ failure() }} + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: failed-project-desktop-macos-${{ env.UNITY_VERSION }} + path: | + samples/IntegrationTest + unity.log + !samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame + retention-days: 14 diff --git a/.github/workflows/test-build-windows.yml b/.github/workflows/test-build-windows.yml index 62a954194..8a66701f7 100644 --- a/.github/workflows/test-build-windows.yml +++ b/.github/workflows/test-build-windows.yml @@ -24,12 +24,16 @@ jobs: - name: Load env id: env - run: echo "unityVersion=$(./scripts/ci-env.ps1 "unity$env:UNITY_VERSION")" >> $env:GITHUB_OUTPUT + run: | + $u = (Get-Content scripts/unity-versions.json -Raw | ConvertFrom-Json).'${{ env.UNITY_VERSION }}' + "unityVersion=$($u.version)" >> $env:GITHUB_OUTPUT + "unityChangeset=$($u.changeset)" >> $env:GITHUB_OUTPUT - name: Setup Unity - uses: getsentry/setup-unity@3bdc8c022b6d30ecf2d21d12a564bfa55a54fa2e + uses: getsentry/setup-unity@1bbd385ae3b0505069aacc56d47f0a16366f10b1 with: unity-version: ${{ steps.env.outputs.unityVersion }} + unity-version-changeset: ${{ steps.env.outputs.unityChangeset }} unity-modules: windows-il2cpp - name: Create Unity license config diff --git a/.github/workflows/test-run-desktop.yml b/.github/workflows/test-run-desktop.yml index 073232604..771c60c0a 100644 --- a/.github/workflows/test-run-desktop.yml +++ b/.github/workflows/test-run-desktop.yml @@ -8,7 +8,7 @@ on: platform: required: true type: string - description: "linux or windows" + description: "linux, windows, or macos" defaults: run: @@ -17,7 +17,7 @@ defaults: jobs: run: name: ${{ inputs.platform }} ${{ inputs.unity-version }} - runs-on: ${{ inputs.platform == 'linux' && 'ubuntu-latest' || 'windows-latest' }} + runs-on: ${{ inputs.platform == 'linux' && 'ubuntu-latest' || inputs.platform == 'macos' && 'macos-latest' || 'windows-latest' }} env: SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} @@ -43,6 +43,11 @@ jobs: run: chmod +x samples/IntegrationTest/Build/test shell: bash + - name: Set executable permission (macOS) + if: inputs.platform == 'macos' + run: chmod +x samples/IntegrationTest/Build/test.app/Contents/MacOS/IntegrationTest + shell: bash + - name: Run Integration Tests (Linux) if: inputs.platform == 'linux' timeout-minutes: 20 @@ -53,6 +58,14 @@ jobs: Invoke-Pester -Path test/IntegrationTest/Integration.Tests.ps1 -CI' shell: bash + - name: Run Integration Tests (macOS) + if: inputs.platform == 'macos' + timeout-minutes: 20 + run: | + $env:SENTRY_TEST_PLATFORM = "Desktop" + $env:SENTRY_TEST_APP = "samples/IntegrationTest/Build/test.app/Contents/MacOS/IntegrationTest" + Invoke-Pester -Path test/IntegrationTest/Integration.Tests.ps1 -CI + - name: Run Integration Tests (Windows) if: inputs.platform == 'windows' timeout-minutes: 20 diff --git a/.github/workflows/update-deps.yml b/.github/workflows/update-deps.yml index c5d40ffaa..5c5c13807 100644 --- a/.github/workflows/update-deps.yml +++ b/.github/workflows/update-deps.yml @@ -60,12 +60,14 @@ jobs: with: ssh-key: ${{ secrets.CI_DEPLOY_KEY }} - - name: Update ci-env.ps1 + - name: Update unity-versions.json run: | - $file = "scripts/ci-env.ps1" - $regexVersion = '${{ matrix.unity-prefix }}' + "\.[0-9]+[a-z][0-9]+" - echo "Regex: $regexVersion" - (Get-Content $file) -replace $regexVersion, '${{ steps.version-select.outputs.version }}' | Out-File $file + $file = "scripts/unity-versions.json" + $data = Get-Content $file -Raw | ConvertFrom-Json + $prefix = '${{ matrix.unity-prefix }}' + $data.$prefix.version = '${{ steps.version-select.outputs.version }}' + $data.$prefix.changeset = '${{ steps.version-select.outputs.changeset }}' + $data | ConvertTo-Json -Depth 3 | Set-Content $file - run: git --no-pager diff diff --git a/CLAUDE.md b/CLAUDE.md index f68c3912a..61fb9406d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -131,12 +131,12 @@ The CI system uses modular, reusable workflows in `.github/workflows/`: | 6000.0.x | Yes | Yes | | 6000.1.x | No | Yes | -Version mapping is defined in `scripts/ci-env.ps1`: +Version mapping is defined in `scripts/unity-versions.json` (each entry has a `version` and a `changeset`): - `2021.3` → `2021.3.45f2` -- `2022.3` → `2022.3.70f1` -- `6000.0` → `6000.0.48f1` -- `6000.1` → `6000.1.17f1` +- `2022.3` → `2022.3.62f3` +- `6000.0` → `6000.0.74f1` +- `6000.3` → `6000.3.14f1` ### Docker-Based Builds diff --git a/scripts/ci-docker.sh b/scripts/ci-docker.sh index 1cbde3566..a9330c0b1 100755 --- a/scripts/ci-docker.sh +++ b/scripts/ci-docker.sh @@ -2,7 +2,7 @@ set -euo pipefail unityPrefix="$1" -unityVersion=$(pwsh ./scripts/ci-env.ps1 "unity$unityPrefix") +unityVersion=$(jq -r --arg p "$unityPrefix" '.[$p].version' ./scripts/unity-versions.json) imageVariant=$(echo "$2" | tr '[:upper:]' '[:lower:]') licenseConfig=$3 diff --git a/scripts/ci-env.ps1 b/scripts/ci-env.ps1 deleted file mode 100644 index 298092a58..000000000 --- a/scripts/ci-env.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -param ( - [Parameter()] - [string] $name -) - -switch ($name) { - "unity2021.3" { - return "2021.3.45f2" - } - "unity2022.3" { - return "2022.3.62f3" - } - "unity6000.0" { - return "6000.0.74f1" - } - "unity6000.3" { - return "6000.3.14f1" - } - Default { - throw "Unkown variable '$name'" - } -} diff --git a/scripts/unity-versions.json b/scripts/unity-versions.json new file mode 100644 index 000000000..75fd5646f --- /dev/null +++ b/scripts/unity-versions.json @@ -0,0 +1,18 @@ +{ + "2021.3": { + "version": "2021.3.45f2", + "changeset": "88f88f591b2e" + }, + "2022.3": { + "version": "2022.3.62f3", + "changeset": "96770f904ca7" + }, + "6000.0": { + "version": "6000.0.74f1", + "changeset": "7685f01dc6be" + }, + "6000.3": { + "version": "6000.3.14f1", + "changeset": "d68c3f99a318" + } +}