|
| 1 | +name: Generate ProjectSettings fixtures |
| 2 | + |
| 3 | +# Manually-triggered, one-time (or occasional) generation of the per-Unity-version |
| 4 | +# globalgamemanagers fixtures consumed by ImportProjectSettingsTests. Each matrix |
| 5 | +# version builds a throwaway empty player, extracts the globalgamemanagers it |
| 6 | +# produced, and a final job commits them all (via Git LFS) under |
| 7 | +# Tests/Editor/Fixtures/GlobalGameManagers/<version>/. |
| 8 | +# |
| 9 | +# The regular test matrix (main.yml) never builds anything — it only consumes the |
| 10 | +# fixtures committed here. |
| 11 | +on: |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Build globalgamemanagers (Unity ${{ matrix.unity-version }}) |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + fail-fast: false # one version failing must not cancel the others |
| 20 | + # Keep in sync with the test matrix in main.yml. |
| 21 | + matrix: |
| 22 | + unity-version: [ |
| 23 | + "6000.5.0f1", |
| 24 | + "6000.4.5f1", |
| 25 | + "6000.3.11f1", |
| 26 | + "6000.2.15f1", |
| 27 | + "6000.1.9f1", |
| 28 | + "6000.0.53f1", |
| 29 | + "2022.1.24f1", |
| 30 | + "2020.3.48f1", |
| 31 | + "2019.4.40f1", |
| 32 | + "2018.4.36f1" |
| 33 | + ] |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + # Minimal empty project: just enough to build a player. ThunderKit is NOT |
| 40 | + # embedded — globalgamemanagers is engine/project settings, independent of any |
| 41 | + # installed package, so an empty project yields a clean, representative file |
| 42 | + # and avoids depending on ThunderKit compiling on every matrix version. |
| 43 | + - name: Scaffold empty build project |
| 44 | + run: | |
| 45 | + mkdir -p BuildProject/Assets/Editor |
| 46 | + mkdir -p BuildProject/ProjectSettings |
| 47 | + mkdir -p BuildProject/Packages |
| 48 | +
|
| 49 | + cp .github/fixtures/FixtureBuilder.cs BuildProject/Assets/Editor/FixtureBuilder.cs |
| 50 | + printf 'm_EditorVersion: ${{ matrix.unity-version }}\n' > BuildProject/ProjectSettings/ProjectVersion.txt |
| 51 | + printf '{\n "dependencies": {}\n}\n' > BuildProject/Packages/manifest.json |
| 52 | +
|
| 53 | + - name: Cache Unity Library |
| 54 | + uses: actions/cache@v4 |
| 55 | + with: |
| 56 | + path: BuildProject/Library |
| 57 | + key: GenLibrary-${{ matrix.unity-version }}-${{ hashFiles('.github/fixtures/FixtureBuilder.cs') }} |
| 58 | + restore-keys: | |
| 59 | + GenLibrary-${{ matrix.unity-version }}- |
| 60 | +
|
| 61 | + - name: Build empty player and extract globalgamemanagers |
| 62 | + uses: game-ci/unity-builder@v4 |
| 63 | + env: |
| 64 | + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} |
| 65 | + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} |
| 66 | + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} |
| 67 | + with: |
| 68 | + unityVersion: ${{ matrix.unity-version }} |
| 69 | + targetPlatform: StandaloneLinux64 |
| 70 | + projectPath: BuildProject |
| 71 | + # FixtureBuilder does its own BuildPlayer + extraction, then EditorApplication.Exit. |
| 72 | + buildMethod: FixtureBuilder.Build |
| 73 | + # The project is mutated at build time (temporary scene), so allow it. |
| 74 | + allowDirtyBuild: true |
| 75 | + |
| 76 | + - name: Stage fixture for upload |
| 77 | + run: | |
| 78 | + test -f BuildProject/Fixture/globalgamemanagers || { echo "No globalgamemanagers produced"; exit 1; } |
| 79 | + mkdir -p staged |
| 80 | + cp -r BuildProject/Fixture staged/${{ matrix.unity-version }} |
| 81 | + ls -la staged/${{ matrix.unity-version }} |
| 82 | +
|
| 83 | + - name: Upload fixture artifact |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: fixture-${{ matrix.unity-version }} |
| 87 | + path: staged/${{ matrix.unity-version }} |
| 88 | + if-no-files-found: error |
| 89 | + retention-days: 5 |
| 90 | + |
| 91 | + commit: |
| 92 | + name: Commit generated fixtures |
| 93 | + needs: build |
| 94 | + runs-on: ubuntu-latest |
| 95 | + permissions: |
| 96 | + contents: write |
| 97 | + steps: |
| 98 | + - name: Checkout |
| 99 | + uses: actions/checkout@v4 |
| 100 | + with: |
| 101 | + lfs: true |
| 102 | + |
| 103 | + - name: Download all fixture artifacts |
| 104 | + uses: actions/download-artifact@v4 |
| 105 | + with: |
| 106 | + path: incoming |
| 107 | + pattern: fixture-* |
| 108 | + |
| 109 | + - name: Place fixtures |
| 110 | + run: | |
| 111 | + dest="Tests/Editor/Fixtures/GlobalGameManagers" |
| 112 | + mkdir -p "$dest" |
| 113 | + # download-artifact lays each artifact down as incoming/fixture-<version>/... |
| 114 | + for d in incoming/fixture-*; do |
| 115 | + version="${d#incoming/fixture-}" |
| 116 | + mkdir -p "$dest/$version" |
| 117 | + cp "$d/globalgamemanagers" "$dest/$version/globalgamemanagers" |
| 118 | + cp "$d/fixture.json" "$dest/$version/fixture.json" |
| 119 | + done |
| 120 | + find "$dest" -type f | sort |
| 121 | +
|
| 122 | + - name: Commit and push |
| 123 | + run: | |
| 124 | + git config user.name "github-actions[bot]" |
| 125 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 126 | + git lfs install --local |
| 127 | + git add Tests/Editor/Fixtures/GlobalGameManagers |
| 128 | + if git diff --cached --quiet; then |
| 129 | + echo "No fixture changes to commit." |
| 130 | + exit 0 |
| 131 | + fi |
| 132 | + git commit -m "test: regenerate ProjectSettings import fixtures (globalgamemanagers per Unity version)" |
| 133 | + git push origin HEAD:${{ github.ref_name }} |
0 commit comments