-
Notifications
You must be signed in to change notification settings - Fork 13
359 lines (309 loc) · 13.6 KB
/
main.ci.cd.workflow.yml
File metadata and controls
359 lines (309 loc) · 13.6 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: CI/CD - Run Tests & Build Project
on:
workflow_dispatch:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
schedule:
- cron: "0 0 * * *" # run daily at midnight (UTC)
jobs:
runtime-tests:
name: Runtime Tests (IL2CPP)
runs-on: ubuntu-latest
env:
RUNTIME_TEST_IMAGE: 'unityci/editor:ubuntu-6000.0.63f1-linux-il2cpp-3.2.2'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Git
run: git config --global --add safe.directory /github/workspace
- name: Free Disk space
uses: jlumbroso/free-disk-space@v1.2.0
with:
dotnet: false
- name: Remove assemblies incompatible with linux-il2cpp image
run: |
rm -rf Assets/Plugins/StreamChat/SampleProject
rm -rf Assets/Plugins/StreamChat/Samples
# The repo intentionally does not track Packages/manifest.json so the
# legacy Unity 2020/2021 build job can fall back to its image's default
# manifest. The IL2CPP runtime test job runs on Unity 6000.0 and must
# pin its own packages (notably com.unity.test-framework for NUnit).
- name: Install runtime-tests Packages/manifest.json
run: |
mkdir -p Packages
cp .github/workflows/manifests/runtime-tests.manifest.json Packages/manifest.json
rm -f Packages/packages-lock.json
- name: Prepare project for IL2CPP runtime tests
uses: game-ci/unity-builder@v4
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
buildMethod: StreamChat.EditorTools.StreamEditorTools.PrepareStandaloneIL2CPPTests
customImage: ${{ env.RUNTIME_TEST_IMAGE }}
allowDirtyBuild: true
- name: Remove editor-only test assemblies before player build
run: |
rm -rf Assets/Plugins/StreamChat/EditorTools
rm -rf Assets/Plugins/StreamChat/Tests/StreamChat.Tests.asmdef
rm -rf Assets/Plugins/StreamChat/Tests/LowLevelClient
rm -rf Assets/Plugins/StreamChat/Tests/StatefulClient
rm -rf Assets/Plugins/StreamChat/Tests/StreamTestClients.cs
rm -rf Assets/Plugins/StreamChat/Tests/TestUtils.cs
rm -rf Assets/Plugins/StreamChat/Tests/ToolsTests.cs
rm -rf Assets/Plugins/StreamChat/Tests/UnityTestRunnerCallbacks.cs
rm -rf Assets/Plugins/StreamChat/Tests/UnityTestUtils.cs
- name: Debug - inspect NUnit and test framework state
run: |
echo "=== Runtime test asmdef ==="
cat Assets/Plugins/StreamChat/Tests/Runtime/StreamChat.Tests.Runtime.asmdef
echo ""
echo "=== Packages/manifest.json (test-framework entry) ==="
grep -i "test-framework" Packages/manifest.json || echo "NOT FOUND in manifest"
echo ""
echo "=== Packages/packages-lock.json (test-framework entry) ==="
grep -A5 "test-framework" Packages/packages-lock.json 2>/dev/null || echo "No packages-lock.json"
echo ""
echo "=== Find nunit.framework.dll anywhere in project ==="
find . -name "nunit.framework.dll" -type f 2>/dev/null || echo "NOT FOUND"
echo ""
echo "=== Find nunit.framework.dll in Unity install ==="
find /opt/unity -name "nunit.framework.dll" -type f 2>/dev/null || echo "NOT FOUND in /opt/unity"
echo ""
echo "=== Find nunit.framework.dll in package cache ==="
find Library/PackageCache -name "nunit.framework.dll" -type f 2>/dev/null || echo "NOT FOUND in PackageCache"
echo ""
echo "=== nunit.framework.dll.meta (if found) ==="
for f in $(find . Library/PackageCache /opt/unity -name "nunit.framework.dll.meta" -type f 2>/dev/null); do
echo "--- $f ---"
cat "$f"
done
echo ""
echo "=== ProjectSettings scripting defines ==="
grep -A2 "scriptingDefineSymbols" ProjectSettings/ProjectSettings.asset || echo "NOT FOUND"
echo ""
echo "=== Remaining test assembly files ==="
find Assets/Plugins/StreamChat/Tests -type f -name "*.cs" -o -name "*.asmdef" | sort
- name: Run runtime tests in IL2CPP player
uses: game-ci/unity-test-runner@v4
id: runtime_tests
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
testMode: playmode
customImage: ${{ env.RUNTIME_TEST_IMAGE }}
customParameters: -testPlatform StandaloneLinux64
allowDirtyBuild: true
timeout-minutes: 90
- name: Upload Runtime Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: Runtime_Test_Results_IL2CPP
path: artifacts
- name: Notify Slack if failed
uses: voxmedia/github-action-slack-notify-build@v1
if: always() && failure()
with:
channel_id: C07KW7ZCJ6T
color: danger
status: "RUNTIME TESTS FAILED (IL2CPP)"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target_platform: [android, ios]
unity_version: [2020, 2021]
dotnet_version: [NET_4_x, STANDARD_2_x]
compiler: [mono, il2cpp]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Calculate Sequential Index
id: calculate-index
run: |
target_index=$([[ "${{ matrix.target_platform }}" == 'android' ]] && echo '0' || echo '1')
unity_index=$([[ "${{ matrix.unity_version }}" == '2020' ]] && echo '0' || echo '1')
dotnet_index=$([[ "${{ matrix.dotnet_version }}" == 'NET_4_x' ]] && echo '0' || echo '1')
compiler_index=$([[ "${{ matrix.compiler }}" == 'mono' ]] && echo '0' || echo '1')
index=$((target_index * 1 + unity_index * 2 + dotnet_index * 4 + compiler_index * 8))
echo "SEQUENTIAL_INDEX=$index" >> $GITHUB_ENV
- name: Print Sequential Index
run: |
echo "Sequential Index: $SEQUENTIAL_INDEX"
- name: Install Git
run: git config --global --add safe.directory /github/workspace
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew update
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y libxtst6 libgtk-3-0
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install --cask adoptopenjdk
brew install gtk+3
- name: Determine Docker Image
id: dockerImageSelector
run: |
if [ "${{ matrix.unity_version }}" == '2020' ]; then
if [ "${{ matrix.target_platform }}" == 'android' ]; then
TAG='unityci/editor:ubuntu-2020.3.40f1-android-3.1.0'
elif [ "${{ matrix.target_platform }}" == 'ios' ]; then
TAG='unityci/editor:ubuntu-2020.3.40f1-ios-3.1.0'
else
echo "Unsupported platform"
exit 1
fi
elif [ "${{ matrix.unity_version }}" == '2021' ]; then
if [ "${{ matrix.target_platform }}" == 'android' ]; then
TAG='unityci/editor:ubuntu-2021.3.36f1-android-3.1.0'
elif [ "${{ matrix.target_platform }}" == 'ios' ]; then
TAG='unityci/editor:ubuntu-2021.3.36f1-ios-3.1.0'
else
echo "Unsupported platform"
exit 1
fi
else
echo "Unsupported Unity version"
exit 1
fi
echo "DOCKER_TAG=$TAG" >> $GITHUB_ENV
- name: Echo Docker Image
run: |
echo ${{ env.DOCKER_TAG }}
- name: Determine Build Name
run: |
RUNNER_ID="${{ matrix.unity_version }}_${{ matrix.target_platform }}_${{ matrix.compiler }}_${{ matrix.dotnet_version }}"
if [ "${{ matrix.target_platform }}" == "android" ]; then
BUILD_NAME="${RUNNER_ID}.apk"
elif [ "${{ matrix.target_platform }}" == "ios" ]; then
BUILD_NAME="${RUNNER_ID}.ipa"
else
echo "Unsupported platform"
exit 1
fi
echo "RUNNER_ID=$RUNNER_ID" >> $GITHUB_ENV
echo "BUILD_NAME=$BUILD_NAME" >> $GITHUB_ENV
- name: Enable Tests
uses: game-ci/unity-builder@v4
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
buildMethod: StreamChat.EditorTools.StreamEditorTools.EnableStreamTestsEnabledCompilerFlag
customImage: ${{ env.DOCKER_TAG }}
- name: Run Tests (Attempt 1)
id: run_tests_1
uses: game-ci/unity-test-runner@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
customParameters: -streamBase64TestDataSet "${{ secrets.STREAM_AUTH_TEST_DATA_BASE64 }}" -testDataSetIndex ${{ env.SEQUENTIAL_INDEX }}
customImage: ${{ env.DOCKER_TAG }}
timeout-minutes: 40
continue-on-error: true
- name: Run Tests (Attempt 2)
id: run_tests_2
if: steps.run_tests_1.outcome == 'failure'
uses: game-ci/unity-test-runner@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
customParameters: -streamBase64TestDataSet "${{ secrets.STREAM_AUTH_TEST_DATA_BASE64 }}" -testDataSetIndex ${{ env.SEQUENTIAL_INDEX }}
customImage: ${{ env.DOCKER_TAG }}
timeout-minutes: 50
continue-on-error: true
- name: Run Tests (Attempt 3)
id: run_tests_3
if: steps.run_tests_2.outcome == 'failure'
uses: game-ci/unity-test-runner@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
customParameters: -streamBase64TestDataSet "${{ secrets.STREAM_AUTH_TEST_DATA_BASE64 }}" -testDataSetIndex ${{ env.SEQUENTIAL_INDEX }}
customImage: ${{ env.DOCKER_TAG }}
timeout-minutes: 60
continue-on-error: true
- name: Run Tests (Attempt 4)
id: run_tests_4
if: steps.run_tests_3.outcome == 'failure'
uses: game-ci/unity-test-runner@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
customParameters: -streamBase64TestDataSet "${{ secrets.STREAM_AUTH_TEST_DATA_BASE64 }}" -testDataSetIndex ${{ env.SEQUENTIAL_INDEX }}
customImage: ${{ env.DOCKER_TAG }}
timeout-minutes: 60
continue-on-error: true
- name: Run Tests (Attempt 5)
id: run_tests_5
if: steps.run_tests_4.outcome == 'failure'
uses: game-ci/unity-test-runner@v4
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
customParameters: -streamBase64TestDataSet "${{ secrets.STREAM_AUTH_TEST_DATA_BASE64 }}" -testDataSetIndex ${{ env.SEQUENTIAL_INDEX }}
customImage: ${{ env.DOCKER_TAG }}
timeout-minutes: 60
- name: Upload Test Results as Artifact
uses: actions/upload-artifact@v4
with:
name: Test_Results_${{ env.RUNNER_ID }}
path: artifacts
- name: Free Disk space
uses: jlumbroso/free-disk-space@v1.2.0
if: matrix.target_platform == 'android' || matrix.target_platform == 'ios'
with:
dotnet: false
- name: List changes
run: |
git diff
- name: Build Sample Project
uses: game-ci/unity-builder@v4
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
buildMethod: StreamChat.EditorTools.StreamEditorTools.BuildSampleApp
customParameters: -streamBase64TestDataSet ${{ secrets.STREAM_AUTH_TEST_DATA_BASE64 }} -testDataSetIndex ${{ env.SEQUENTIAL_INDEX }} -apiCompatibility ${{ matrix.dotnet_version }} -scriptingBackend ${{ matrix.compiler }} -buildTargetPlatform ${{ matrix.target_platform }} -buildTargetPath $(pwd)/SampleAppBuild/${{ env.BUILD_NAME }}
customImage: ${{ env.DOCKER_TAG }}
allowDirtyBuild: true #Needed because the import process may update ProjectSettings
- name: Upload Build as Artifact
uses: actions/upload-artifact@v4
with:
name: Build_${{ env.BUILD_NAME }}
path: $(pwd)/SampleAppBuild/${{ env.BUILD_NAME }}
- name: Notify Slack if failed
uses: voxmedia/github-action-slack-notify-build@v1
if: always() && failure()
with:
channel_id: C07KW7ZCJ6T
color: danger
status: FAILED
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}