-
Notifications
You must be signed in to change notification settings - Fork 183
327 lines (282 loc) · 13.3 KB
/
compiler-build.yml
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
name: compiler-build
on: [push, pull_request]
concurrency:
group: compiler-build-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/heads/release/') }}
env:
NUGET_CERT_REVOCATION_MODE: offline
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
jobs:
build-native:
name: build-native-${{matrix.config.name}}
runs-on: ${{matrix.config.os}}
strategy:
matrix:
config:
- {name: x86_64-macos, os: macos-latest, cmakeArgs: -DENABLE_X86SIMD=OFF, buildType: Release}
- {name: x86_64-linux, os: ubuntu-latest, cmakeArgs: '', buildType: Release}
- {name: x86_64-windows, os: windows-latest, arch: x64, cmakeArgs: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl, buildType: Release}
steps:
- uses: actions/checkout@v3
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Set up build environment (Windows, Visual Studio)
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.config.arch}}
if: runner.os == 'Windows'
- name: Set up build environment (Macos)
run: |
brew install sunnycase/core/[email protected]
if: runner.os == 'Macos'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install Conan
shell: bash
run: |
pip install conan==1.58
- name: Configure Conan (Linux)
run: |
conan profile new default --detect
conan profile update settings.compiler.libcxx=libstdc++11 default
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV
if: runner.os == 'Linux'
- name: Configure CMake
shell: bash
run: |
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.config.buildType}} ${{matrix.config.cmakeArgs}} -DPython3_ROOT_DIR=${pythonLocation}
- name: Build & Install
run: |
cmake --build build --config ${{matrix.config.buildType}}
cmake --install build --prefix install
- name: Upload nncase Native Build Artifact
uses: actions/upload-artifact@v3
with:
name: nncase-native-${{matrix.config.name}}
path: ${{github.workspace}}/install
if-no-files-found: error
build-compiler:
needs: [build-native]
name: build-${{matrix.config.name}}
runs-on: ${{matrix.config.os}}
strategy:
matrix:
dotnet-version: ['7.0']
config:
- {name: x86_64-macos, os: macos-latest, shell: bash, rid: osx-x64, buildType: Release}
- {name: x86_64-linux, os: ubuntu-latest, shell: bash, rid: linux-x64, buildType: Release}
- {name: x86_64-windows, os: windows-latest, shell: bash, rid: win-x64, buildType: Release}
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{matrix.dotnet-version}}
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Install nncase native Artifact
uses: actions/[email protected]
with:
name: nncase-native-${{matrix.config.name}}
path: ${{github.workspace}}/install
- name: Set up build environment (Macos)
run: |
brew install sunnycase/core/[email protected]
if: runner.os == 'Macos'
- name: Build
run: |
dotnet restore -r ${{matrix.config.rid}}
dotnet build -c ${{matrix.config.buildType}} --no-restore
dotnet publish src/Nncase.Compiler -c ${{matrix.config.buildType}} --no-restore --sc false -r ${{matrix.config.rid}}
- name: Set up Dotnet Test settings
uses: 1arp/[email protected]
with:
file: 'test.runsettings'
content: |
<?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<LD_LIBRARY_PATH>${{github.workspace}}/install/lib</LD_LIBRARY_PATH>
<DYLD_LIBRARY_PATH>${{github.workspace}}/install/lib</DYLD_LIBRARY_PATH>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>
- name: Set up test environment (Windows)
shell: pwsh
run: |
echo "PATH=${env:PATH};${env:GITHUB_WORKSPACE}/install/bin" >> $env:GITHUB_ENV
if: runner.os == 'Windows'
- name: Dotnet Test
working-directory: ${{github.workspace}}
run: |
dotnet tool install --global dotnet-coverage
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/unit.xml "dotnet test -c ${{matrix.config.buildType}} -s test.runsettings --no-build --verbosity normal"
dotnet-coverage merge -o coverage.unit.xml -f cobertura -r coverage/*.xml
- name: Upload Coverage
uses: actions/upload-artifact@v3
if: matrix.config.name == 'x86_64-linux'
with:
name: nncase-coverage-unit
path: coverage.unit.xml
if-no-files-found: error
- name: Upload nncase Build Artifact
uses: actions/upload-artifact@v3
with:
name: nncase-${{matrix.config.name}}
path: ${{github.workspace}}/src/Nncase.Compiler/bin/${{matrix.config.buildType}}/net${{matrix.dotnet-version}}/${{matrix.config.rid}}/publish
if-no-files-found: error
test-compiler:
needs: [build-compiler]
name: test-${{matrix.config.name}}
runs-on: ${{matrix.config.os}}
strategy:
matrix:
dotnet-version: ['7.0']
config:
- {name: x86_64-macos, os: macos-latest, shell: bash}
- {name: x86_64-linux, os: ubuntu-latest, shell: bash}
- {name: x86_64-windows, os: windows-latest, shell: bash}
env:
VULKANSDK_VER: 1.3.268.0
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{matrix.dotnet-version}}
- name: Install nncase native Artifact
uses: actions/download-artifact@v3
with:
name: nncase-native-${{matrix.config.name}}
path: ${{github.workspace}}/install
- name: Install nncase
uses: actions/download-artifact@v3
with:
name: nncase-${{matrix.config.name}}
path: ${{github.workspace}}/install
- name: Set up test environment (macOS)
run: |
brew install sunnycase/core/[email protected]
aria2c --parameterized-uri=true https://{sdk.lunarg.com/sdk/download/${VULKANSDK_VER}/mac,distfiles.macports.org/MoltenVK}/vulkansdk-macos-${VULKANSDK_VER}.dmg
hdiutil attach ./vulkansdk-macos-*.dmg
sudo /Volumes/vulkansdk-macos-*/InstallVulkan.app/Contents/MacOS/InstallVulkan --root $HOME/VulkanSDK --accept-licenses --default-answer --confirm-command install
hdiutil detach /Volumes/vulkansdk-macos-*
echo "VULKAN_SDK=$HOME/VulkanSDK/macOS" >> $GITHUB_ENV
wget https://github.com/sunnycase/swiftshader/releases/download/v1.0/swiftshader-macos-10.15-x86_64.zip -O swiftshader.zip
unzip swiftshader.zip
sudo cmake -E make_directory /usr/local/share/vulkan/icd.d
sudo cp lib/* /usr/local/share/vulkan/icd.d
cp install/lib/*.dylib install/
echo "PYTHONPATH=$GITHUB_WORKSPACE/install/lib:$GITHUB_WORKSPACE/install/python:$GITHUB_WORKSPACE/tests" >> $GITHUB_ENV
if: runner.os == 'macOS'
- name: Set up test environment (Linux)
run: |
wget https://sdk.lunarg.com/sdk/download/${VULKANSDK_VER}/linux/vulkansdk-linux-x86_64-${VULKANSDK_VER}.tar.xz -O vulkansdk.tar.xz
tar xf vulkansdk.tar.xz
sudo cp -P ${VULKANSDK_VER}/x86_64/lib/libvulkan.so* /usr/local/lib/
wget https://github.com/sunnycase/swiftshader/releases/download/v1.0/swiftshader-ubuntu-18.04-x86_64.zip -O swiftshader.zip
unzip swiftshader.zip
sudo cmake -E make_directory /usr/local/share/vulkan/icd.d
sudo cp lib/* /usr/local/share/vulkan/icd.d
cp install/lib/*.so install/
echo "PYTHONPATH=$GITHUB_WORKSPACE/install/lib:$GITHUB_WORKSPACE/install/python:$GITHUB_WORKSPACE/tests" >> $GITHUB_ENV
if: runner.os == 'Linux'
- name: Set up test environment (Windows)
shell: pwsh
run: |
# Invoke-WebRequest -Uri https://sdk.lunarg.com/sdk/download/${env:VULKANSDK_VER}/windows/VulkanSDK-${env:VULKANSDK_VER}-Installer.exe -O VulkanSDK-Installer.exe
# .\VulkanSDK-Installer.exe /S
Invoke-WebRequest -Uri https://github.com/sunnycase/swiftshader/releases/download/v1.0/swiftshader-windows-2019-x86_64.zip -OutFile swiftshader.zip
Expand-Archive swiftshader.zip
Copy-Item swiftshader\lib\vk_swiftshader_icd.json swiftshader\bin\
Copy-Item install/bin/*.dll install/
echo "VK_ICD_FILENAMES=${env:GITHUB_WORKSPACE}/swiftshader/bin/vk_swiftshader_icd.json" >> $env:GITHUB_ENV
echo "PYTHONPATH=${env:GITHUB_WORKSPACE}/install/lib;${env:GITHUB_WORKSPACE}/install/python;${env:GITHUB_WORKSPACE}/tests" >> $env:GITHUB_ENV
echo "PATH=${env:PATH};${env:GITHUB_WORKSPACE}/install/bin" >> $env:GITHUB_ENV
if: runner.os == 'Windows'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: '**/requirements.test.txt'
- name: Install Python Packages
run: pip install -r requirements.test.txt
- name: Create Test Environment
run: mkdir test_results
- name: Test
working-directory: ${{github.workspace}}
shell: bash
env:
NNCASE_COMPILER: ${{github.workspace}}/install/Nncase.Compiler.dll
run: |
dotnet tool install --global dotnet-coverage
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/onnx_basic.xml pytest tests/importer/onnx_/basic/ --doctest-modules --junitxml=test_results/onnx_basic.xml
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/onnx_combine.xml pytest tests/importer/onnx_/combine/ --doctest-modules --junitxml=test_results/onnx_combine.xml
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/tflite_basic.xml pytest tests/importer/tflite_/basic/ --doctest-modules --junitxml=test_results/tflite_basic.xml
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/tflite_combine.xml pytest tests/importer/tflite_/combine/ --doctest-modules --junitxml=test_results/tflite_combine.xml
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/tflite_model.xml pytest tests/importer/tflite_/model/ --doctest-modules --junitxml=test_results/tflite_model.xml
dotnet-coverage collect -s tools/dotnet_coverage.settings.xml -f cobertura -o coverage/ncnn_basic.xml pytest tests/importer/ncnn_/basic/ --doctest-modules --junitxml=test_results/ncnn_basic.xml
dotnet-coverage merge -o coverage.integration.xml -f cobertura -r coverage/*.xml
- name: Upload Coverage
uses: actions/upload-artifact@v3
if: matrix.config.name == 'x86_64-linux'
with:
name: nncase-coverage-integration
path: coverage.integration.xml
if-no-files-found: error
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always() && matrix.config.name == 'x86_64-linux'
with:
files: test_results/*.xml
upload-coverage:
needs: [test-compiler]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: "7.0"
- name: Download Unit Test Coverage
uses: actions/download-artifact@v3
with:
name: nncase-coverage-unit
path: ${{github.workspace}}/coverage
- name: Download Integration Test Coverage
uses: actions/download-artifact@v3
with:
name: nncase-coverage-integration
path: ${{github.workspace}}/coverage
- name: Upload Codecov (Unit)
uses: codecov/codecov-action@v3
with:
files: coverage/coverage.unit.xml
flags: unit
- name: Upload Codecov (Integration)
uses: codecov/codecov-action@v3
with:
files: coverage/coverage.integration.xml
flags: integration
- name: Generate Coverage Report
run: |
dotnet tool install --global dotnet-coverage
dotnet tool install -g dotnet-reportgenerator-globaltool
dotnet-coverage merge -o coverage.xml -f cobertura -r coverage/*.xml
reportgenerator -reports:coverage.xml -targetdir:"coveragereport" -reporttypes:Html
- name: Upload Coverage Report
uses: actions/upload-artifact@v3
with:
name: nncase-coverage-report
path: coveragereport
if-no-files-found: error