Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 214 additions & 60 deletions .github/workflows/build-viewer.yml
Original file line number Diff line number Diff line change
@@ -1,116 +1,270 @@
name: Build Interactive Viewer
# Build & publish dimos-viewer wheels.
#
# Closely follows Rerun's reusable_build_and_upload_wheels.yml pattern:
# - manylinux_2_28 Docker container for Linux builds (same as Rerun)
# - Same Rust toolchain (from rust-toolchain file)
# - Same shell defaults and env conventions
# - GitHub Artifacts instead of GCS for wheel storage
# - Trusted publisher (OIDC) for PyPI instead of API token
#
# Triggers:
# PR → main build + test
# push → main build + test
# tag v* build + test + publish to PyPI + GitHub Release

name: Build & Publish dimos-viewer

on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
id-token: write

defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}

env:
PYTHON_VERSION: "3.10"
PACKAGE_DIR: examples/rust/custom_callback

# ---------------------------------------------------------------------------
jobs:
build-linux:

# -------------------------------------------------------------------
# 1. Rust checks & tests (native Ubuntu, no container needed)
# -------------------------------------------------------------------
check:
name: Cargo check & test
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.92.0
run: |
rustup install
rustup show active-toolchain

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libgtk-3-dev \
libxcb-render0-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libxkbcommon-dev \
libvulkan-dev \
mesa-vulkan-drivers \
xvfb \
libxkbcommon-x11-0

- name: Cache cargo
uses: actions/cache@v4
libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev \
libxcb-xfixes0-dev libxkbcommon-dev libvulkan-dev \
mesa-vulkan-drivers libxkbcommon-x11-0

- uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-check-${{ hashFiles('**/Cargo.lock') }}

- run: cargo check -p custom_callback
- run: cargo test -p custom_callback

# -------------------------------------------------------------------
# 2. Build wheels per platform
# Linux: manylinux_2_28 Docker container (matches Rerun's ci_docker)
# macOS: native runner
# -------------------------------------------------------------------
build-wheel:
name: Build wheel (${{ matrix.platform }})
needs: [check]
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- platform: linux-x64
os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
container: quay.io/pypa/manylinux_2_28_x86_64
compatibility: manylinux_2_28
- platform: macos-arm64
os: macos-14
target: aarch64-apple-darwin
container: ""
compatibility: ""

runs-on: ${{ matrix.os }}
container: ${{ matrix.container || null }}

- name: Build viewer
run: cargo build --release -p custom_callback
steps:
- uses: actions/checkout@v4

# --- Linux (inside manylinux container) ---
- name: Install system dependencies (manylinux)
if: matrix.container != ''
run: |
dnf update -y
dnf install -y \
make automake gcc gcc-c++ kernel-devel \
cmake \
gtk3-devel \
xcb-util-renderutil-devel \
xcb-util-devel \
xcb-util-wm-devel \
libxkbcommon-devel \
openssl-devel \
fontconfig-devel \
freetype-devel \
python3-pip
dnf clean all

- name: Install Rust (manylinux)
if: matrix.container != ''
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
. "$HOME/.cargo/env"
rustup install
rustup show active-toolchain

- name: Install maturin (manylinux)
if: matrix.container != ''
run: |
. "$HOME/.cargo/env"
pip3 install maturin>=1.8.1

- name: Build wheel (manylinux)
if: matrix.container != ''
run: |
. "$HOME/.cargo/env"
maturin build \
--release \
--manifest-path "${{ env.PACKAGE_DIR }}/Cargo.toml" \
--target "${{ matrix.target }}" \
--compatibility "${{ matrix.compatibility }}" \
-i python3 \
--out dist/

# --- macOS (native runner) ---
- name: Install Rust (macOS)
if: matrix.container == ''
run: |
rustup install
rustup show active-toolchain

- name: Run tests
run: cargo test -p custom_callback
- name: Install maturin (macOS)
if: matrix.container == ''
run: |
python3 -m pip install maturin>=1.8.1

- name: Package binary
- name: Build wheel (macOS)
if: matrix.container == ''
run: |
cd target/release
strip custom_callback_viewer
tar -czf dimos-viewer-${{ github.ref_name }}-linux-x64.tar.gz custom_callback_viewer
maturin build \
--release \
--manifest-path "${{ env.PACKAGE_DIR }}/Cargo.toml" \
--target "${{ matrix.target }}" \
--out dist/

- name: Upload artifact
# --- Common ---
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: dimos-viewer-linux-x64
path: target/release/dimos-viewer-*.tar.gz
name: wheel-${{ matrix.platform }}
path: dist/*.whl

# -------------------------------------------------------------------
# 3. Test installed wheels
# -------------------------------------------------------------------
test-wheel:
name: Test wheel (py${{ matrix.python-version }})
needs: [build-wheel]
strategy:
matrix:
python-version: ["3.10", "3.12"]
runs-on: ubuntu-22.04

build-macos:
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v5
with:
toolchain: 1.92.0
python-version: ${{ matrix.python-version }}

- name: Cache cargo
uses: actions/cache@v4
- name: Download linux-x64 wheel
uses: actions/download-artifact@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
name: wheel-linux-x64
path: dist/

- name: Build viewer
run: cargo build --release -p custom_callback
- name: Install wheel + test deps
run: |
pip install dist/*.whl
pip install pytest

- name: Run tests
run: cargo test -p custom_callback
- name: Run Python tests
run: pytest "${{ env.PACKAGE_DIR }}/tests/" -v

- name: Package binary
- name: Verify CLI entry point
run: |
cd target/release
strip custom_callback_viewer
tar -czf dimos-viewer-${{ github.ref_name }}-macos-arm64.tar.gz custom_callback_viewer
which dimos-viewer
python -c "from dimos_viewer import __version__; print(f'dimos-viewer v{__version__}')"
python -c "from dimos_viewer import _find_viewer_binary; print(f'binary: {_find_viewer_binary()}')"

- name: Upload artifact
uses: actions/upload-artifact@v4
# -------------------------------------------------------------------
# 4. Publish to PyPI (tag v* only)
# Uses trusted publisher (OIDC) — no API token needed.
# -------------------------------------------------------------------
publish-pypi:
name: Publish to PyPI
needs: [test-wheel]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04
permissions:
id-token: write

steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheel-*
merge-multiple: true
path: dist/

- run: ls -la dist/

- name: Publish to PyPI (trusted publisher)
uses: pypa/gh-action-pypi-publish@release/v1
with:
name: dimos-viewer-macos-arm64
path: target/release/dimos-viewer-*.tar.gz
packages-dir: dist/
skip-existing: true

release:
needs: [build-linux, build-macos]
runs-on: ubuntu-22.04
# -------------------------------------------------------------------
# 5. GitHub Release (tag v* only)
# -------------------------------------------------------------------
github-release:
name: GitHub Release
needs: [publish-pypi]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-22.04

steps:
- name: Download all artifacts
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheel-*
merge-multiple: true
path: release/
path: dist/

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release/dimos-viewer-*.tar.gz
files: dist/*.whl
generate_release_notes: true
10 changes: 10 additions & 0 deletions examples/rust/custom_callback/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Python
__pycache__/
*.pyc
*.egg-info/
dist/
build/
.pytest_cache/

# Maturin build artifacts
target/
6 changes: 1 addition & 5 deletions examples/rust/custom_callback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ license = "MIT OR Apache-2.0"
publish = false

[[bin]]
name = "custom_callback_viewer"
name = "dimos-viewer"
path = "src/viewer.rs"

[[bin]]
name = "custom_callback_app"
path = "src/app.rs"

[features]
default = []

Expand Down
Loading
Loading