Skip to content

Commit 380ee70

Browse files
committed
build: read the core pin from buf.gen.yaml like sdk-go
inputs[0] in buf.gen.yaml names core's proto/ at v0.1.7 and is the single pin, read with yq by core:version, proto:fetch, and conformance:check, as in sdk-go. The file has no plugins, because grpcio-tools still generates the bindings. conformance:check now fetches the fixtures from raw.githubusercontent.com like sdk-go's, which replaces scripts/fetch-core.sh (removed in the previous commit). Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
1 parent 7ce1a6b commit 380ee70

4 files changed

Lines changed: 52 additions & 24 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828

2929
- uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0
3030

31-
# fetch-core.sh reads proto/ and sdk/conformance from NVIDIA/OpenShell
32-
# at the pinned ref (public, no credentials).
31+
# proto:check and conformance:check read proto/ and sdk/conformance from
32+
# NVIDIA/OpenShell at the tag pinned in buf.gen.yaml (public, no credentials).
3333
- name: Format, lint, typecheck, proto and fixture drift
3434
run: mise run check
3535

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ mise run core:version
2828

2929
## Core version and generated bindings
3030

31-
The bindings are generated from `proto/` in NVIDIA/OpenShell at the ref in
32-
`OPENSHELL_CORE_REF` (`mise.toml`, currently `v0.1.7`) and committed under
33-
`src/openshell/_proto`. `buf export` fetches the protos, the same way sdk-go
34-
reads them, and `grpcio-tools` generates the bindings:
31+
The bindings are generated from `proto/` in NVIDIA/OpenShell at the tag pinned
32+
in `buf.gen.yaml` (`inputs[0].tag`, currently `v0.1.7`), the same file and
33+
field sdk-go uses, and committed under `src/openshell/_proto`. `buf export`
34+
fetches the protos and `grpcio-tools` generates the bindings:
3535

3636
- Building a wheel or sdist needs neither a core checkout nor network access.
3737
- A change of the pin shows the effect on the generated API in its diff.

‎buf.gen.yaml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# The core pin, in the same shape as ai-openshell/sdk-go's buf.gen.yaml.
5+
# inputs[0] names core's proto/ at a release tag. inputs[0].tag is the single
6+
# pin: the core-watch automation changes only that line, and
7+
# `mise run core:version` prints it.
8+
#
9+
# Unlike sdk-go, this file has no plugins: the bindings are not produced by
10+
# `buf generate`. grpcio-tools ships the protoc and gRPC Python plugin that
11+
# match the runtime, and has no standalone plugin binary for buf to run.
12+
# `mise run proto:fetch` passes this input to `buf export`, which writes the
13+
# listed files and their imports to proto/, and
14+
# scripts/generate_python_proto.py compiles them.
15+
version: v2
16+
17+
inputs:
18+
- git_repo: https://github.com/NVIDIA/OpenShell.git
19+
tag: v0.1.7
20+
depth: 1
21+
subdir: proto
22+
paths:
23+
- openshell.proto
24+
- credential_driver.proto

‎mise.toml‎

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,48 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# 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.
5+
# full pipeline. Bindings are generated from core's proto/ at the release tag
6+
# pinned in buf.gen.yaml (inputs[0].tag) and committed under
7+
# src/openshell/_proto, so building the package needs no core checkout and no
8+
# network.
89

910
min_version = { soft = "2026.9.9" }
1011

1112
[tools]
1213
python = "3.14.5"
1314
buf = "1.72.0"
1415
uv = "0.10.12"
16+
yq = "4.53.6"
1517

1618
[env]
17-
# The single core pin: a release tag (or a full commit SHA).
18-
OPENSHELL_CORE_REF = "v0.1.7"
1919
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_OPENSHELL = "0.0.0"
2020

2121
[vars]
2222
python_paths = "src/ tests/ scripts/"
2323

2424
[tasks."core:version"]
25-
description = "Print the pinned core ref"
26-
run = "echo $OPENSHELL_CORE_REF"
25+
description = "Print the core release tag the bindings are pinned to"
26+
run = "yq -r '.inputs[0].tag' buf.gen.yaml"
2727

2828
[tasks.sync]
2929
description = "Install the SDK and its development dependencies"
3030
run = "uv sync --frozen --group dev"
3131

3232
[tasks."proto:fetch"]
33-
description = "Export the SDK's protos from core at the pinned ref into proto/"
34-
# buf follows the imports of the two root files, so proto/ holds exactly the
35-
# files the SDK compiles.
33+
description = "Export the SDK's protos from core at the pinned tag into proto/"
34+
# buf follows the imports of the files in inputs[0].paths, so proto/ holds
35+
# exactly the files the SDK compiles.
3636
run = """
3737
#!/usr/bin/env bash
3838
set -euo pipefail
39+
input() { yq -r ".inputs[0].$1" buf.gen.yaml; }
40+
paths=()
41+
while read -r path; do paths+=(--path "$path"); done < <(yq -r '.inputs[0].paths[]' buf.gen.yaml)
3942
rm -rf proto
40-
buf export "https://github.com/NVIDIA/OpenShell.git#ref=${OPENSHELL_CORE_REF},depth=1,subdir=proto" \
41-
--path openshell.proto --path credential_driver.proto --output proto
43+
buf export "$(input git_repo)#tag=$(input tag),depth=$(input depth),subdir=$(input subdir)" \
44+
"${paths[@]}" --output proto
4245
"""
43-
sources = ["mise.toml"]
46+
sources = ["buf.gen.yaml"]
4447
outputs = ["proto/openshell.proto"]
4548

4649
[tasks."proto:gen"]
@@ -62,15 +65,16 @@ fi
6265
"""
6366

6467
[tasks."conformance:check"]
65-
description = "Fail if vendored fixtures differ from core at the pinned ref"
68+
description = "Fail if vendored fixtures differ from core at the pinned tag"
6669
run = """
6770
#!/usr/bin/env bash
6871
set -euo pipefail
69-
core=$(mktemp -d)
70-
trap 'rm -rf "$core"' EXIT
71-
scripts/fetch-core.sh "$OPENSHELL_CORE_REF" "$core" sdk/conformance
72+
# Shared cross-SDK fixtures live in core's sdk/conformance/. The copies in
73+
# tests/fixtures must match core at the pinned tag.
74+
TAG=$(yq -r '.inputs[0].tag' buf.gen.yaml)
75+
BASE="https://raw.githubusercontent.com/NVIDIA/OpenShell/$TAG/sdk/conformance"
7276
for fixture in oauth-client-credentials.json oauth-client-credentials.json.license; do
73-
diff -u "$core/sdk/conformance/$fixture" "tests/fixtures/$fixture"
77+
curl -fsSL "$BASE/$fixture" | diff -u - "tests/fixtures/$fixture"
7478
done
7579
"""
7680

0 commit comments

Comments
 (0)