Repository navigation
156 lines (143 loc) · 5.36 KB
/
Copy pathtests.yaml
File metadata and controls
156 lines (143 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Tests
on:
push:
branches:
- main
pull_request: {}
workflow_dispatch:
inputs:
unityVersion:
description: 'Editor version for a targeted run (empty runs the full matrix)'
type: string
required: false
testFilter:
description: 'Unity test filter for a targeted run (empty runs all tests)'
type: string
required: false
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@v7
- 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: ${{ fromJSON(github.event_name == 'workflow_dispatch' && inputs.unityVersion != '' && format('["{0}"]', inputs.unityVersion) || '["2021.3.45f2","6000.6.6f1","7000.0.0a11"]') }}
steps:
- name: Checkout
uses: actions/checkout@v7
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@v6
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: Install window manager for Editor windows
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends openbox x11-utils
- name: Run EditMode tests
env:
LIBGL_ALWAYS_SOFTWARE: '1'
UNITY_EDITOR_VERSION: ${{ matrix.unityVersion }}
UNITY_TEST_FILTER: ${{ github.event_name == 'workflow_dispatch' && inputs.testFilter || '' }}
run: |
mkdir -p Logs
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" \
bash -euo pipefail <<'DISPLAY_SESSION'
# Xvfb supplies a display, but EditorWindow resize/focus also needs a WM.
openbox --sm-disable > Logs/window-manager.log 2>&1 &
window_manager_pid=$!
trap 'kill "$window_manager_pid" 2>/dev/null || true' EXIT
timeout 15 bash -c 'until xprop -root _NET_SUPPORTING_WM_CHECK | grep -q "window id"; do sleep 0.1; done'
test_arguments=()
if [[ -n "$UNITY_TEST_FILTER" ]]; then
test_arguments+=(--filter "$UNITY_TEST_FILTER")
fi
unity --non-interactive test . \
--editor-version "$UNITY_EDITOR_VERSION" \
--mode EditMode \
--output Logs/TestResults/editmode.xml \
--timeout 1200 \
"${test_arguments[@]}" \
-- -force-glcore -timestamps -logFile Logs/editmode.log
DISPLAY_SESSION
- 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@v7
with:
name: TestResults-${{ matrix.unityVersion }}-EditMode
path: Logs/
verify:
name: ${{ github.event_name == 'workflow_dispatch' && (inputs.unityVersion != '' || inputs.testFilter != '') && 'Targeted verification' || '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