Skip to content

Commit 05df88d

Browse files
authored
Merge pull request #1 from espetro/ci-release
feat: v0.1.0 - drop OpenCV, cross-platform CI + releases, dev harness
2 parents 3d07078 + 68e7cb8 commit 05df88d

25 files changed

Lines changed: 28944 additions & 675 deletions

‎.clang-format‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# based on LLVM style (matches the brace/indent conventions in src/), with a
2+
# generous column limit to keep churn on existing code minimal
3+
BasedOnStyle: LLVM
4+
Language: Cpp
5+
ColumnLimit: 120
6+
IndentWidth: 4
7+
TabWidth: 4
8+
UseTab: Never
9+
PointerAlignment: Right
10+
DerivePointerAlignment: false
11+
AllowShortFunctionsOnASingleLine: Inline
12+
AllowShortIfStatementsOnASingleLine: false
13+
AllowShortLoopsOnASingleLine: false
14+
SortIncludes: Never
15+
AlignConsecutiveAssignments: Consecutive
16+
AlignConsecutiveDeclarations: Consecutive
17+
IncludeBlocks: Preserve
18+
InsertBraces: true
19+
FixNamespaceComments: true

‎.clang-tidy‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# conservative starter config; warnings are not errors
2+
Checks: >
3+
bugprone-*,
4+
performance-*,
5+
readability-*,
6+
-bugprone-easily-swappable-parameters,
7+
-readability-magic-numbers,
8+
-readability-identifier-length,
9+
-readability-function-cognitive-complexity,
10+
-readability-implicit-bool-conversion
11+
12+
WarningsAsErrors: ''
13+
HeaderFilterRegex: '^(src|tests)/.*\.h$'
14+
FormatStyle: file

