|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +# Python SDK tasks. Run `mise tasks` to list them and `mise run ci` for the |
| 5 | +# full pipeline. Bindings are generated from core's proto/ at the ref pinned in |
| 6 | +# OPENSHELL_CORE_REF and committed under src/openshell/_proto, so building the |
| 7 | +# package needs no core checkout and no network. |
| 8 | + |
| 9 | +min_version = { soft = "2026.9.9" } |
| 10 | + |
| 11 | +[tools] |
| 12 | +python = "3.14.5" |
| 13 | +uv = "0.10.12" |
| 14 | + |
| 15 | +[env] |
| 16 | +# The single core pin: a release tag (or a full commit SHA). |
| 17 | +OPENSHELL_CORE_REF = "v0.1.7" |
| 18 | +SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENSHELL = "0.0.0" |
| 19 | + |
| 20 | +[vars] |
| 21 | +python_paths = "src/ tests/ scripts/" |
| 22 | + |
| 23 | +[tasks."core:version"] |
| 24 | +description = "Print the pinned core ref" |
| 25 | +run = "echo $OPENSHELL_CORE_REF" |
| 26 | + |
| 27 | +[tasks.sync] |
| 28 | +description = "Install the SDK and its development dependencies" |
| 29 | +run = "uv sync --frozen --group dev" |
| 30 | + |
| 31 | +[tasks."proto:fetch"] |
| 32 | +description = "Fetch core's proto/ at the pinned ref into proto/" |
| 33 | +run = "scripts/fetch-core.sh $OPENSHELL_CORE_REF . proto" |
| 34 | +sources = ["mise.toml"] |
| 35 | +outputs = ["proto/openshell.proto"] |
| 36 | + |
| 37 | +[tasks."proto:gen"] |
| 38 | +description = "Generate the Python bindings into src/openshell/_proto" |
| 39 | +depends = ["sync", "proto:fetch"] |
| 40 | +run = "uv run --frozen python scripts/generate_python_proto.py" |
| 41 | + |
| 42 | +[tasks."proto:check"] |
| 43 | +description = "Fail if the committed bindings differ from the pinned protos" |
| 44 | +depends = ["proto:gen"] |
| 45 | +run = """ |
| 46 | +#!/usr/bin/env bash |
| 47 | +set -euo pipefail |
| 48 | +if ! git diff --exit-code --stat -- src/openshell/_proto \ |
| 49 | + || [ -n "$(git ls-files --others --exclude-standard -- src/openshell/_proto)" ]; then |
| 50 | + echo "ERROR: src/openshell/_proto is stale; run 'mise run proto:gen' and commit." >&2 |
| 51 | + exit 1 |
| 52 | +fi |
| 53 | +""" |
| 54 | + |
| 55 | +[tasks."conformance:check"] |
| 56 | +description = "Fail if vendored fixtures differ from core at the pinned ref" |
| 57 | +run = """ |
| 58 | +#!/usr/bin/env bash |
| 59 | +set -euo pipefail |
| 60 | +core=$(mktemp -d) |
| 61 | +trap 'rm -rf "$core"' EXIT |
| 62 | +scripts/fetch-core.sh "$OPENSHELL_CORE_REF" "$core" sdk/conformance |
| 63 | +for fixture in oauth-client-credentials.json oauth-client-credentials.json.license; do |
| 64 | + diff -u "$core/sdk/conformance/$fixture" "tests/fixtures/$fixture" |
| 65 | +done |
| 66 | +""" |
| 67 | + |
| 68 | +[tasks.lint] |
| 69 | +description = "Lint with ruff" |
| 70 | +depends = ["sync"] |
| 71 | +run = "uv run --frozen ruff check {{vars.python_paths}}" |
| 72 | + |
| 73 | +[tasks.format] |
| 74 | +description = "Format with ruff" |
| 75 | +depends = ["sync"] |
| 76 | +run = "uv run --frozen ruff format {{vars.python_paths}}" |
| 77 | + |
| 78 | +[tasks."format:check"] |
| 79 | +description = "Check formatting with ruff" |
| 80 | +depends = ["sync"] |
| 81 | +run = "uv run --frozen ruff format --check {{vars.python_paths}}" |
| 82 | + |
| 83 | +[tasks.typecheck] |
| 84 | +description = "Type check with ty" |
| 85 | +depends = ["sync"] |
| 86 | +run = "uv run --frozen ty check {{vars.python_paths}}" |
| 87 | + |
| 88 | +[tasks.test] |
| 89 | +description = "Run unit tests (set UV_PYTHON to pick the interpreter)" |
| 90 | +depends = ["sync", "proto:fetch"] |
| 91 | +run = "uv run --frozen pytest -n auto" |
| 92 | + |
| 93 | +[tasks.check] |
| 94 | +description = "Run formatting, lint, type, and drift checks" |
| 95 | +depends = ["format:check", "lint", "typecheck", "proto:check", "conformance:check"] |
| 96 | + |
| 97 | +[tasks.build] |
| 98 | +description = "Build the wheel and sdist, verify the wheel, and install both on the oldest Python" |
| 99 | +depends = ["sync"] |
| 100 | +run = """ |
| 101 | +#!/usr/bin/env bash |
| 102 | +set -euo pipefail |
| 103 | +rm -rf dist |
| 104 | +uv build --out-dir dist |
| 105 | +uv run --no-project python scripts/verify-python-wheel.py dist \ |
| 106 | + --expected-version "$SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENSHELL" |
| 107 | +
|
| 108 | +# Install each artifact into a clean environment on the oldest supported |
| 109 | +# Python and import the public API and the generated bindings. |
| 110 | +smoke=$(mktemp -d) |
| 111 | +trap 'rm -rf "$smoke"' EXIT |
| 112 | +for artifact in dist/*.whl dist/*.tar.gz; do |
| 113 | + uv venv --quiet --clear --python "${SMOKE_PYTHON:-3.11}" "$smoke/venv" |
| 114 | + uv pip install --quiet --python "$smoke/venv/bin/python" "$artifact" |
| 115 | + "$smoke/venv/bin/python" -I -c 'import openshell, openshell._proto.openshell_pb2_grpc; print(openshell.__version__, len(openshell.__all__))' |
| 116 | +done |
| 117 | +""" |
| 118 | + |
| 119 | +[tasks.ci] |
| 120 | +description = "Run the full CI pipeline" |
| 121 | +depends = ["check", "test", "build"] |
0 commit comments