-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
353 lines (308 loc) · 13.8 KB
/
Copy pathmanylinux.yml
File metadata and controls
353 lines (308 loc) · 13.8 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
name: manylinux
on:
pull_request:
types: [synchronize, opened]
push:
branches:
- main
permissions:
contents: read
packages: read
env:
DEBIAN_FRONTEND: noninteractive
OPENCV_VERSION: 5.0.0
MEDIAMTX_VERSION: 1.19.3
jobs:
# ---------------------------------------------------------------------------
# Build full libOpenCvSharpExtern.so inside manylinux_2_28.
# Static deps (FFmpeg via build_static_deps.sh cached in /opt/ffmpeg;
# image libs + Tesseract + Leptonica via vcpkg cached in vcpkg_installed/)
# The resulting .so depends only on glibc / libstdc++ system libraries.
# ---------------------------------------------------------------------------
build_full:
name: Linux (x64, full)
runs-on: ubuntu-24.04
container:
image: ghcr.io/shimat/opencvsharp-manylinux@sha256:fdb9a9c223b215604dc7b6f7e8fff4b39bfea5fbaa7777a2e5544a60dfa437f8
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
options: --user root
steps:
- uses: actions/checkout@v7
with:
submodules: true
- uses: ./.github/actions/build-manylinux-variant
with:
opencv_version: ${{ env.OPENCV_VERSION }}
variant_label: full
install_gtk3_devel: 'true'
artifacts_dir: opencv_artifacts
opencv_build_dir: opencv/build
extern_build_dir: src/build
save_shared_caches: 'true'
output_so_name: libOpenCvSharpExtern.so
artifact_name: libOpenCvSharpExtern-full
# ---------------------------------------------------------------------------
# Build headless libOpenCvSharpExtern.so inside manylinux_2_28.
# Same module set as "full" (videoio, dnn, ml, contrib, stitching, barcode, ...)
# but highgui is disabled, so GTK3/X11/Mesa are never linked. Targets
# containerized/headless consumers that need more than the "slim" module set
# but don't want the GTK3 runtime dependency of "full". See issue #2065.
# ---------------------------------------------------------------------------
build_headless:
name: Linux (x64, headless)
runs-on: ubuntu-24.04
container:
image: ghcr.io/shimat/opencvsharp-manylinux@sha256:fdb9a9c223b215604dc7b6f7e8fff4b39bfea5fbaa7777a2e5544a60dfa437f8
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
options: --user root
steps:
- uses: actions/checkout@v7
with:
submodules: true
persist-credentials: false
- uses: ./.github/actions/build-manylinux-variant
with:
opencv_version: ${{ env.OPENCV_VERSION }}
variant_label: headless
install_gtk3_devel: 'false'
artifacts_dir: opencv_artifacts_headless
opencv_build_dir: opencv/build-headless
extern_build_dir: src/build-headless
extra_opencv_cmake_args: -D WITH_GTK=OFF
extra_extern_cmake_args: -D NO_HIGHGUI=ON
verify_gtk_off: 'true'
verify_no_gui_deps: 'true'
save_shared_caches: 'false'
output_so_name: libOpenCvSharpExtern-headless.so
artifact_name: libOpenCvSharpExtern-headless
# ---------------------------------------------------------------------------
# Build slim libOpenCvSharpExtern.so inside manylinux_2_28.
# No external deps needed: OpenCV bundled 3rdparty provides static .a for
# jpeg/png/tiff/webp/zlib internally.
# ---------------------------------------------------------------------------
build_slim:
name: Linux (x64, slim)
runs-on: ubuntu-24.04
container:
image: ghcr.io/shimat/opencvsharp-manylinux@sha256:fdb9a9c223b215604dc7b6f7e8fff4b39bfea5fbaa7777a2e5544a60dfa437f8
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
options: --user root
steps:
- uses: actions/checkout@v7
with:
submodules: true
# -- System tools --------------------------------------------------------
- name: Install system tools
run: dnf install -y ninja-build
- name: Restore OpenCV cache (slim)
id: opencv-cache
uses: actions/cache/restore@v6
with:
path: ${{ github.workspace }}/opencv_artifacts_slim
key: opencv-${{ env.OPENCV_VERSION }}-manylinux2_28-slim-${{ hashFiles('cmake/opencv_build_options_slim.cmake') }}
- name: Configure OpenCV (slim)
if: steps.opencv-cache.outputs.cache-hit != 'true'
run: |
cmake \
-G Ninja \
-C cmake/opencv_build_options_slim.cmake \
-S opencv \
-B opencv/build \
-D OPENCV_EXTRA_MODULES_PATH=${GITHUB_WORKSPACE}/opencv_contrib/modules \
-D CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_artifacts_slim \
-D WITH_TBB=OFF \
-D BUILD_ZLIB=ON
- name: Build OpenCV (slim)
if: steps.opencv-cache.outputs.cache-hit != 'true'
run: |
cmake --build opencv/build -j 3
cmake --install opencv/build
echo "=== opencv_artifacts_slim layout ==="
find ${GITHUB_WORKSPACE}/opencv_artifacts_slim -name 'OpenCVConfig.cmake' -o -name '*.pc' | head -20
du -sh ${GITHUB_WORKSPACE}/opencv_artifacts_slim/*/
- name: Save OpenCV cache (slim)
if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
config=$(find ${GITHUB_WORKSPACE}/opencv_artifacts_slim -name 'OpenCVConfig.cmake' | head -1)
if [ -z "$config" ]; then
echo "ERROR: OpenCVConfig.cmake not found under opencv_artifacts_slim - install is incomplete."
exit 1
fi
echo "Found: $config"
shell: bash
- name: Save OpenCV cache (slim) - upload
if: steps.opencv-cache.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/cache/save@v6
with:
path: ${{ github.workspace }}/opencv_artifacts_slim
key: opencv-${{ env.OPENCV_VERSION }}-manylinux2_28-slim-${{ hashFiles('cmake/opencv_build_options_slim.cmake') }}
- name: Build OpenCvSharpExtern (slim)
run: |
cmake \
-G Ninja \
-S src \
-B src/build-slim \
-D CMAKE_BUILD_TYPE=Release \
-D OpenCV_DIR=${GITHUB_WORKSPACE}/opencv_artifacts_slim/lib64/cmake/opencv5 \
-D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/opencv_artifacts_slim \
-D NO_CONTRIB=ON \
-D NO_VIDEOIO=ON \
-D NO_HIGHGUI=ON \
-D NO_DNN=ON \
-D NO_STITCHING=ON
cmake --build src/build-slim -j
cp src/build-slim/OpenCvSharpExtern/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/libOpenCvSharpExtern-slim.so
- uses: actions/upload-artifact@v7
with:
name: libOpenCvSharpExtern-slim
path: libOpenCvSharpExtern-slim.so
# ---------------------------------------------------------------------------
# Integration test: run the manylinux-built .so on bare Ubuntu 24.04 (no container).
# This validates that a glibc 2.28-built binary works on a newer distro.
# ---------------------------------------------------------------------------
test:
name: Linux (test)
needs: [build_full, build_headless, build_slim]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
submodules: false
- name: Download full artifact
uses: actions/download-artifact@v8
with:
name: libOpenCvSharpExtern-full
path: packaging/nuget/
- name: Download headless artifact
uses: actions/download-artifact@v8
with:
name: libOpenCvSharpExtern-headless
path: nuget-headless/
- name: Download slim artifact
uses: actions/download-artifact@v8
with:
name: libOpenCvSharpExtern-slim
path: nuget-slim/
- name: Install .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
- name: Start local RTSP test server
run: |
docker run --detach --rm \
--name opencvsharp-rtsp \
--publish 8554:8554 \
--volume "${GITHUB_WORKSPACE}/test/rtsp/mediamtx.yml:/mediamtx.yml:ro" \
bluenviron/mediamtx:${MEDIAMTX_VERSION}@sha256:7797ed3df88df21e8c04ecd0aff08ce49a5232d1db453e51f5480ef36bc80865
for attempt in $(seq 1 30); do
if docker logs opencvsharp-rtsp 2>&1 | grep -q "stream is available"; then
exit 0
fi
sleep 1
done
docker logs opencvsharp-rtsp
exit 1
- name: Test (full)
env:
OPENCVSHARP_TEST_RTSP_URL: rtsp://127.0.0.1:8554/test
run: |
cd ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests
dotnet build -c Release -f net10.0
cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so bin/Release/net10.0/
cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so ./
sudo cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so /usr/lib/
LD_LIBRARY_PATH=. dotnet test --project OpenCvSharp.Tests.csproj -c Release -f net10.0 --runtime linux-x64 \
--results-directory TestResults --report-xunit-trx --report-xunit-trx-filename test-results.trx < /dev/null
- name: Test Avalonia extensions
run: |
cd ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests.Avalonia
dotnet build -c Release -f net10.0
cp ${GITHUB_WORKSPACE}/packaging/nuget/libOpenCvSharpExtern.so bin/Release/net10.0/
LD_LIBRARY_PATH=. dotnet test --project OpenCvSharp.Tests.Avalonia.csproj -c Release -f net10.0 --runtime linux-x64 < /dev/null
# Headless has the same module set as full except highgui, so it runs the same xunit
# suite minus the one test class that calls into highgui (WaitKey/PollKey/...).
- name: Test (headless)
env:
OPENCVSHARP_TEST_RTSP_URL: rtsp://127.0.0.1:8554/test
run: |
cd ${GITHUB_WORKSPACE}/test/OpenCvSharp.Tests
cp ${GITHUB_WORKSPACE}/nuget-headless/libOpenCvSharpExtern-headless.so bin/Release/net10.0/libOpenCvSharpExtern.so
cp ${GITHUB_WORKSPACE}/nuget-headless/libOpenCvSharpExtern-headless.so ./libOpenCvSharpExtern.so
sudo cp ${GITHUB_WORKSPACE}/nuget-headless/libOpenCvSharpExtern-headless.so /usr/lib/libOpenCvSharpExtern.so
LD_LIBRARY_PATH=. dotnet test --project OpenCvSharp.Tests.csproj -c Release -f net10.0 --runtime linux-x64 --no-build \
--filter-not-class OpenCvSharp.Tests.HighGui.HighGuiTest \
--results-directory TestResults --report-xunit-trx --report-xunit-trx-filename test-results-headless.trx < /dev/null
- name: Stop local RTSP test server
if: always()
run: docker stop opencvsharp-rtsp >/dev/null 2>&1 || true
- name: Smoke test (slim)
run: |
cd ${GITHUB_WORKSPACE}/nuget-slim/
mv libOpenCvSharpExtern-slim.so libOpenCvSharpExtern.so
echo -ne "#include <stdio.h>\nint core_Mat_sizeof(); int main(){ int i = core_Mat_sizeof(); printf(\"sizeof(Mat) = %d\", i); return 0; }" > test.c
gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern
LD_LIBRARY_PATH=. ./test
- uses: actions/upload-artifact@v7
with:
name: test-results-manylinux
path: test/OpenCvSharp.Tests/TestResults/test-results*.trx
# ---------------------------------------------------------------------------
# Create NuGet packages from the manylinux-built binaries.
# Only runs on push to main.
# ---------------------------------------------------------------------------
nuget:
name: Linux (nuget)
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- name: Download full artifact
uses: actions/download-artifact@v8
with:
name: libOpenCvSharpExtern-full
path: /tmp/so-full/
- name: Download headless artifact
uses: actions/download-artifact@v8
with:
name: libOpenCvSharpExtern-headless
path: /tmp/so-headless/
- name: Download slim artifact
uses: actions/download-artifact@v8
with:
name: libOpenCvSharpExtern-slim
path: /tmp/so-slim/
- name: Install .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
- name: Create NuGet packages
env:
BETA: "-beta"
run: |
yyyymmdd=$(date '+%Y%m%d')
version="${OPENCV_VERSION}.${yyyymmdd}${BETA}"
echo "Package version: $version"
# Full package
cp /tmp/so-full/libOpenCvSharpExtern.so packaging/nuget/libOpenCvSharpExtern.so
dotnet pack packaging/nuget/OpenCvSharp5.official.runtime.linux-x64.csproj \
-o ${GITHUB_WORKSPACE}/artifacts -p:Version=$version
# Headless package (overwrite .so in packaging/nuget/ with headless binary)
cp /tmp/so-headless/libOpenCvSharpExtern-headless.so packaging/nuget/libOpenCvSharpExtern.so
dotnet pack packaging/nuget/OpenCvSharp5.official.runtime.linux-x64.headless.csproj \
-o ${GITHUB_WORKSPACE}/artifacts -p:Version=$version
# Slim package (overwrite .so in packaging/nuget/ with slim binary)
cp /tmp/so-slim/libOpenCvSharpExtern-slim.so packaging/nuget/libOpenCvSharpExtern.so
dotnet pack packaging/nuget/OpenCvSharp5.official.runtime.linux-x64.slim.csproj \
-o ${GITHUB_WORKSPACE}/artifacts -p:Version=$version
ls ${GITHUB_WORKSPACE}/artifacts
- uses: actions/upload-artifact@v7
with:
name: nuget-packages-manylinux
path: artifacts