forked from homuler/MediaPipeUnityPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (181 loc) · 6.82 KB
/
linux-test.yml
File metadata and controls
203 lines (181 loc) · 6.82 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
name: Run Tests on Linux
on:
workflow_call:
inputs:
ref:
type: string
is_master:
type: boolean
default: false
secrets:
UNITY_EMAIL:
required: true
UNITY_PASSWORD:
required: true
UNITY_TOTP_KEY:
required: true
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
# Cache built libraries
- name: Concat native library source files
run: |
find WORKSPACE packages.config build.py .bazelrc mediapipe_api/ third_party/ -type f | sort | xargs cat > cache_key.txt
- name: Cache libraries
id: cache-libs
uses: actions/cache@v4
with:
path: |
Packages/com.github.homuler.mediapipe/Runtime/Plugins/libmediapipe_c.so
Packages/com.github.homuler.mediapipe/Runtime/Plugins/Protobuf/*.dll
Packages/com.github.homuler.mediapipe/Runtime/Scripts/Protobuf/**/*.cs
Packages/com.github.homuler.mediapipe/PackageResources/MediaPipe/*.bytes
Packages/com.github.homuler.mediapipe/PackageResources/MediaPipe/*.txt
key: libs-ubuntu-24.04-v1-${{ hashFiles('cache_key.txt') }}
# Setup build tools
- name: Mount bazel cache
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: "~/.cache/bazel"
key: bazel-ubuntu-24.04-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}
restore-keys: |
bazel-ubuntu-24.04-v1-${{ hashFiles('WORKSPACE') }}-
bazel-ubuntu-24.04-v1-
- name: Remove cache_key.txt
run: |
rm cache_key.txt
# Setup Python
- uses: actions/setup-python@v5
if: steps.cache-libs.outputs.cache-hit != 'true'
with:
python-version: '3.12'
- name: Install dependencies
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
# install NuGet
sudo apt update
sudo apt-get install -y --no-install-recommends mono-complete
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
bash -c 'echo -e "#!/bin/bash\nmono /usr/local/bin/nuget.exe \$@" | sudo tee -a /usr/local/bin/nuget'
sudo chmod +x /usr/local/bin/nuget
# install NumPy
pip install --no-cache-dir --user numpy
- name: Build
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
unset ANDROID_NDK_HOME
python build.py build --desktop cpu --opencv cmake -vv
- name: Package
run: |
tar cvf artifacts.tar Packages/com.github.homuler.mediapipe
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: linux-package
path: artifacts.tar
retention-days: 1
- name: Cache bazel
if: inputs.is_master && steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ~/.cache/bazel
key: bazel-ubuntu-24.04-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}
test:
runs-on: ${{ matrix.os }}
needs: build
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
unityVersion:
- 6000.0.33f1
- 2022.3.55f1
steps:
- name: Install UnityEditor
run: |
sudo docker cp $(docker create --rm unityci/editor:${{ matrix.unityVersion }}-base-3):/opt/unity /opt/unity
sudo chown -R $(id -u):$(id -g) /opt/unity
echo -e '#!/bin/bash\nxvfb-run -ae /dev/stdout /opt/unity/Editor/Unity -batchmode "$@"' | sudo tee -a /usr/bin/unity-editor
sudo chmod +x /usr/bin/unity-editor
- name: Generate a license activation file
run: |
unity-editor -quit -createManualActivationFile -logFile || true
- name: Request a Unity license file
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_TOTP_KEY: ${{ secrets.UNITY_TOTP_KEY }}
run: |
npm install -g unity-verify-code
git clone https://github.com/homuler/unity-license-activate.git
cd unity-license-activate
npm install
cd ..
npm install -g ./unity-license-activate
unity-license-activate "$UNITY_EMAIL" "$UNITY_PASSWORD" Unity_v${{ matrix.unityVersion }}.alf --authenticator-key "$UNITY_TOTP_KEY"
- name: Activate License
run: |
unity-editor -quit -batchmode -nographics -logFile -manualLicenseFile $(ls Unity_*.ulf) || true
rm Unity_*.ulf
- name: Download built artifacts
uses: actions/download-artifact@v4
with:
name: linux-package
- name: Create a dummy project
run: |
unity-editor -quit -nographics -createProject DummyProject -logFile
mv artifacts.tar DummyProject
cd DummyProject
tar xvf artifacts.tar
echo $(jq '.dependencies += {"com.unity.testtools.codecoverage":"1.2.4"}' Packages/manifest.json) > Packages/manifest.json
- uses: actions/cache@v4
with:
path: DummyProject/Library
key: Library-DummyProject-${{ matrix.os }}-${{ matrix.unityVersion }}-v1
- name: Run tests
env:
ARTIFACTS_PATH: testResults
run: |
unity-editor -nographics \
-logFile \
-projectPath DummyProject \
-testResults ${ARTIFACTS_PATH}/results.xml \
-coverageResultsPath CodeCoverage \
-runTests \
-testPlatform EditMode \
-testCategory !GpuOnly \
-enableCodeCoverage \
-debugCodeOptimization \
-coverageOptions 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;assemblyFilters:+Mediapipe.Runtime;pathFilters:-*/Runtime/Scripts/Protobuf/*'
- name: Cat results.xml
env:
RESULT_FILE_PATH: DummyProject/testResults/results.xml
if: always()
run: |
[ -f $RESULT_FILE_PATH ] && cat ${RESULT_FILE_PATH}
- uses: actions/upload-artifact@v4
if: always()
with:
name: Test results for ${{ matrix.unityVersion }} on ${{ matrix.os }}
path: DummyProject/testResults
retention-days: 7
- uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'ubuntu-22.04' && startsWith(matrix.unityVersion, '2021') }}
with:
name: Coverage results
path: DummyProject/CodeCoverage
retention-days: 7
post-test:
runs-on: ubuntu-latest
needs: test
steps:
- uses: geekyeggo/delete-artifact@v4
with:
name: linux-package
failOnError: false