|
| 1 | +name: "Test: Build macOS" |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + unity-version: |
| 6 | + required: true |
| 7 | + type: string |
| 8 | + |
| 9 | +defaults: |
| 10 | + run: |
| 11 | + shell: pwsh |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: macOS ${{ inputs.unity-version }} |
| 16 | + runs-on: macos-latest |
| 17 | + env: |
| 18 | + UNITY_VERSION: ${{ inputs.unity-version }} |
| 19 | + BUILD_PLATFORM: MacOS |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 24 | + |
| 25 | + - name: Load env |
| 26 | + id: env |
| 27 | + run: | |
| 28 | + $u = (Get-Content scripts/unity-versions.json -Raw | ConvertFrom-Json).'${{ env.UNITY_VERSION }}' |
| 29 | + "unityVersion=$($u.version)" >> $env:GITHUB_OUTPUT |
| 30 | + "unityChangeset=$($u.changeset)" >> $env:GITHUB_OUTPUT |
| 31 | +
|
| 32 | + - name: Setup Unity |
| 33 | + uses: getsentry/setup-unity@1bbd385ae3b0505069aacc56d47f0a16366f10b1 |
| 34 | + with: |
| 35 | + unity-version: ${{ steps.env.outputs.unityVersion }} |
| 36 | + unity-version-changeset: ${{ steps.env.outputs.unityChangeset }} |
| 37 | + unity-modules: mac-il2cpp |
| 38 | + |
| 39 | + - name: Create Unity license config |
| 40 | + run: | |
| 41 | + sudo mkdir -p "/Library/Application Support/Unity/config" |
| 42 | + echo "$env:UNITY_LICENSE_SERVER_CONFIG" | sudo tee "/Library/Application Support/Unity/config/services-config.json" > /dev/null |
| 43 | + env: |
| 44 | + UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }} |
| 45 | + |
| 46 | + - name: Download IntegrationTest project |
| 47 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 48 | + with: |
| 49 | + name: test-${{ env.UNITY_VERSION }} |
| 50 | + |
| 51 | + - name: Extract project archive |
| 52 | + run: tar -xvzf test-project.tar.gz |
| 53 | + |
| 54 | + - name: Cache Unity Library |
| 55 | + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 56 | + with: |
| 57 | + path: samples/IntegrationTest/Library |
| 58 | + key: Library-IntegrationTest-macos-${{ env.UNITY_VERSION }}-v1 |
| 59 | + restore-keys: | |
| 60 | + Library-IntegrationTest-macos-${{ env.UNITY_VERSION }}- |
| 61 | + Library-IntegrationTest-macos- |
| 62 | +
|
| 63 | + - name: Restore cached build without Sentry |
| 64 | + id: cache-build-nosentry |
| 65 | + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
| 66 | + with: |
| 67 | + path: samples/IntegrationTest/Build-NoSentry |
| 68 | + key: build-nosentry-MacOS-${{ inputs.unity-version }} |
| 69 | + |
| 70 | + - name: Build without Sentry SDK |
| 71 | + if: steps.cache-build-nosentry.outputs.cache-hit != 'true' |
| 72 | + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS -BuildDirName "Build-NoSentry" |
| 73 | + |
| 74 | + - name: Download UPM package |
| 75 | + uses: ./.github/actions/wait-for-artifact |
| 76 | + with: |
| 77 | + name: package-release |
| 78 | + |
| 79 | + - name: Extract UPM package |
| 80 | + run: ./test/Scripts.Integration.Test/extract-package.ps1 |
| 81 | + |
| 82 | + - name: Add Sentry to the project |
| 83 | + run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "$env:UNITY_PATH" -PackagePath "test-package-release" |
| 84 | + |
| 85 | + - name: Configure Sentry |
| 86 | + run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS |
| 87 | + env: |
| 88 | + SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }} |
| 89 | + |
| 90 | + - name: Build with Sentry SDK |
| 91 | + run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS -UnityVersion "$env:UNITY_VERSION" |
| 92 | + |
| 93 | + - name: Compare build sizes |
| 94 | + run: ./test/Scripts.Integration.Test/measure-build-size.ps1 -Path1 "samples/IntegrationTest/Build-NoSentry" -Path2 "samples/IntegrationTest/Build" -Platform MacOS -UnityVersion "$env:UNITY_VERSION" |
| 95 | + |
| 96 | + - name: Upload build size measurement |
| 97 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 98 | + with: |
| 99 | + name: build-size-MacOS-${{ env.UNITY_VERSION }} |
| 100 | + path: build-size-measurements/*.json |
| 101 | + retention-days: 1 |
| 102 | + |
| 103 | + # We create tar explicitly because upload-artifact is slow for many files. |
| 104 | + - name: Create archive |
| 105 | + run: | |
| 106 | + Remove-Item -Recurse -Force samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame -ErrorAction SilentlyContinue |
| 107 | + tar -cvzf test-app-desktop.tar.gz samples/IntegrationTest/Build |
| 108 | +
|
| 109 | + - name: Upload test app |
| 110 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 111 | + with: |
| 112 | + name: testapp-desktop-compiled-${{ env.UNITY_VERSION }}-macos |
| 113 | + if-no-files-found: error |
| 114 | + path: test-app-desktop.tar.gz |
| 115 | + retention-days: 14 |
| 116 | + |
| 117 | + - name: Upload IntegrationTest project on failure |
| 118 | + if: ${{ failure() }} |
| 119 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 120 | + with: |
| 121 | + name: failed-project-desktop-macos-${{ env.UNITY_VERSION }} |
| 122 | + path: | |
| 123 | + samples/IntegrationTest |
| 124 | + unity.log |
| 125 | + !samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame |
| 126 | + retention-days: 14 |
0 commit comments