Skip to content

Commit 0a2a601

Browse files
committed
ci: replace custom build-and-publish.yml with build-viewer.yml
Rework CI workflow to follow Rerun's patterns: - Renamed build-and-publish.yml → build-viewer.yml - Added push-to-main trigger alongside PR and tag triggers - Simplified wheel build: removed redundant --interpreter flag (bindings='bin' produces py3-none universal wheels) - Added concurrency group to cancel stale runs - Added workflow_dispatch for manual triggers - Cleaner job structure: check → build-wheel → test-wheel → publish → release - Uses GitHub Artifacts for wheel storage (not GCS) - Publish to PyPI via maturin upload on v* tags only Rerun's reusable_build_and_upload_wheels.yml cannot be called directly because it is tightly coupled to building rerun_py (uses pixi, GCS sccache, rerun-cli download, and rerun_py-specific feature flags). Instead, this workflow follows the same structural patterns: platform matrix, manylinux_2_28 compat, artifact upload per platform.
1 parent 63d28cb commit 0a2a601

1 file changed

Lines changed: 103 additions & 98 deletions

File tree

Lines changed: 103 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,56 @@
1+
# Build & publish dimos-viewer wheels.
2+
#
3+
# Modelled on Rerun's reusable_build_and_upload_wheels / reusable_publish_wheels
4+
# but adapted for the dimos-viewer binary package:
5+
# - Uses standard GitHub runners (no self-hosted)
6+
# - Uses GitHub Artifacts instead of GCS for wheel storage
7+
# - Builds with `maturin build` (bindings = "bin") instead of rerun_py
8+
#
9+
# Triggers:
10+
# PR → main build + test
11+
# push → main build + test
12+
# tag v* build + test + publish to PyPI + GitHub Release
13+
114
name: Build & Publish dimos-viewer
215

316
on:
417
push:
18+
branches: [main]
519
tags: ['v*']
620
pull_request:
721
branches: [main]
822
workflow_dispatch:
923

24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
1028
permissions:
11-
contents: write # for GitHub Releases
29+
contents: write
30+
id-token: write
31+
32+
defaults:
33+
run:
34+
shell: bash
1235

1336
env:
1437
RUST_TOOLCHAIN: "1.92.0"
38+
PYTHON_VERSION: "3.10"
39+
PACKAGE_DIR: examples/rust/custom_callback
1540

41+
# ---------------------------------------------------------------------------
1642
jobs:
17-
# ---------------------------------------------------------------
18-
# Rust Tests
19-
# ---------------------------------------------------------------
20-
test-rust:
21-
name: Rust Tests
43+
44+
# -------------------------------------------------------------------
45+
# 1. Rust checks & tests
46+
# -------------------------------------------------------------------
47+
check:
48+
name: Cargo check & test
2249
runs-on: ubuntu-22.04
2350
steps:
2451
- uses: actions/checkout@v4
2552

26-
- name: Install Rust
27-
uses: dtolnay/rust-toolchain@stable
53+
- uses: dtolnay/rust-toolchain@stable
2854
with:
2955
toolchain: ${{ env.RUST_TOOLCHAIN }}
3056

@@ -36,71 +62,55 @@ jobs:
3662
libxcb-xfixes0-dev libxkbcommon-dev libvulkan-dev \
3763
mesa-vulkan-drivers libxkbcommon-x11-0
3864
39-
- name: Cache cargo
40-
uses: actions/cache@v4
65+
- uses: actions/cache@v4
4166
with:
4267
path: |
4368
~/.cargo/registry/index/
4469
~/.cargo/registry/cache/
4570
~/.cargo/git/db/
4671
target/
47-
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
72+
key: ${{ runner.os }}-cargo-check-${{ hashFiles('**/Cargo.lock') }}
4873

49-
- name: Run Rust tests
50-
run: cargo test -p custom_callback
74+
- run: cargo check -p custom_callback
75+
- run: cargo test -p custom_callback
5176

