video stub replacement #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI (Docker) | |
on: | |
push: | |
branches: [ main, develop ] | |
pull_request: | |
branches: [ main ] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build-container: | |
name: Build Docker Container | |
runs-on: ubuntu-latest | |
outputs: | |
image-digest: ${{ steps.build.outputs.digest }} | |
image-tag: ${{ steps.meta.outputs.tags }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Extract metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }}/ci-runner | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=sha,prefix={{branch}}- | |
- name: Build and push | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
rust-tests: | |
name: Rust Tests | |
runs-on: ubuntu-latest | |
needs: build-container | |
container: | |
image: ${{ needs.build-container.outputs.image-tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo index | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo target | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
- name: Run clippy | |
run: cargo clippy --all-targets --no-default-features --features python-bindings,simd,opencv -- -D warnings | |
- name: Run tests (no Python bindings) | |
run: cargo test --no-default-features --features simd,opencv | |
- name: Compile tests (Linux compatible features) | |
run: cargo test --no-default-features --features python-bindings,simd,opencv --no-run | |
python-tests: | |
name: Python Tests | |
runs-on: ubuntu-latest | |
needs: build-container | |
strategy: | |
matrix: | |
python-version: ["3.11", "3.12"] | |
container: | |
image: ${{ needs.build-container.outputs.image-tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build Python package | |
run: | | |
mkdir -p dist | |
maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv | |
- name: Install built package | |
run: pip install dist/*.whl | |
- name: Install test dependencies | |
run: pip install pytest pytest-benchmark numpy pillow opencv-python | |
- name: Run Python tests | |
run: pytest tests/ -v | |
pre-commit: | |
name: Pre-commit hooks | |
runs-on: ubuntu-latest | |
needs: build-container | |
container: | |
image: ${{ needs.build-container.outputs.image-tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install cargo-audit | |
run: cargo install cargo-audit | |
- name: Install pre-commit | |
run: pip install pre-commit | |
- name: Run pre-commit | |
run: pre-commit run --all-files | |
build-wheels: | |
name: Build wheels | |
runs-on: ubuntu-latest | |
needs: build-container | |
container: | |
image: ${{ needs.build-container.outputs.image-tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build wheels | |
run: | | |
mkdir -p dist | |
maturin build --release --out dist --no-default-features --features python-bindings,simd,opencv | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux | |
path: dist/ |