|
| 1 | +#@ load("@ytt:template", "template") |
| 2 | +#@ load("common.lib.yml", "uploadArtifacts", "actionDownloadArtifact", "checkoutCode") |
| 3 | +#@ load("test.lib.yml", "publishTestsResults") |
| 4 | + |
| 5 | +#@ unityPkgName = "io.realm.unity-${{ inputs.version }}.tgz" |
| 6 | + |
| 7 | +--- |
| 8 | +name: test-unity |
| 9 | +"on": |
| 10 | + workflow_call: |
| 11 | + inputs: |
| 12 | + version: |
| 13 | + type: string |
| 14 | + required: true |
| 15 | + platform: |
| 16 | + type: string |
| 17 | + required: true |
| 18 | + settings: |
| 19 | + type: string |
| 20 | + required: true |
| 21 | +env: |
| 22 | + REALM_DISABLE_ANALYTICS: true |
| 23 | + DOTNET_NOLOGO: true |
| 24 | +jobs: |
| 25 | + build-tests: |
| 26 | + runs-on: |
| 27 | + - unity |
| 28 | + - ${{ matrix.platform.os }} |
| 29 | + name: Build Unity ${{ matrix.platform.os }} |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + platform: ${{ fromJson(inputs.platform) }} |
| 34 | + settings: ${{ fromJson(inputs.settings) }} |
| 35 | + timeout-minutes: 30 |
| 36 | + steps: |
| 37 | + - #@ template.replace(checkoutCode()) |
| 38 | + - name: Cleanup Workspace |
| 39 | + run: git clean -fdx |
| 40 | + - name: Fetch Unity Package |
| 41 | + uses: #@ actionDownloadArtifact |
| 42 | + with: |
| 43 | + name: #@ unityPkgName |
| 44 | + path: Realm/Realm.Unity |
| 45 | + - name: Fetch Unity Tests |
| 46 | + uses: #@ actionDownloadArtifact |
| 47 | + with: |
| 48 | + name: UnityTests |
| 49 | + path: Tests/Tests.Unity |
| 50 | + - name: Build Unity Tests |
| 51 | + run: | |
| 52 | + unity-editor -runTests -batchmode -projectPath ${{ github.workspace }}/Tests/Tests.Unity -testPlatform Standalone${{ matrix.platform.testPlatform }} -testSettingsFile ${{ github.workspace }}/Tests/Tests.Unity/.TestConfigs/${{ matrix.settings }}.json -logFile ${{ matrix.platform.os == 'windows' && 'build.log' || '-'}} |
| 53 | + - #@ uploadArtifacts("UnityTestsRunner.${{ matrix.platform.os }}", "Tests/Tests.Unity/Player_Standalone${{ matrix.platform.testPlatform }}_${{ matrix.settings }}/") |
| 54 | + |
| 55 | + run-tests-linux: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + name: Unity Linux |
| 58 | + timeout-minutes: 30 |
| 59 | + needs: |
| 60 | + - build-tests |
| 61 | + if: ${{ contains(inputs.platform, 'Linux') }} |
| 62 | + steps: |
| 63 | + - #@ template.replace(checkoutCode()) |
| 64 | + - name: Download Test Runner |
| 65 | + uses: #@ actionDownloadArtifact |
| 66 | + with: |
| 67 | + name: UnityTestsRunner.linux |
| 68 | + path: TestRunner |
| 69 | + - name: Install xvfb |
| 70 | + run: sudo apt install -y xvfb libglu1 libxcursor1 |
| 71 | + - name: Run Tests |
| 72 | + run: | |
| 73 | + chmod +x ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 |
| 74 | + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24:32' ${{ github.workspace }}/TestRunner/PlayerWithTests.x86_64 -logFile - --result=${{ github.workspace }}/TestResults.xml |
| 75 | + - #@ publishTestsResults("TestResults.xml", "Unity Linux Mono_Net4") |
| 76 | + |
| 77 | + run-tests-windows: |
| 78 | + runs-on: windows-latest |
| 79 | + name: Unity Windows |
| 80 | + if: ${{ contains(inputs.platform, 'Windows') }} |
| 81 | + timeout-minutes: 30 |
| 82 | + needs: |
| 83 | + - build-tests |
| 84 | + steps: |
| 85 | + - #@ template.replace(checkoutCode()) |
| 86 | + - name: Download Test Runner |
| 87 | + uses: #@ actionDownloadArtifact |
| 88 | + with: |
| 89 | + name: UnityTestsRunner.windows |
| 90 | + path: TestRunner |
| 91 | + - name: Run Tests |
| 92 | + run: | |
| 93 | + Start-Process ${{ github.workspace }}\TestRunner\PlayerWithTests.exe -Wait -ArgumentList "-logFile","${{ github.workspace }}\test.log","--result=${{ github.workspace }}\TestResults.xml" |
| 94 | + cat ${{ github.workspace }}\test.log |
| 95 | + shell: powershell |
| 96 | + - #@ publishTestsResults("TestResults.xml", "Unity Windows Mono_Net4") |
0 commit comments