52-
# ---------------------------------------------------------------
53-
# Build Wheels (matrix: linux-x64, linux-arm64, macos-arm64)
54-
# ---------------------------------------------------------------
77+
# -------------------------------------------------------------------
78+
# 2. Build wheels (one job per platform)
79+
# Mirrors the matrix approach from reusable_build_and_upload_wheels.yml
80+
# -------------------------------------------------------------------
5581
build-wheel:
56-
name: Build Wheel (${{ matrix.platform }})
57-
needs: [test-rust]
82+
name: Build wheel (${{ matrix.platform }})
83+
needs: [check]
5884
strategy:
5985
fail-fast: false
6086
matrix:
6187
include:
6288
- platform: linux-x64
6389
os: ubuntu-22.04
6490
target: x86_64-unknown-linux-gnu
65-
maturin_args: "--compatibility manylinux_2_28"
91+
compatibility: manylinux_2_28
6692
- platform: linux-arm64
6793
os: ubuntu-22.04
6894
target: aarch64-unknown-linux-gnu
69-
maturin_args: "--compatibility manylinux_2_28"
95+
compatibility: manylinux_2_28
7096
- platform: macos-arm64
7197
os: macos-14
7298
target: aarch64-apple-darwin
73-
maturin_args: ""
99+
compatibility: ""
100+
74101
runs-on: ${{ matrix.os }}
75102

76103
steps:
77104
- uses: actions/checkout@v4
78105

79-
- name: Install Rust
80-
uses: dtolnay/rust-toolchain@stable
106+
- uses: dtolnay/rust-toolchain@stable
81107
with:
82108
toolchain: ${{ env.RUST_TOOLCHAIN }}
83109
targets: ${{ matrix.target }}
84110

85-
- name: Set up Python 3.10
86-
uses: actions/setup-python@v5
111+
- uses: actions/setup-python@v5
87112
with:
88-
python-version: "3.10"
89-
90-
- name: Set up Python 3.11
91-
uses: actions/setup-python@v5
92-
with:
93-
python-version: "3.11"
94-
95-
- name: Set up Python 3.12
96-
uses: actions/setup-python@v5
97-
with:
98-
python-version: "3.12"
99-
100-
- name: Set up Python 3.13
101-
uses: actions/setup-python@v5
102-
with:
103-
python-version: "3.13"
113+
python-version: ${{ env.PYTHON_VERSION }}
104114

105115
- name: Install maturin
106116
run: pip install maturin>=1.8.1
@@ -110,137 +120,132 @@ jobs:
110120
run: |
111121
sudo apt-get update
112122
sudo apt-get install -y \
113-
libgtk-3-dev \
114-
libxcb-render0-dev \
115-
libxcb-shape0-dev \
116-
libxcb-xfixes0-dev \
117-
libxkbcommon-dev \
118-
libvulkan-dev \
119-
mesa-vulkan-drivers \
120-
libxkbcommon-x11-0
121-
122-
- name: Install cross-compilation tools (Linux ARM64)
123+
libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev \
124+
libxcb-xfixes0-dev libxkbcommon-dev libvulkan-dev \
125+
mesa-vulkan-drivers libxkbcommon-x11-0
126+
127+
- name: Install cross-compilation toolchain (Linux ARM64)
123128
if: matrix.target == 'aarch64-unknown-linux-gnu'
124129
run: |
125130
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
126-
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
131+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
127132
128-
- name: Cache cargo
129-
uses: actions/cache@v4
133+
- uses: actions/cache@v4
130134
with:
131135
path: |
132136
~/.cargo/registry/index/
133137
~/.cargo/registry/cache/
134138
~/.cargo/git/db/
135139
target/
136-
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
140+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-wheel-${{ hashFiles('**/Cargo.lock') }}
137141

