Repository navigation
Move and expand editor tests, and avoid duplicate CI #91
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: {} | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: read | |
| jobs: | |
| changes: | |
| name: Determine required checks | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| outputs: | |
| unity: ${{ github.event_name == 'workflow_dispatch' && 'true' || steps.filter.outputs.unity }} | |
| steps: | |
| - name: Checkout | |
| if: github.event_name == 'push' | |
| uses: actions/checkout@v4 | |
| - name: Detect Unity changes | |
| id: filter | |
| if: github.event_name != 'workflow_dispatch' | |
| uses: dorny/paths-filter@v4 | |
| with: | |
| filters: | | |
| unity: | |
| - 'Assets/**' | |
| - 'Packages/**' | |
| - 'ProjectSettings/**' | |
| - '.github/actions/setup-unity/**' | |
| - '.github/workflows/tests.yaml' | |
| - '.gitattributes' | |
| test: | |
| name: EditMode on Unity ${{ matrix.unityVersion }} | |
| needs: changes | |
| if: needs.changes.outputs.unity == 'true' | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 45 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| unityVersion: | |
| - 2021.3.45f2 | |
| - 2023.2.22f1 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| - name: Set up Unity | |
| uses: ./.github/actions/setup-unity | |
| with: | |
| editor-version: ${{ matrix.unityVersion }} | |
| email: ${{ secrets.UNITY_EMAIL }} | |
| password: ${{ secrets.UNITY_PASSWORD }} | |
| - name: Cache Library | |
| uses: actions/cache@v4 | |
| with: | |
| path: Library | |
| key: Library-${{ runner.os }}-${{ matrix.unityVersion }}-EditMode-${{ hashFiles('Packages/manifest.json', 'Packages/packages-lock.json', 'ProjectSettings/ProjectVersion.txt') }} | |
| restore-keys: Library-${{ runner.os }}-${{ matrix.unityVersion }}-EditMode- | |
| - name: Run EditMode tests | |
| env: | |
| LIBGL_ALWAYS_SOFTWARE: '1' | |
| run: | | |
| xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" \ | |
| unity --non-interactive test . \ | |
| --editor-version "${{ matrix.unityVersion }}" \ | |
| --mode EditMode \ | |
| --output Logs/TestResults/editmode.xml \ | |
| --timeout 900 \ | |
| -- -force-glcore -logFile Logs/editmode.log | |
| - name: Return Unity license | |
| if: always() && env.UNITY_LICENSE_ACTIVATION_ATTEMPTED == 'true' | |
| timeout-minutes: 5 | |
| env: | |
| UNITY_EDITOR_VERSION: ${{ matrix.unityVersion }} | |
| UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
| UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
| run: bash .github/actions/setup-unity/return-license.sh | |
| - name: Upload test results and logs | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: TestResults-${{ matrix.unityVersion }}-EditMode | |
| path: Logs/ | |
| verify: | |
| name: Verification | |
| needs: [changes, test] | |
| if: always() | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Require all applicable checks to pass | |
| env: | |
| CHANGES_RESULT: ${{ needs.changes.result }} | |
| UNITY_REQUIRED: ${{ needs.changes.outputs.unity }} | |
| TEST_RESULT: ${{ needs.test.result }} | |
| run: | | |
| if [[ "$CHANGES_RESULT" != success ]]; then | |
| echo "::error::Could not determine required checks ($CHANGES_RESULT)." | |
| exit 1 | |
| fi | |
| case "$UNITY_REQUIRED:$TEST_RESULT" in | |
| true:success) | |
| echo "All required EditMode tests passed." | |
| ;; | |
| false:skipped) | |
| echo "No Unity changes require EditMode tests." | |
| ;; | |
| *) | |
| echo "::error::EditMode validation did not pass (required=$UNITY_REQUIRED, result=$TEST_RESULT)." | |
| exit 1 | |
| ;; | |
| esac |