Skip to content

Commit e534a3d

Browse files
authored
Merge pull request #34 from GetStream/develop
Develop
2 parents 0cdd300 + 5fc08c3 commit e534a3d

22 files changed

+618
-10
lines changed

.github/workflows/ci.yml

Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
name: CI - Run Tests + Build Sample App
2+
3+
on:
4+
pull_request:
5+
branches: [ main, develop ]
6+
push:
7+
branches: [ main, develop ]
8+
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
17+
18+
jobs:
19+
testRunner:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: [macos-latest]
24+
unity_version: [2021.3.27, 2022.3.4]
25+
dotnet_version: [NET_4_x, STANDARD_2_x]
26+
compiler: [il2cpp]
27+
target_platform: [standalone, mobile]
28+
name: Run tests + Build Sample APp
29+
runs-on: ${{ matrix.os }}
30+
timeout-minutes: 600
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v2
34+
35+
- name: Print chipset
36+
shell: bash
37+
run: uname -m
38+
continue-on-error: true
39+
40+
- name: Set up Node.js 16
41+
uses: actions/setup-node@v1
42+
with:
43+
node-version: 16
44+
45+
- uses: actions/setup-python@v4
46+
with:
47+
python-version: '3.x'
48+
49+
- name: Print python version
50+
shell: bash
51+
run: python --version
52+
continue-on-error: true
53+
54+
- name: Install node package, `unity-license-activate`
55+
run: npm install --global https://github.com/sierpinskid/unity-license-activate
56+
57+
- name: Install node package, `unity-verify-code`
58+
run: npm install --global https://github.com/sierpinskid/unity-verify-code
59+
60+
- name: Download Unity & Modules
61+
if: ${{ matrix.os }} == 'macos-latest'
62+
shell: bash
63+
run: |
64+
if [[ ${{ matrix.unity_version }} == '2021.3.27' ]]
65+
then
66+
curl -L -o ~/Unity.pkg https://download.unity3d.com/download_unity/ca3ffb99bcc6/MacEditorInstaller/Unity.pkg
67+
68+
if [[ ${{ matrix.compiler }} == 'il2cpp' ]]
69+
then
70+
curl -L -o ~/UnityIL2CPPModule.pkg https://download.unity3d.com/download_unity/ca3ffb99bcc6/MacEditorTargetInstaller/UnitySetup-Mac-IL2CPP-Support-for-Editor-2021.3.27f1.pkg
71+
fi
72+
73+
if [[ ${{ matrix.target_platform }} == 'mobile' ]]
74+
then
75+
curl -L -o ~/UnityIosModule.pkg https://download.unity3d.com/download_unity/ca3ffb99bcc6/MacEditorTargetInstaller/UnitySetup-iOS-Support-for-Editor-2021.3.27f1.pkg
76+
fi
77+
elif [[ ${{ matrix.unity_version }} == '2022.3.4' ]]
78+
then
79+
curl -L -o ~/Unity.pkg https://download.unity3d.com/download_unity/35713cd46cd7/MacEditorInstaller/Unity.pkg
80+
81+
if [[ ${{ matrix.compiler }} == 'il2cpp' ]]
82+
then
83+
curl -L -o ~/UnityIL2CPPModule.pkg https://download.unity3d.com/download_unity/35713cd46cd7/MacEditorTargetInstaller/UnitySetup-Mac-IL2CPP-Support-for-Editor-2022.3.4f1.pkg
84+
fi
85+
86+
if [[ ${{ matrix.target_platform }} == 'mobile' ]]
87+
then
88+
curl -L -o ~/UnityIosModule.pkg https://download.unity3d.com/download_unity/35713cd46cd7/MacEditorTargetInstaller/UnitySetup-iOS-Support-for-Editor-2022.3.4f1.pkg
89+
fi
90+
fi
91+
92+
- name: Install Unity
93+
uses: nick-fields/retry@v2
94+
with:
95+
timeout_minutes: 15
96+
max_attempts: 3
97+
shell: bash
98+
command: sudo installer -package ~/Unity.pkg -target /
99+
100+
- name: Instal IL2CPP Module
101+
if: matrix.compiler == 'il2cpp'
102+
uses: nick-fields/retry@v2
103+
with:
104+
timeout_minutes: 5
105+
max_attempts: 3
106+
shell: bash
107+
command: sudo installer -package ~/UnityIL2CPPModule.pkg -target /
108+
109+
- name: Instal Mobile Module
110+
if: matrix.target_platform == 'mobile'
111+
uses: nick-fields/retry@v2
112+
with:
113+
timeout_minutes: 5
114+
max_attempts: 3
115+
shell: bash
116+
command: sudo installer -package ~/UnityIosModule.pkg -target /
117+
118+
- name: Create Test Results dir
119+
shell: bash
120+
run: mkdir test_results
121+
122+
- name: Generate .ALF license file
123+
shell: bash
124+
run: sudo /Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -nographics -createManualActivationFile -quit
125+
continue-on-error: true #Unity return exit code 1 even if successfully creating license file
126+
127+
- name: List dir
128+
shell: bash
129+
run: |
130+
ls
131+
grep ".alf$"
132+
ULF_FILE_PATH=$(ls | grep ".alf$")
133+
echo $ULF_FILE_PATH
134+
continue-on-error: true
135+
136+
- name: Ensure code file exists
137+
shell: bash
138+
run: touch ./code.txt
139+
continue-on-error: true
140+
141+
- name: Activate .ALF License - Get .ULF file
142+
id: generate_ulf_license_attempt_1
143+
shell: bash
144+
run: sudo unity-license-activate "${{ secrets.UNITY_ACCOUNT_USER }}" "${{ secrets.UNITY_ACCOUNT_PASS }}" "$(ls | grep ".alf$")" --password "${{ secrets.EMAIL_PASS }}" --host "imap.gmail.com"
145+
timeout-minutes: 25
146+
continue-on-error: true
147+
148+
- name: Activate .ALF License - Get .ULF file - Attempt 2
149+
if: steps.generate_ulf_license_attempt_1.outcome == 'failure'
150+
id: generate_ulf_license_attempt_2
151+
shell: bash
152+
run: sudo unity-license-activate "${{ secrets.UNITY_ACCOUNT_USER }}" "${{ secrets.UNITY_ACCOUNT_PASS }}" "$(ls | grep ".alf$")" --password "${{ secrets.EMAIL_PASS }}" --host "imap.gmail.com"
153+
timeout-minutes: 25
154+
continue-on-error: true
155+
156+
- name: Activate .ALF License - Get .ULF file - Attempt 3
157+
if: steps.generate_ulf_license_attempt_2.outcome == 'failure'
158+
id: generate_ulf_license_attempt_3
159+
shell: bash
160+
run: sudo unity-license-activate "${{ secrets.UNITY_ACCOUNT_USER }}" "${{ secrets.UNITY_ACCOUNT_PASS }}" "$(ls | grep ".alf$")" --password "${{ secrets.EMAIL_PASS }}" --host "imap.gmail.com"
161+
timeout-minutes: 25
162+
continue-on-error: true
163+
164+
- name: 🩺 Upload error screenshot
165+
if: steps.generate_ulf_license_attempt_1.outcome == 'failure'
166+
uses: actions/upload-artifact@v1
167+
continue-on-error: true
168+
with:
169+
name: screenshot_error_1
170+
path: error.png
171+
172+
- name: 🩺 Upload error screenshot 2
173+
if: steps.generate_ulf_license_attempt_2.outcome == 'failure'
174+
uses: actions/upload-artifact@v1
175+
continue-on-error: true
176+
with:
177+
name: screenshot_error_2
178+
path: error.png
179+
180+
- name: 🩺 Upload error screenshot 3
181+
if: steps.generate_ulf_license_attempt_3.outcome == 'failure'
182+
uses: actions/upload-artifact@v1
183+
continue-on-error: true
184+
with:
185+
name: screenshot_error_3
186+
path: error.png
187+
188+
- name: Activate Unity with .ULF license file
189+
shell: bash
190+
run: sudo /Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -nographics -manualLicenseFile "$(ls | grep ".ulf$")" -quit
191+
continue-on-error: true #Unity return exit code 1 even if successfully activating with license file
192+
193+
- name: LS Unity Logs dir
194+
shell: bash
195+
run: ls ~/Library/Logs/Unity/
196+
continue-on-error: true
197+
198+
- name: Print Audit Unity Logs
199+
shell: bash
200+
run: cat ~/Library/Logs/Unity/Unity.Entitlements.Audit.log
201+
continue-on-error: true
202+
203+
- name: Print Client Unity Logs
204+
shell: bash
205+
run: cat ~/Library/Logs/Unity/Unity.Licensing.Client.log
206+
continue-on-error: true
207+
208+
- name: Print Unity Editor Logs
209+
shell: bash
210+
run: cat ~/Library/Logs/Unity/Editor.log
211+
continue-on-error: true
212+
213+
- name: Enable Stream Tests in Unity
214+
shell: bash
215+
run: sudo /Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -nographics -projectPath "$GITHUB_WORKSPACE" -executeMethod StreamVideo.EditorTools.StreamEditorTools.EnableStreamTestsEnabledCompilerFlag -quit
216+
217+
#skip -quit due to not working with async tests
218+
- name: Run Unity Tests
219+
id: run_unity_tests
220+
shell: bash
221+
run: sudo /Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -nographics -projectPath "$GITHUB_WORKSPACE" -runTests -testResults ~/test_results/results.xml -streamBase64TestDataSet ${{ secrets.STREAM_AUTH_TEST_DATA_BASE64 }}
222+
continue-on-error: true
223+
224+
#due to skipped -quit
225+
- name: Force Close Unity
226+
shell: bash
227+
run: sudo pkill -x Unity
228+
continue-on-error: true
229+
230+
- name: Print Test Results
231+
if: always()
232+
shell: bash
233+
run: cat ~/test_results/results.xml
234+
235+
- name: Print Unity Logs
236+
shell: bash
237+
run: cat ~/Library/Logs/Unity/Editor.log
238+
continue-on-error: true
239+
240+
- name: Generate HTML test report
241+
uses: rempelj/[email protected]
242+
if: always()
243+
with:
244+
inputXmlPath: ~/test_results/results.xml
245+
outputHtmlPath: ~/test_results/results.html
246+
247+
- name: Upload tests results XML Artifact
248+
uses: actions/upload-artifact@v3
249+
if: always()
250+
with:
251+
name: ${{ matrix.os }}_${{ matrix.unity_version }}_${{ matrix.compiler }}_${{ matrix.dotnet_version }}_${{ matrix.target_platform }}_test_results.xml
252+
path: ~/test_results/results.xml
253+
254+
- name: Upload tests results Html Artifact
255+
uses: actions/upload-artifact@v3
256+
if: always()
257+
with:
258+
name: ${{ matrix.os }}_${{ matrix.unity_version }}_${{ matrix.compiler }}_${{ matrix.dotnet_version }}_${{ matrix.target_platform }}_test_results.html
259+
path: ~/test_results/results.html
260+
261+
- name: Validate All Tests Passed
262+
if: steps.run_unity_tests.outcome == 'failure'
263+
run: exit 1
264+
265+
- name: Generate GH Summary Comment
266+
uses: sierpinskid/nunit-github-comment@v1
267+
if: github.event_name == 'pull_request'
268+
with:
269+
inputXmlPath: ~/test_results/results.xml
270+
outputFilePath: ~/test_results/gh_comment.txt
271+
272+
- name: Set GH Comment as variable
273+
if: github.event_name == 'pull_request'
274+
id: generate_gh_comment
275+
run: echo "::set-output name=gh_comment::$(cat ~/test_results/gh_comment.txt)"
276+
277+
- name: Build Sample App
278+
shell: bash
279+
run: sudo /Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -nographics -projectPath "$GITHUB_WORKSPACE" -executeMethod "StreamVideo.EditorTools.StreamEditorTools.BuildSampleApp" -streamBase64TestDataSet ${{ secrets.STREAM_AUTH_TEST_DATA_BASE64 }} -apiCompatibility ${{ matrix.dotnet_version }} -scriptingBackend ${{ matrix.compiler }} -buildTargetPlatform ${{ matrix.target_platform }} -buildTargetPath "~/SampleAppBuild/App" -quit
280+
281+
- name: LS
282+
shell: bash
283+
run: |
284+
ls
285+
echo '----'
286+
ls ~
287+
echo '----'
288+
ls "~/SampleAppBuild/"
289+
echo '----'
290+
ls "~/SampleAppBuild/App/"
291+
echo '----'
292+
continue-on-error: true
293+
294+
- name: Upload Sample App
295+
uses: actions/upload-artifact@v3
296+
with:
297+
name: ${{ matrix.os }}_${{ matrix.unity_version }}_${{ matrix.compiler }}_${{ matrix.dotnet_version }}_${{ matrix.target_platform }}_sample_app
298+
path: ~/SampleAppBuild/App/
299+
300+

