|
| 1 | +name: Unity Cross-Platform Test Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + types: [opened, synchronize] |
| 8 | + |
| 9 | +jobs: |
| 10 | + buildAndTestForLinuxBasedPlatforms: |
| 11 | + name: Test for ${{ matrix.targetPlatform }} |
| 12 | + runs-on: ubuntu-latest-32 |
| 13 | + concurrency: |
| 14 | + group: Unity-Test-${{ matrix.targetPlatform }}-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + projectPath: |
| 20 | + - "." |
| 21 | + unityVersion: |
| 22 | + - 2022.3.17f1 |
| 23 | + targetPlatform: |
| 24 | + - StandaloneLinux64 # Build a Linux 64-bit standalone. |
| 25 | + - iOS # Build an iOS player. |
| 26 | + - Android # Build an Android player. |
| 27 | + - WebGL # WebGL. |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + lfs: false |
| 33 | + |
| 34 | + - uses: actions/cache@v3 |
| 35 | + with: |
| 36 | + path: ${{ matrix.projectPath }}/Library |
| 37 | + key: |
| 38 | + Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{ |
| 39 | + hashFiles(matrix.projectPath) }} |
| 40 | + restore-keys: | |
| 41 | + Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}- |
| 42 | + Library-${{ matrix.projectPath }}- |
| 43 | + Library- |
| 44 | +
|
| 45 | + - name: Setup Config |
| 46 | + env: |
| 47 | + CLIENT_ID: ${{ secrets.CLIENT_ID }} |
| 48 | + run: | |
| 49 | + mkdir -p Assets/Tests/Resources |
| 50 | + echo '{"clientId": "${{ secrets.CLIENT_ID }}"}' > Assets/Tests/Resources/config.json |
| 51 | + shell: bash |
| 52 | + |
| 53 | + - name: Run Tests |
| 54 | + uses: game-ci/unity-test-runner@v4 |
| 55 | + id: testRunner |
| 56 | + env: |
| 57 | + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} |
| 58 | + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} |
| 59 | + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} |
| 60 | + with: |
| 61 | + artifactsPath: Artifacts/${{ matrix.targetPlatform }} |
| 62 | + projectPath: ${{ matrix.projectPath }} |
| 63 | + unityVersion: ${{ matrix.unityVersion }} |
| 64 | + githubToken: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + testMode: PlayMode # Run PlayMode tests. |
| 66 | + |
| 67 | + - name: Upload Test Results |
| 68 | + uses: actions/upload-artifact@v3 |
| 69 | + if: always() |
| 70 | + with: |
| 71 | + name: TestResults-${{ matrix.targetPlatform }}-${{ github.run_number }} |
| 72 | + path: ${{ steps.testRunner.outputs.artifactsPath }} |
| 73 | + |
| 74 | + - name: Download Test Results |
| 75 | + uses: actions/download-artifact@v3 |
| 76 | + if: always() |
| 77 | + with: |
| 78 | + name: TestResults-${{ matrix.targetPlatform }}-${{ github.run_number }} |
| 79 | + path: ${{ matrix.projectPath }}/TestResults-${{ matrix.targetPlatform }} |
| 80 | + |
| 81 | + - name: Publish Test Results |
| 82 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 83 | + if: always() |
| 84 | + with: |
| 85 | + files: ${{ matrix.projectPath }}/TestResults-${{ matrix.targetPlatform }}/**/*.xml |
| 86 | + check_name: "Test Results for ${{ matrix.targetPlatform }}" |
| 87 | + comment_title: "Test Results for ${{ matrix.targetPlatform }}" |
| 88 | + |
| 89 | + # - uses: jlumbroso/free-disk-space@v1.3.1 |
| 90 | + |
| 91 | + # - uses: game-ci/unity-builder@v4 |
| 92 | + # env: |
| 93 | + # UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} |
| 94 | + # UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} |
| 95 | + # UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} |
| 96 | + # with: |
| 97 | + # projectPath: ${{ matrix.projectPath }} |
| 98 | + # unityVersion: ${{ matrix.unityVersion }} |
| 99 | + # targetPlatform: ${{ matrix.targetPlatform }} |
| 100 | + # allowDirtyBuild: true |
| 101 | + |
| 102 | + # - uses: actions/upload-artifact@v3 |
| 103 | + # with: |
| 104 | + # name: Build-${{ matrix.targetPlatform }}-${{ github.run_number }} |
| 105 | + # path: build |
| 106 | + |
| 107 | + # deploy-webgl-to-gh-pages: |
| 108 | + # needs: buildAndTestForLinuxBasedPlatforms |
| 109 | + # runs-on: ubuntu-latest |
| 110 | + # if: github.ref == 'refs/heads/main' |
| 111 | + # steps: |
| 112 | + # - name: Checkout |
| 113 | + # uses: actions/checkout@v4 |
| 114 | + |
| 115 | + # - name: Download WebGL Build Artifact |
| 116 | + # uses: actions/download-artifact@v3 |
| 117 | + # with: |
| 118 | + # name: Build-WebGL-${{ github.run_number }} |
| 119 | + # path: webgl-build |
| 120 | + |
| 121 | + # - name: Deploy to GitHub Pages |
| 122 | + # uses: JamesIves/github-pages-deploy-action@4.5.0 |
| 123 | + # with: |
| 124 | + # branch: main |
| 125 | + # folder: webgl-build |
| 126 | + # target-folder: docs |
| 127 | + # clean: true |
| 128 | + # commit-message: "Deploy WebGL build to GitHub Pages" |
| 129 | + # env: |
| 130 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 131 | + |
| 132 | + # buildForWindowsBasedPlatforms: |
| 133 | + # name: Build for ${{ matrix.targetPlatform }} |
| 134 | + # runs-on: windows-2022 |
| 135 | + # strategy: |
| 136 | + # fail-fast: false |
| 137 | + # matrix: |
| 138 | + # projectPath: |
| 139 | + # - "" |
| 140 | + # unityVersion: |
| 141 | + # - 2022.3.17f1 |
| 142 | + # targetPlatform: |
| 143 | + # - StandaloneWindows64 # Build a Windows 64-bit standalone. |
| 144 | + |
| 145 | + # steps: |
| 146 | + # - uses: actions/checkout@v4 |
| 147 | + # with: |
| 148 | + # # fetch-depth: 0 |
| 149 | + # lfs: false |
| 150 | + # - uses: actions/cache@v3 |
| 151 | + # with: |
| 152 | + # path: ${{ matrix.projectPath }}/Library |
| 153 | + # key: |
| 154 | + # Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{ |
| 155 | + # hashFiles(matrix.projectPath) }} |
| 156 | + # restore-keys: | |
| 157 | + # Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}- |
| 158 | + # Library-${{ matrix.projectPath }}- |
| 159 | + # Library- |
| 160 | + # - uses: game-ci/unity-builder@v4 |
| 161 | + # env: |
| 162 | + # UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} |
| 163 | + # UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} |
| 164 | + # UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} |
| 165 | + # with: |
| 166 | + # projectPath: ${{ matrix.projectPath }} |
| 167 | + # unityVersion: ${{ matrix.unityVersion }} |
| 168 | + # targetPlatform: ${{ matrix.targetPlatform }} |
| 169 | + # allowDirtyBuild: true |
| 170 | + # - uses: actions/upload-artifact@v3 |
| 171 | + # with: |
| 172 | + # name: Build-${{ matrix.targetPlatform }}-${{ github.run_number }} |
| 173 | + # path: build |
| 174 | + |
| 175 | + # buildForMacOSBasedPlatforms: |
| 176 | + # name: Build for ${{ matrix.targetPlatform }} |
| 177 | + # runs-on: macos-latest |
| 178 | + # strategy: |
| 179 | + # fail-fast: false |
| 180 | + # matrix: |
| 181 | + # projectPath: |
| 182 | + # - "" |
| 183 | + # unityVersion: |
| 184 | + # - 2022.3.17f1 |
| 185 | + # targetPlatform: |
| 186 | + # - StandaloneOSX # Build a macOS standalone. |
| 187 | + |
| 188 | + # steps: |
| 189 | + # - uses: actions/checkout@v4 |
| 190 | + # with: |
| 191 | + # # fetch-depth: 0 |
| 192 | + # lfs: false |
| 193 | + |
| 194 | + # - uses: actions/cache@v3 |
| 195 | + # with: |
| 196 | + # path: ${{ matrix.projectPath }}/Library |
| 197 | + # key: |
| 198 | + # Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{ |
| 199 | + # hashFiles(matrix.projectPath) }} |
| 200 | + # restore-keys: | |
| 201 | + # Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}- |
| 202 | + # Library-${{ matrix.projectPath }}- |
| 203 | + # Library- |
| 204 | + |
| 205 | + # - uses: game-ci/unity-builder@v4 |
| 206 | + # env: |
| 207 | + # UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} |
| 208 | + # UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} |
| 209 | + # UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} |
| 210 | + # with: |
| 211 | + # projectPath: ${{ matrix.projectPath }} |
| 212 | + # unityVersion: ${{ matrix.unityVersion }} |
| 213 | + # targetPlatform: ${{ matrix.targetPlatform }} |
| 214 | + # allowDirtyBuild: true |
| 215 | + |
| 216 | + # - uses: actions/upload-artifact@v3 |
| 217 | + # with: |
| 218 | + # name: Build-${{ matrix.targetPlatform }}-${{ github.run_number }} |
| 219 | + # path: build |
0 commit comments