|
| 1 | +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json |
| 2 | +name: Unity EditMode Suite |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + checks: write |
| 14 | + statuses: write |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: unity-editmode-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +env: |
| 21 | + UNITY_VERSION: 6000.0.0f1 |
| 22 | + PROJECT_PATH: . |
| 23 | + TEST_PLATFORM: EditMode |
| 24 | + |
| 25 | +jobs: |
| 26 | + editmode: |
| 27 | + name: EditMode Regression |
| 28 | + runs-on: ubuntu-latest |
| 29 | + timeout-minutes: 30 |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + lfs: true |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Install Unity |
| 38 | + uses: game-ci/unity-setup@v4 |
| 39 | + with: |
| 40 | + unityVersion: ${{ env.UNITY_VERSION }} |
| 41 | + githubToken: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + |
| 43 | + - name: Cache Library |
| 44 | + uses: actions/cache@v4 |
| 45 | + with: |
| 46 | + path: Library |
| 47 | + key: ${{ runner.os }}-unity-${{ env.UNITY_VERSION }}-${{ hashFiles('Packages/packages-lock.json') }} |
| 48 | + restore-keys: | |
| 49 | + ${{ runner.os }}-unity-${{ env.UNITY_VERSION }}- |
| 50 | +
|
| 51 | + - name: Run EditMode Tests |
| 52 | + uses: game-ci/unity-test-runner@v4 |
| 53 | + with: |
| 54 | + githubToken: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + projectPath: ${{ env.PROJECT_PATH }} |
| 56 | + unityVersion: ${{ env.UNITY_VERSION }} |
| 57 | + testMode: ${{ env.TEST_PLATFORM }} |
| 58 | + artifactsPath: Artifacts |
| 59 | + coverageOptions: generateAdditionalMetrics;generateHtmlReport;generateBadgeReport |
| 60 | + |
| 61 | + - name: Publish Artifacts |
| 62 | + if: always() |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: editmode-suite |
| 66 | + path: Artifacts |
| 67 | + |
| 68 | + - name: Surface Coverage Summary |
| 69 | + if: always() |
| 70 | + shell: pwsh |
| 71 | + run: | |
| 72 | + $summaryPath = Join-Path Artifacts "coverage/Report/Summary.xml" |
| 73 | + if (Test-Path $summaryPath) { |
| 74 | + [xml]$summary = Get-Content $summaryPath |
| 75 | + $attributes = $summary.Summary.Attributes |
| 76 | + $coverageAttr = $attributes.GetNamedItem('lineCoverage') |
| 77 | + if (-not $coverageAttr) { |
| 78 | + $coverageAttr = $attributes.GetNamedItem('linecoverage') |
| 79 | + } |
| 80 | + if ($coverageAttr) { |
| 81 | + $coverage = [math]::Round([double]$coverageAttr.Value, 2) |
| 82 | + Write-Host "::notice::Line coverage: $coverage%" |
| 83 | + } else { |
| 84 | + Write-Warning 'Coverage summary present but lineCoverage attribute missing.' |
| 85 | + } |
| 86 | + } else { |
| 87 | + Write-Warning 'Coverage summary not generated.' |
| 88 | + } |
0 commit comments