‎.github/workflows/build.yml‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: build
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches-ignore:
7+
- master
8+
9+
concurrency:
10+
group: ci-${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
submodules: recursive
23+
24+
- name: Install ninja and ccache
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y ninja-build ccache
28+
29+
- name: ccache
30+
uses: ggml-org/ccache-action@v1.2.21
31+
with:
32+
max-size: 500MB
33+
evict-old-files: 7d
34+
save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
35+
36+
- name: Configure
37+
run: >-
38+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
39+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
40+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
41+
-DCMAKE_INSTALL_RPATH='$ORIGIN'
42+
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
43+
44+
- name: Build
45+
run: cmake --build build -j"$(nproc)"
46+
47+
sanitize:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v4
51+
with:
52+
submodules: recursive
53+
54+
- name: Install ninja
55+
run: |
56+
sudo apt-get update
57+
sudo apt-get install -y ninja-build
58+
59+
- name: Configure (ASan + UBSan)
60+
run: >-
61+
cmake -B build-sanitize -G Ninja
62+
-DCMAKE_BUILD_TYPE=Debug
63+
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"
64+
-DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"
65+
66+
- name: Build
67+
run: cmake --build build-sanitize -j"$(nproc)"
68+
69+
- name: Test
70+
run: ctest --test-dir build-sanitize --output-on-failure
71+
72+
lint:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v4
76+
77+
- name: Install clang-format
78+
run: sudo apt-get update && sudo apt-get install -y clang-format-18
79+
80+
- name: clang-format check
81+
run: >-
82+
clang-format-18 --dry-run --Werror
83+
src/image.cpp src/image.h
84+
inference.cpp dinov2.cpp dinov2.h quantize.cpp
85+
tests/test_image.cpp

‎.github/workflows/release.yml‎

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
concurrency:
9+
group: ci-${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: false
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
ubuntu-x64:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
23+
- name: Cache apt packages
24+
uses: actions/cache@v4
25+
with:
26+
path: /var/cache/apt/archives
27+
key: apt-${{ runner.os }}-x64-${{ hashFiles('.github/workflows/release.yml') }}
28+
restore-keys: apt-${{ runner.os }}-x64-
29+
30+
- name: Install build packages
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y ninja-build ccache cmake
34+
dpkg-query -W -f='${Package} ${Version}\n' ninja-build ccache cmake > /tmp/apt-fingerprint.txt
35+
36+
- name: ccache
37+
uses: ggml-org/ccache-action@v1.2.21
38+
with:
39+
max-size: 500MB
40+
evict-old-files: 7d
41+
42+
- name: Configure
43+
run: >-
44+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
45+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
46+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
47+
-DCMAKE_INSTALL_RPATH='$ORIGIN'
48+
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
49+
-DBUILD_SHARED_LIBS=OFF
50+
51+
- name: Build
52+
run: cmake --build build -j"$(nproc)"
53+
54+
- name: Package
55+
run: |
56+
mkdir -p stage/bin
57+
cp build/bin/inference build/bin/quantize stage/bin/
58+
tar -czf "dinov2-${{ github.ref_name }}-bin-ubuntu-x64.tar.gz" -C stage bin
59+
60+
- uses: actions/upload-artifact@v4
61+
with:
62+
name: dinov2-bin-linux-x64
63+
path: dinov2-*-bin-ubuntu-x64.tar.gz
64+
if-no-files-found: error
65+
66+
ubuntu-arm64:
67+
runs-on: ubuntu-24.04-arm
68+
steps:
69+
- uses: actions/checkout@v4
70+
with:
71+
submodules: recursive
72+
73+
- name: Cache apt packages
74+
uses: actions/cache@v4
75+
with:
76+
path: /var/cache/apt/archives
77+
key: apt-${{ runner.os }}-arm64-${{ hashFiles('.github/workflows/release.yml') }}
78+
restore-keys: apt-${{ runner.os }}-arm64-
79+
80+
- name: Install build packages
81+
run: |
82+
sudo apt-get update
83+
sudo apt-get install -y ninja-build ccache cmake
84+
dpkg-query -W -f='${Package} ${Version}\n' ninja-build ccache cmake > /tmp/apt-fingerprint.txt
85+
86+
- name: ccache
87+
uses: ggml-org/ccache-action@v1.2.21
88+
with:
89+
max-size: 500MB
90+
evict-old-files: 7d
91+
92+
- name: Configure
93+
run: >-
94+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
95+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
96+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
97+
-DCMAKE_INSTALL_RPATH='$ORIGIN'
98+
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
99+
-DBUILD_SHARED_LIBS=OFF
100+
101+
- name: Build
102+
run: cmake --build build -j"$(nproc)"
103+
104+
- name: Package
105+
run: |
106+
mkdir -p stage/bin
107+
cp build/bin/inference build/bin/quantize stage/bin/
108+
tar -czf "dinov2-${{ github.ref_name }}-bin-ubuntu-arm64.tar.gz" -C stage bin
109+
110+
- uses: actions/upload-artifact@v4
111+
with:
112+
name: dinov2-bin-linux-arm64
113+
path: dinov2-*-bin-ubuntu-arm64.tar.gz
114+
if-no-files-found: error
115+
116+
macos-arm64:
117+
runs-on: macos-latest
118+
steps:
119+
- uses: actions/checkout@v4
120+
with:
121+
submodules: recursive
122+
123+
- name: Cache brew formulas
124+
uses: actions/cache@v4
125+
with:
126+
path: |
127+
/usr/local/Cellar/ninja
128+
/usr/local/Cellar/ccache
129+
/opt/homebrew/Cellar/ninja
130+
/opt/homebrew/Cellar/ccache
131+
key: brew-${{ runner.os }}-${{ runner.arch }}-ninja-ccache
132+
restore-keys: brew-${{ runner.os }}-${{ runner.arch }}-
133+
134+
- name: Install build packages
135+
run: |
136+
brew install ninja ccache
137+
brew link --overwrite ninja ccache
138+
139+
- name: ccache
140+
uses: ggml-org/ccache-action@v1.2.21
141+
with:
142+
max-size: 500MB
143+
evict-old-files: 7d
144+
145+
- name: Configure
146+
run: >-
147+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
148+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
149+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
150+
-DCMAKE_BUILD_RPATH='@loader_path'
151+
-DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
152+
-DBUILD_SHARED_LIBS=OFF
153+
154+
- name: Build
155+
run: cmake --build build -j"$(sysctl -n hw.logicalcpu)"
156+
157+
- name: Package
158+
run: |
159+
mkdir -p stage/bin
160+
cp build/bin/inference build/bin/quantize stage/bin/
161+
tar -czf "dinov2-${{ github.ref_name }}-bin-macos-arm64.tar.gz" -C stage bin
162+
163+
- uses: actions/upload-artifact@v4
164+
with:
165+
name: dinov2-bin-macos-arm64
166+
path: dinov2-*-bin-macos-arm64.tar.gz
167+
if-no-files-found: error
168+
169+
windows-x64:
170+
runs-on: windows-latest
171+
env:
172+
SCCACHE_GHA_ENABLED: "true"
173+
SCCACHE_CACHE_SIZE: 500MB
174+
CMAKE_C_COMPILER_LAUNCHER: sccache
175+
CMAKE_CXX_COMPILER_LAUNCHER: sccache
176+
steps:
177+
- uses: actions/checkout@v4
178+
with:
179+
submodules: recursive
180+
181+
- name: sccache
182+
uses: Mozilla-Actions/sccache-action@v0.0.9
183+
184+
- name: Configure
185+
shell: pwsh
186+
run: >-
187+
cmake -B build -G "Ninja Multi-Config"
188+
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
189+
-DCMAKE_BUILD_TYPE=Release
190+
-DBUILD_SHARED_LIBS=OFF
191+
192+
- name: Build
193+
shell: pwsh
194+
run: cmake --build build --config Release
195+
196+
- name: Package
197+
shell: pwsh
198+
run: |
199+
New-Item -ItemType Directory -Force -Path stage/bin | Out-Null
200+
Copy-Item build/bin/Release/inference.exe,build/bin/Release/quantize.exe stage/bin/
201+
Compress-Archive -Path stage/bin -DestinationPath dinov2-bin-win-cpu-x64.zip
202+
203+
- uses: actions/upload-artifact@v4
204+
with:
205+
name: dinov2-bin-win-cpu-x64
206+
path: dinov2-bin-win-cpu-x64.zip
207+
if-no-files-found: error
208+
209+
release:
210+
needs: [ubuntu-x64, ubuntu-arm64, macos-arm64, windows-x64]
211+
runs-on: ubuntu-latest
212+
steps:
213+
- uses: actions/download-artifact@v4
214+
with:
215+
merge-multiple: true
216+
path: dist
217+
218+
- name: Generate checksums
219+
run: |
220+
cd dist
221+
sha256sum * > SHA256SUMS.txt
222+
223+
- name: Publish release
224+
uses: softprops/action-gh-release@v2
225+
with:
226+
files: |
227+
dist/**
228+
generate_release_notes: true

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,5 @@ cmake-build-debug/
496496

497497
.vs/
498498
.vscode/
499+
500+
build*

‎.gitmodules‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "ggml"]
22
path = ggml
3-
url = git@github.com:ggml-org/ggml.git
3+
url = https://github.com/ggml-org/ggml.git
44
branch = master

0 commit comments

Comments
 (0)