-
-
Notifications
You must be signed in to change notification settings - Fork 16
301 lines (238 loc) · 10.7 KB
/
Copy pathci.yml
File metadata and controls
301 lines (238 loc) · 10.7 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
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
name: CI
permissions:
contents: read
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 0 * * *"
env:
CARGO_TERM_COLOR: always
# CI builds don't need debuginfo; dropping it cuts crate compile+link
CARGO_PROFILE_DEV_DEBUG: "0"
CARGO_PROFILE_TEST_DEBUG: "0"
# Incremental compilation adds overhead and never hits on cold CI runners.
CARGO_INCREMENTAL: "0"
jobs:
# Cross-platform tests (default features only - no video/ffmpeg required)
test:
name: test / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
# macos-latest's default Xcode 16.4 toolchain dangles libclang_rt.osx.a
# (ld: library 'clang_rt.osx' not found). Select a present, known-good
# Xcode and export its version so the Rust cache key is scoped to it -
# otherwise a cache built under one image's Xcode dangles on another.
- name: Select Xcode (macOS)
if: matrix.os == 'macos-latest'
run: |
sudo xcode-select -s "$(ls -d /Applications/Xcode_*.app | grep -vE 'beta|16\.4' | sort -V | tail -1)"
xcodebuild -version
echo "XCODE_VER=$(xcodebuild -version | head -1 | awk '{print $2}')" >> "$GITHUB_ENV"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
# Formatting is platform-independent; check it once instead of on every OS.
- name: Format
if: matrix.os == 'ubuntu-latest'
run: cargo fmt --all -- --check
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
key: xcode-${{ env.XCODE_VER }}
- name: Ensure toolchain
run: rustup show
- name: Clippy (annotate feature)
if: matrix.os != 'macos-latest'
run: cargo clippy --all-targets --no-default-features --features annotate -- -D warnings
- name: Tests (annotate feature)
if: matrix.os != 'macos-latest'
run: cargo test --no-default-features --features annotate
# CoreML is macOS-only — covers issue #148 (GatherElements warmup) and graph_input_cast_0 fix
- name: Clippy (coreml + annotate)
if: matrix.os == 'macos-latest'
run: cargo clippy --all-targets --no-default-features --features "coreml,annotate" -- -D warnings
- name: Tests (coreml + annotate)
if: matrix.os == 'macos-latest'
run: cargo test --no-default-features --features "coreml,annotate"
- name: Integration tests (CoreML regression, including ignored)
if: matrix.os == 'macos-latest'
run: cargo test --no-default-features --features "coreml,annotate" --test integration_test test_coreml_model_loads_and_warms_up -- --ignored --exact
# Video feature tests for Linux - FFmpeg 7 and 8
test-video:
name: test / linux / ffmpeg ${{ matrix.ffmpeg_version }}
runs-on: ubuntu-latest
container: jrottenberg/ffmpeg:${{ matrix.ffmpeg_version }}-ubuntu
strategy:
matrix:
ffmpeg_version: ["8.0", "7.1"]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install dependencies
run: |
DEBIAN_FRONTEND=noninteractive apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential ca-certificates clang curl pkg-config libssl-dev
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
# Key on ffmpeg version so each container gets its own cache
key: ffmpeg-${{ matrix.ffmpeg_version }}
- name: Ensure toolchain
run: rustup show
- name: Clippy (annotate + video)
run: cargo clippy --all --features annotate,video -- -D warnings
- name: Tests (annotate + video)
run: cargo test --all --features annotate,video
# macOS FFmpeg 8 video build test
build-macos-video:
name: build / macos / ffmpeg 8 / video
runs-on: macos-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
# macos-latest's default Xcode 16.4 toolchain dangles libclang_rt.osx.a
# (ld: library 'clang_rt.osx' not found). Select a present, known-good
# Xcode and export its version so the Rust cache key is scoped to it -
# otherwise a cache built under one image's Xcode dangles on another.
- name: Select Xcode (macOS)
run: |
sudo xcode-select -s "$(ls -d /Applications/Xcode_*.app | grep -vE 'beta|16\.4' | sort -V | tail -1)"
xcodebuild -version
echo "XCODE_VER=$(xcodebuild -version | head -1 | awk '{print $2}')" >> "$GITHUB_ENV"
- name: Install dependencies
run: brew install ffmpeg
- name: Capture FFmpeg version for cache key
run: echo "FFMPEG_VERSION=$(brew list --versions ffmpeg | awk '{print $2}')" >> "$GITHUB_ENV"
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
key: ffmpeg-${{ env.FFMPEG_VERSION }}-xcode-${{ env.XCODE_VER }}
- name: Ensure toolchain
run: rustup show
- name: Build (annotate + video features)
run: cargo build --release --features "annotate,video,visualize" --bin ultralytics-inference
# Windows FFmpeg 8 video build test
build-windows-video:
name: build / windows / ffmpeg 8 / video
runs-on: windows-latest
env:
FFMPEG_VERSION: "8.1.1"
FFMPEG_DOWNLOAD_URL: https://github.com/GyanD/codexffmpeg/releases/download/8.1.1/ffmpeg-8.1.1-full_build-shared.7z
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Cache FFmpeg
id: cache-ffmpeg
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ffmpeg
key: windows-ffmpeg-${{ env.FFMPEG_VERSION }}
- name: Download FFmpeg
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: |
Invoke-WebRequest "${env:FFMPEG_DOWNLOAD_URL}" -OutFile ffmpeg-shared.7z
7z x ffmpeg-shared.7z
mkdir ffmpeg
mv ffmpeg-*/* ffmpeg/
- name: Set FFmpeg environment variables
run: |
$VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin"
Add-Content $env:GITHUB_ENV "FFMPEG_DIR=${pwd}\ffmpeg"
Add-Content $env:GITHUB_PATH "${pwd}\ffmpeg\bin"
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Ensure toolchain
run: rustup show
- name: Build (annotate + video features)
run: cargo build --features annotate,video
# Browser/WebAssembly build: guards that the core library stays wasm-compatible
# and that the WebGPU (ort-web) bindings + npm wrapper build end to end.
wasm:
name: wasm / browser
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
components: clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
key: wasm
- name: Ensure toolchain
run: rustup show
# The core crate must keep compiling for wasm without the native backend.
- name: Build core lib for wasm32
run: cargo build -p ultralytics-inference --lib --no-default-features --target wasm32-unknown-unknown
- name: Clippy WebGPU bindings (wasm32)
run: cargo clippy -p ultralytics-inference-web --target wasm32-unknown-unknown -- -D warnings
- name: Install wasm-pack
uses: taiki-e/install-action@c7eb1735f09259a5035e8e5d44b1406b1cddc0fb # v2.83.0
with:
tool: wasm-pack
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 20
# Builds the wasm (wasm-pack) and the TypeScript wrapper.
- name: Build npm package
working-directory: web
run: |
npm ci
npm run build
# Code coverage (runs on Ubuntu with FFmpeg dev libs for full feature coverage)
coverage:
name: coverage
runs-on: ubuntu-latest
needs: [test]
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y pkg-config libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libavdevice-dev libswscale-dev libswresample-dev libpostproc-dev clang
- name: Set up Rust
uses: dtolnay/rust-toolchain@nightly
# Nightly toolchain version in rustc -V already gives this job a unique cache key
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Ensure toolchain
run: rustup show
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@c7eb1735f09259a5035e8e5d44b1406b1cddc0fb # v2.83.0
with:
tool: cargo-llvm-cov
- name: Coverage
# Exclude code that host-side unit tests cannot exercise: the CUDA kernel
# (needs an NVIDIA GPU), the minifb viewer window (GUI), the thin CLI
# entry point, and the wasm32-only web crate.
run: cargo llvm-cov --features annotate,video,visualize --workspace --lcov --output-path lcov.info --ignore-filename-regex '(src/cuda_inference\.rs|src/visualizer/viewer\.rs|src/main\.rs|crates/web/)'
- name: Upload coverage to Codecov
continue-on-error: true
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
files: ./lcov.info
disable_search: true
fail_ci_if_error: false
plugins: noop
flags: template_coverage
use_oidc: true