unitforge 0.3.13

A library for unit and quantity consistent computations in Rust
Documentation
image: "rust:latest"

lint:
  script:
    - rustup component add clippy
    - cargo clippy --no-deps -- -D warnings
  allow_failure: true

lint_serde:
  script:
    - rustup component add clippy
    - cargo clippy -F serde --no-deps -- -D warnings
  allow_failure: true

lint_strum:
  script:
    - rustup component add clippy
    - cargo clippy -F strum --no-deps -- -D warnings
  allow_failure: true

lint_pyo3:
  script:
    - rustup component add clippy
    - cargo clippy -F pyo3 --no-deps -- -D warnings
  allow_failure: true

test:
  script:
    - rustc --version && cargo --version
    - cargo test --workspace --verbose

test_serde:
  script:
    - rustc --version && cargo --version
    - cargo test -F serde --workspace

test_strum:
  script:
    - cargo test -F strum --workspace

test_pyo3:
  script:
    - apt-get update && apt-get install -y python3 python3-venv python3.13-dev
    - python3 -m venv .venv
    - source .venv/bin/activate
    - pip install --upgrade pip setuptools wheel maturin pytest numpy
    - python scripts/generate_python_stubs.py
    - maturin develop --features pyo3
    - pytest tests
    - deactivate

typecheck_pyo3_stubs:
  script:
    - apt-get update && apt-get install -y python3 python3-venv python3.13-dev
    - python3 -m venv .venv
    - source .venv/bin/activate
    - pip install --upgrade pip setuptools wheel maturin numpy "mypy==1.8.0"
    - python scripts/generate_python_stubs.py
    - python scripts/generate_python_stubs.py --check
    - MYPYPATH=python mypy --python-version 3.7 tests/typecheck/mypy_smoke.py
    - maturin build --features pyo3 --out dist
    - |
      python - <<'PY'
      import glob
      import zipfile

      wheels = sorted(glob.glob("dist/*.whl"))
      if not wheels:
          raise SystemExit("No wheels built in dist/")

      required = {
          "unitforge/__init__.py",
          "unitforge/__init__.pyi",
          "unitforge/py.typed",
      }
      with zipfile.ZipFile(wheels[-1]) as wheel:
          names = set(wheel.namelist())
      missing = sorted(required - names)
      if missing:
          raise SystemExit(f"Wheel is missing required typing artifacts: {missing}")
      print("Wheel typing artifacts verified.")
      PY
    - pip install --force-reinstall --no-deps dist/*.whl
    - TMP_DIR="$(mktemp -d)"
    - cp tests/typecheck/mypy_smoke.py "$TMP_DIR"/
    - (cd "$TMP_DIR" && mypy --python-version 3.7 mypy_smoke.py)
    - deactivate