138-
- name: Build wheels with maturin
142+
- name: Build wheel
139143
run: |
144+
COMPAT_ARG=""
145+
if [ -n "${{ matrix.compatibility }}" ]; then
146+
COMPAT_ARG="--compatibility ${{ matrix.compatibility }}"
147+
fi
140148
maturin build \
141149
--release \
142-
--manifest-path examples/rust/custom_callback/Cargo.toml \
143-
--target ${{ matrix.target }} \
144-
--interpreter python3.10 python3.11 python3.12 python3.13 \
145-
${{ matrix.maturin_args }} \
150+
--manifest-path "${{ env.PACKAGE_DIR }}/Cargo.toml" \
151+
--target "${{ matrix.target }}" \
152+
$COMPAT_ARG \
146153
--out dist/
147154
148-
- name: Upload wheel artifacts
155+
- name: Upload wheel artifact
149156
uses: actions/upload-artifact@v4
150157
with:
151-
name: wheels-${{ matrix.platform }}
158+
name: wheel-${{ matrix.platform }}
152159
path: dist/*.whl
153160

154-
# ---------------------------------------------------------------
155-
# Python Tests (run after building the native wheel)
156-
# ---------------------------------------------------------------
157-
test-python:
158-
name: Python Tests (py${{ matrix.python-version }})
161+
# -------------------------------------------------------------------
162+
# 3. Test installed wheels
163+
# -------------------------------------------------------------------
164+
test-wheel:
165+
name: Test wheel (py${{ matrix.python-version }})
159166
needs: [build-wheel]
160167
strategy:
161168
matrix:
162169
python-version: ["3.10", "3.12"]
163170
runs-on: ubuntu-22.04
171+
164172
steps:
165173
- uses: actions/checkout@v4
166174

167-
- name: Set up Python
168-
uses: actions/setup-python@v5
175+
- uses: actions/setup-python@v5
169176
with:
170177
python-version: ${{ matrix.python-version }}
171178

172-
- name: Download linux-x64 wheels
179+
- name: Download linux-x64 wheel
173180
uses: actions/download-artifact@v4
174181
with:
175-
name: wheels-linux-x64
182+
name: wheel-linux-x64
176183
path: dist/
177184

178-
- name: Install wheel and test dependencies
185+
- name: Install wheel + test deps
179186
run: |
180-
# Find the wheel matching our Python version
181-
WHEEL=$(ls dist/*cp$(echo ${{ matrix.python-version }} | tr -d '.')*.whl | head -1)
182-
pip install "$WHEEL"
187+
pip install dist/*.whl
183188
pip install pytest
184189
185190
- name: Run Python tests
186-
run: |
187-
pytest examples/rust/custom_callback/tests/ -v
191+
run: pytest "${{ env.PACKAGE_DIR }}/tests/" -v
188192

189193
- name: Verify CLI entry point
190194
run: |
191195
which dimos-viewer
192196
python -c "from dimos_viewer import __version__; print(f'dimos-viewer v{__version__}')"
193-
python -c "from dimos_viewer import _find_viewer_binary; print(f'Binary: {_find_viewer_binary()}')"
197+
python -c "from dimos_viewer import _find_viewer_binary; print(f'binary: {_find_viewer_binary()}')"
194198
195-
# ---------------------------------------------------------------
196-
# Publish to PyPI (on tag push only)
197-
# ---------------------------------------------------------------
199+
# -------------------------------------------------------------------
200+
# 4. Publish to PyPI (tag v* only)
201+
# Mirrors reusable_publish_wheels.yml but pulls from GitHub Artifacts
202+
# instead of GCS, then uploads via `maturin upload`.
203+
# -------------------------------------------------------------------
198204
publish-pypi:
199205
name: Publish to PyPI
200-
needs: [test-python, build-wheel]
201-
runs-on: ubuntu-22.04
206+
needs: [test-wheel]
202207
if: startsWith(github.ref, 'refs/tags/v')
208+
runs-on: ubuntu-22.04
203209
environment: pypi
204210
permissions:
205-
id-token: write # for trusted publishing
211+
id-token: write
212+
206213
steps:
207214
- name: Download all wheels
208215
uses: actions/download-artifact@v4
209216
with:
210-
pattern: wheels-*
217+
pattern: wheel-*
211218
merge-multiple: true
212219
path: dist/
213220

214-
- name: List wheels
215-
run: ls -la dist/
221+
- run: ls -la dist/
216222

217-
- name: Set up Python
218-
uses: actions/setup-python@v5
223+
- uses: actions/setup-python@v5
219224
with:
220-
python-version: "3.10"
225+
python-version: ${{ env.PYTHON_VERSION }}
221226

222227
- name: Install maturin
223228
run: pip install maturin>=1.8.1
224229

225230
- name: Publish to PyPI
226231
env:
227232
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
228-
run: |
229-
maturin upload --skip-existing dist/*.whl
233+
run: maturin upload --skip-existing dist/*.whl
230234

231-
# ---------------------------------------------------------------
232-
# GitHub Release (on tag push only)
233-
# ---------------------------------------------------------------
235+
# -------------------------------------------------------------------
236+
# 5. GitHub Release (tag v* only)
237+
# -------------------------------------------------------------------
234238
github-release:
235239
name: GitHub Release
236-
needs: [build-wheel]
237-
runs-on: ubuntu-22.04
240+
needs: [publish-pypi]
238241
if: startsWith(github.ref, 'refs/tags/v')
242+
runs-on: ubuntu-22.04
243+
239244
steps:
240245
- name: Download all wheels
241246
uses: actions/download-artifact@v4
242247
with:
243-
pattern: wheels-*
248+
pattern: wheel-*
244249
merge-multiple: true
245250
path: dist/
246251

0 commit comments

Comments
 (0)