Skip to content

Commit bfad7d0

Browse files
authored
Create ci-internal.yml
1 parent cca8710 commit bfad7d0

1 file changed

Lines changed: 296 additions & 0 deletions

File tree

.github/workflows/ci-internal.yml

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

0 commit comments

Comments
 (0)