|
7 | 7 | matrix: |
8 | 8 | required: true |
9 | 9 | type: string |
| 10 | + allow-security-alert: |
| 11 | + required: false |
| 12 | + type: boolean |
| 13 | + default: false |
10 | 14 | jobs: |
11 | 15 | build: |
12 | 16 | name: ${{ matrix.name }} |
13 | 17 | runs-on: ${{ matrix.os }} |
14 | 18 | strategy: |
15 | 19 | matrix: ${{ fromJSON(inputs.matrix) }} |
16 | 20 | fail-fast: false |
17 | | - timeout-minutes: 30 |
| 21 | + # a hung download must not hold the matrix; rows that install the Android module and its SDK get more |
| 22 | + timeout-minutes: ${{ contains(matrix.build-targets, 'Android') && 60 || 45 }} |
| 23 | + defaults: |
| 24 | + run: |
| 25 | + shell: bash |
18 | 26 | env: |
19 | 27 | UNITY_EDITORS: '' # set by the unity-setup action |
20 | | - UNITY_HUB_PATH: '' # set by the unity-setup action |
| 28 | + UNITY_CLI_PATH: '' # set by the unity-setup action |
21 | 29 | UNITY_EDITOR_PATH: '' # set by the unity-setup action |
22 | 30 | UNITY_PROJECT_PATH: '' # set by the unity-setup action |
23 | 31 | steps: |
| 32 | + # runs alongside checkout; the wait before the editor packages joins it |
24 | 33 | - name: Free Disk Space |
| 34 | + id: free-disk-space |
| 35 | + background: true |
25 | 36 | if: ${{ matrix.os == 'ubuntu-latest' && (matrix.unity-version != '2018' && matrix.unity-version != '2017.4.40f1') }} |
26 | | - uses: endersonmenezes/free-disk-space@7901478139cff6e9d44df5972fd8ab8fcade4db1 # v3.2.2 |
| 37 | + uses: endersonmenezes/free-disk-space@8b8cd4e2277836962939a8f3b4ea0ee4bc006156 # v4.0.1 |
27 | 38 | with: |
28 | 39 | remove_android: true |
29 | 40 | remove_dotnet: false |
30 | 41 | remove_tool_cache: false |
31 | | - - uses: actions/checkout@v6 |
| 42 | + - uses: actions/checkout@v7 |
| 43 | + - name: Wait for Free Disk Space |
| 44 | + wait: free-disk-space |
| 45 | + # the editor's apt packages come from a mirror that has served them at about 40 kB/s, so the .deb files are kept |
| 46 | + # in the Actions cache: an apt hook copies every package dpkg installs, and a later run puts them back into apt's |
| 47 | + # archive before unity-setup, so apt finds them already downloaded |
| 48 | + - name: Restore Linux editor packages |
| 49 | + id: linux-packages |
| 50 | + if: ${{ runner.os == 'Linux' && matrix.unity-version != 'None' }} |
| 51 | + run: | |
| 52 | + echo "key=unity-linux-packages-${ImageOS}-${ImageVersion}" >> "$GITHUB_OUTPUT" |
| 53 | + echo "restore-key=unity-linux-packages-${ImageOS}-" >> "$GITHUB_OUTPUT" |
| 54 | + mkdir -p "${RUNNER_TEMP}/apt-packages" |
| 55 | + echo "DPkg::Pre-Install-Pkgs {\"xargs -r cp -n -t ${RUNNER_TEMP}/apt-packages/ || true\";};" | sudo tee /etc/apt/apt.conf.d/99unity-setup-keep-packages > /dev/null |
| 56 | + - uses: actions/cache/restore@v6 |
| 57 | + id: linux-packages-cache |
| 58 | + if: ${{ steps.linux-packages.outcome == 'success' }} |
| 59 | + with: |
| 60 | + path: ${{ runner.temp }}/apt-packages |
| 61 | + key: ${{ steps.linux-packages.outputs.key }} |
| 62 | + restore-keys: ${{ steps.linux-packages.outputs.restore-key }} |
| 63 | + - name: Seed apt with cached packages |
| 64 | + if: ${{ steps.linux-packages-cache.outputs.cache-matched-key != '' }} |
| 65 | + run: | |
| 66 | + count=$(find "${RUNNER_TEMP}/apt-packages" -maxdepth 1 -name '*.deb' | wc -l | tr -d ' ') |
| 67 | + echo "Restored ${count} cached packages" |
| 68 | + if [ "${count}" -gt 0 ]; then |
| 69 | + sudo cp -n "${RUNNER_TEMP}"/apt-packages/*.deb /var/cache/apt/archives/ |
| 70 | + fi |
32 | 71 | - uses: ./ # buildalon/unity-setup |
33 | 72 | id: unity-setup |
34 | 73 | with: |
35 | 74 | version-file: None |
36 | 75 | unity-version: ${{ matrix.unity-version }} |
37 | 76 | build-targets: ${{ matrix.build-targets }} |
38 | 77 | modules: ${{ matrix.modules }} |
39 | | - auto-update-hub: ${{ !contains(matrix.modules, 'None') }} |
40 | | - hub-version: ${{ contains(matrix.modules, 'None') && '3.12.0' || '' }} |
| 78 | + # streams that only have betas or alphas so far resolve to those; a stable release wins once there is one |
| 79 | + channels: f,b,a |
| 80 | + allow-security-alert: ${{ inputs.allow-security-alert }} |
| 81 | + - name: Collect Linux editor packages |
| 82 | + id: linux-packages-collect |
| 83 | + if: ${{ steps.linux-packages.outcome == 'success' && steps.linux-packages-cache.outputs.cache-hit != 'true' }} |
| 84 | + run: | |
| 85 | + sudo chown -R "$(id -u):$(id -g)" "${RUNNER_TEMP}/apt-packages" |
| 86 | + count=$(find "${RUNNER_TEMP}/apt-packages" -maxdepth 1 -name '*.deb' | wc -l | tr -d ' ') |
| 87 | + echo "Collected ${count} packages" |
| 88 | + echo "count=${count}" >> "$GITHUB_OUTPUT" |
| 89 | + - uses: actions/cache/save@v6 |
| 90 | + # rows run in parallel, so several may try the same key; the first save wins and the rest only warn |
| 91 | + if: ${{ steps.linux-packages-collect.outputs.count > 0 }} |
| 92 | + continue-on-error: true |
| 93 | + with: |
| 94 | + path: ${{ runner.temp }}/apt-packages |
| 95 | + key: ${{ steps.linux-packages.outputs.key }} |
41 | 96 | - run: | |
42 | | - ENV_UNITY_HUB_PATH="${{ env.UNITY_HUB_PATH }}" |
43 | | - echo "env.UNITY_HUB_PATH: \"${ENV_UNITY_HUB_PATH}\"" |
44 | | - STEPS_UNITY_HUB_PATH="${{ steps.unity-setup.outputs.unity-hub-path }}" |
45 | | - echo "steps.unity-setup.outputs.unity-hub-path: \"${STEPS_UNITY_HUB_PATH}\"" |
| 97 | + ENV_UNITY_CLI_PATH="${{ env.UNITY_CLI_PATH }}" |
| 98 | + echo "env.UNITY_CLI_PATH: \"${ENV_UNITY_CLI_PATH}\"" |
| 99 | + STEPS_UNITY_CLI_PATH="${{ steps.unity-setup.outputs.unity-cli-path }}" |
| 100 | + echo "steps.unity-setup.outputs.unity-cli-path: \"${STEPS_UNITY_CLI_PATH}\"" |
| 101 | + "${ENV_UNITY_CLI_PATH}" --version |
46 | 102 | ENV_UNITY_EDITORS='${{ env.UNITY_EDITORS }}' # single quotes to preserve JSON format and quotes from breaking the script |
47 | 103 | # The json string is raw and not escaped, which breaks echoing it directly. Escape quotes for safe echoing. |
48 | 104 | ENV_UNITY_EDITORS="${ENV_UNITY_EDITORS//\"/\\\"}" |
|
61 | 117 | echo "steps.unity-setup.outputs.unity-project-path: \"${STEPS_UNITY_PROJECT_PATH}\"" |
62 | 118 |
|
63 | 119 | # validate both the env and output variables are the same |
64 | | - if [[ "${ENV_UNITY_HUB_PATH}" != "${STEPS_UNITY_HUB_PATH}" ]]; then |
65 | | - echo "Error: UNITY_HUB_PATH env and output do not match!" |
| 120 | + if [[ "${ENV_UNITY_CLI_PATH}" != "${STEPS_UNITY_CLI_PATH}" ]]; then |
| 121 | + echo "Error: UNITY_CLI_PATH env and output do not match!" |
66 | 122 | exit 1 |
67 | 123 | fi |
68 | 124 |
|
|
0 commit comments