Packages/StreamVideo/Editor/Builders.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace StreamVideo.EditorTools.Builders
2+
{
3+
public enum ApiCompatibility
4+
{
5+
NET_4_x,
6+
STANDARD_2_x
7+
}
8+
}

Packages/StreamVideo/Editor/Builders/ApiCompatibility.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using UnityEditor;
2+
3+
namespace StreamVideo.EditorTools.Builders
4+
{
5+
public readonly struct BuildSettings
6+
{
7+
public BuildTargetGroup BuildTargetGroup { get; }
8+
public ApiCompatibilityLevel ApiCompatibilityLevel { get; }
9+
public ScriptingImplementation ScriptingImplementation { get; }
10+
public string TargetPath { get; }
11+
12+
public BuildSettings(BuildTargetGroup buildTargetGroup, ApiCompatibilityLevel apiCompatibilityLevel,
13+
ScriptingImplementation scriptingImplementation, string targetPath)
14+
{
15+
BuildTargetGroup = buildTargetGroup;
16+
ApiCompatibilityLevel = apiCompatibilityLevel;
17+
ScriptingImplementation = scriptingImplementation;
18+
TargetPath = targetPath;
19+
}
20+
21+
public override string ToString() =>
22+
$"{nameof(BuildSettings)} - {nameof(BuildTargetGroup)}: {BuildTargetGroup}, {nameof(ApiCompatibilityLevel)}: {ApiCompatibilityLevel}, " +
23+
$"{nameof(ScriptingImplementation)}: {ScriptingImplementation}, {nameof(TargetPath)}: {TargetPath}";
24+
}
25+
}

Packages/StreamVideo/Editor/Builders/BuildSettings.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace StreamVideo.EditorTools.Builders
2+
{
3+
public enum BuildTargetPlatform
4+
{
5+
Standalone,
6+
Mobile
7+
}
8+
}

Packages/StreamVideo/Editor/Builders/BuildTargetPlatform.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace StreamVideo.EditorTools.Builders
2+
{
3+
public enum ScriptingBackend
4+
{
5+
IL2CPP
6+
}
7+
}

Packages/StreamVideo/Editor/Builders/ScriptingBackend.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)