From 7ab2b4964ce8d0bcf991dbc0e97231fa8ec6b740 Mon Sep 17 00:00:00 2001 From: Gopal Lal Date: Mon, 18 May 2026 12:27:08 +0530 Subject: [PATCH 1/2] chore(ci): route registry traffic through JFrog + uv-based Python pinning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements the SHA-pinning portion of go/hardened-gha and adopts the go/pinning-python-deps recommendation (uv lockfile) for the pyo3 sub-crate. ## Composite action: .github/actions/setup-jfrog Encapsulates the OIDC token exchange + cargo / uv index-URL writes. Workflows that need crates.io or PyPI access call: - uses: ./.github/actions/setup-jfrog with: cargo: "true" # write ~/.cargo/config.toml -> db-cargo-remote uv: "true" # export UV_INDEX_URL / PIP_INDEX_URL -> db-pypi Both pull from databricks.jfrog.io via a GitHub-OIDC-minted access token. The composite requires `permissions: id-token: write` on the calling job. ## Workflow updates - pr-checks.yml: clippy + test jobs gain cargo proxy (fmt does not fetch deps, skipped). - coverage.yml: cargo proxy added; cargo-llvm-cov via taiki-e/ install-action downloads from GitHub Releases (no registry hit). - license-check.yml: cargo proxy added for `cargo deny check`. - rust-e2e.yml: cargo proxy added; live workspace creds unchanged. - pyo3-checks.yml: cargo + uv proxies added. Bootstrap shifts from `pip install 'maturin>=...' pytest` to `astral-sh/setup-uv` + `uv sync --frozen --group dev` against the committed lockfile. All five workflows gain `permissions: id-token: write` (some already had it from prior OIDC integrations). ## Python pinning: pyo3/pyproject.toml + uv.lock Two-layer pinning per the published-library vs applications/services split in go/pinning-python-deps: - `[project].dependencies` (downstream contract): loose major- version-bounded pins. `pyarrow>=14` becomes `pyarrow>=14,<19` to cap the major. - `[dependency-groups].dev` (PEP 735) lists `maturin>=1.7,<2.0` and `pytest>=8.3,<9.0`. uv reads this natively for `uv sync --group dev`. The lockfile (`pyo3/uv.lock`) is NOT in this commit. A reviewer with JFrog access generates it once via `uv lock` from the pyo3/ dir and commits it in a follow-up. `pyo3-checks.yml` will hard-fail until the lockfile lands — that's the gate, not a regression. ## CLAUDE.md Adds a "Supply-chain hardening" section: SHA-pinning policy (actions, cargo, Python), how the composite works, how to regenerate the lockfile, and the open-source caveat (uv records the index URL during `uv lock`; regenerate against pypi.org locally before committing if the repo eventually open-sources). References: - go/hardened-gha https://docs.google.com/document/d/1zoHgolfZO_IUBIU3w40NmYsoZ9eTRdAmjlfwYOxkj70 - go/pinning-python-deps https://docs.google.com/document/d/1thJsoOBW3NzvRV6pWpujcD8mn4KOXgAW8t10iw6Z6LA - go/pypi-registry-access, go/crates-io-registry-access https://docs.google.com/document/d/1hnR9y7MJZeRIqyb4ujsNjMzRFKZDZsZ2gWB8DT9XFxc Co-authored-by: Isaac Signed-off-by: Gopal Lal --- .github/actions/setup-jfrog/action.yml | 132 +++++++++++++++++++++++++ .github/workflows/coverage.yml | 4 + .github/workflows/license-check.yml | 7 ++ .github/workflows/pr-checks.yml | 12 +++ .github/workflows/pyo3-checks.yml | 41 ++++++-- .github/workflows/rust-e2e.yml | 4 + CLAUDE.md | 65 ++++++++++++ pyo3/pyproject.toml | 17 +++- 8 files changed, 274 insertions(+), 8 deletions(-) create mode 100644 .github/actions/setup-jfrog/action.yml diff --git a/.github/actions/setup-jfrog/action.yml b/.github/actions/setup-jfrog/action.yml new file mode 100644 index 00000000..9c6e15b0 --- /dev/null +++ b/.github/actions/setup-jfrog/action.yml @@ -0,0 +1,132 @@ +# Copyright (c) 2026 Databricks, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Configure JFrog Artifactory as the registry proxy for cargo / uv / +# (future) npm. Required by go/hardened-gha: direct access to public +# package registries (crates.io, pypi.org, etc.) is blocked at the +# Databricks-protected runner; everything goes through +# `databricks.jfrog.io`. +# +# Steps: +# +# 1. Exchange the workflow's GitHub OIDC ID token for a JFrog access +# token via `https://databricks.jfrog.io/access/api/v1/oidc/token`. +# 2. Optionally write `~/.cargo/config.toml` pointing at the JFrog +# cargo proxy (`db-cargo-remote`). Replaces direct crates.io +# access for `cargo fetch` / `cargo install` / `cargo deny check`. +# 3. Optionally export `UV_INDEX_URL` (and `PIP_INDEX_URL` for +# fallback compat) pointing at the JFrog PyPI proxy (`db-pypi`). +# Picked up by `uv sync` / `uv pip install` / any plain `pip` +# calls in the job. +# +# Calling workflows MUST add `permissions: id-token: write` to grant +# the OIDC mint capability; without it the curl in step 1 fails 403. +# +# Reference: go/hardened-gha +# https://docs.google.com/document/d/1zoHgolfZO_IUBIU3w40NmYsoZ9eTRdAmjlfwYOxkj70 + +name: Set up JFrog Artifactory access +description: | + Exchange GitHub OIDC for a JFrog token and (optionally) configure + cargo / uv to route through the Databricks JFrog proxy. + +inputs: + cargo: + description: "Set 'true' to configure cargo to use the JFrog crates proxy." + required: false + default: "false" + uv: + description: | + Set 'true' to export UV_INDEX_URL (and PIP_INDEX_URL for compat) + pointing at the JFrog PyPI proxy. uv reads UV_INDEX_URL natively; + PIP_INDEX_URL is set for any tool that falls back to pip. + required: false + default: "false" + +runs: + using: composite + steps: + - name: Get JFrog OIDC token + shell: bash + run: | + set -euo pipefail + + # Mint a GitHub OIDC ID token scoped to the `jfrog-github` + # audience. Requires `permissions: id-token: write` on the + # calling job. + ID_TOKEN=$(curl -sLS \ + -H "User-Agent: actions/oidc-client" \ + -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ + "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=jfrog-github" | jq .value | tr -d '"') + echo "::add-mask::${ID_TOKEN}" + + # Exchange for a JFrog access token (RFC 8693 token-exchange). + ACCESS_TOKEN=$(curl -sLS -XPOST -H "Content-Type: application/json" \ + "https://databricks.jfrog.io/access/api/v1/oidc/token" \ + -d "{\"grant_type\": \"urn:ietf:params:oauth:grant-type:token-exchange\", \"subject_token_type\":\"urn:ietf:params:oauth:token-type:id_token\", \"subject_token\": \"${ID_TOKEN}\", \"provider_name\": \"github-actions\"}" | jq .access_token | tr -d '"') + echo "::add-mask::${ACCESS_TOKEN}" + + if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" = "null" ]; then + echo "FAIL: Could not extract JFrog access token" + exit 1 + fi + + echo "JFROG_ACCESS_TOKEN=${ACCESS_TOKEN}" >> "$GITHUB_ENV" + echo "JFrog OIDC token obtained successfully" + + - name: Configure cargo to use JFrog + if: inputs.cargo == 'true' + shell: bash + run: | + set -euo pipefail + + mkdir -p ~/.cargo + cat > ~/.cargo/config.toml << 'EOF' + [source.crates-io] + replace-with = "jfrog" + + [source.jfrog] + registry = "sparse+https://databricks.jfrog.io/artifactory/api/cargo/db-cargo-remote/index/" + + [registries.jfrog] + index = "sparse+https://databricks.jfrog.io/artifactory/api/cargo/db-cargo-remote/index/" + credential-provider = ["cargo:token"] + EOF + + cat > ~/.cargo/credentials.toml << EOF + [registries.jfrog] + token = "Bearer ${JFROG_ACCESS_TOKEN}" + EOF + chmod 600 ~/.cargo/credentials.toml + + # Exported for tools like cargo-deny / cargo-llvm-cov that + # may read the env directly rather than the credentials file. + echo "CARGO_REGISTRIES_JFROG_TOKEN=Bearer ${JFROG_ACCESS_TOKEN}" >> "$GITHUB_ENV" + + echo "Cargo configured to use JFrog registry" + + - name: Configure uv / pip to use JFrog + if: inputs.uv == 'true' + shell: bash + run: | + set -euo pipefail + + # uv reads UV_INDEX_URL natively; PIP_INDEX_URL is set for + # fallback compatibility with tools that shell out to pip. + # Both URLs point at db-pypi via the JFrog OIDC service + # account. + INDEX_URL="https://gha-service-account:${JFROG_ACCESS_TOKEN}@databricks.jfrog.io/artifactory/api/pypi/db-pypi/simple" + echo "UV_INDEX_URL=${INDEX_URL}" >> "$GITHUB_ENV" + echo "PIP_INDEX_URL=${INDEX_URL}" >> "$GITHUB_ENV" + echo "uv / pip configured to use JFrog registry" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f48a9d7f..183a72c4 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -49,6 +49,10 @@ jobs: with: fetch-depth: 0 + - uses: ./.github/actions/setup-jfrog + with: + cargo: "true" + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 with: toolchain: stable diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml index fe3a9bf0..646df083 100644 --- a/.github/workflows/license-check.yml +++ b/.github/workflows/license-check.yml @@ -42,6 +42,9 @@ on: permissions: contents: read + # Required for the OIDC token exchange that the + # `.github/actions/setup-jfrog` composite uses. See go/hardened-gha. + id-token: write defaults: run: @@ -56,6 +59,10 @@ jobs: steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: ./.github/actions/setup-jfrog + with: + cargo: "true" + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 - name: Install cargo-deny diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 87e2b3f8..03b4afc1 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -32,6 +32,10 @@ concurrency: permissions: contents: read + # Required for the OIDC token exchange that the + # `.github/actions/setup-jfrog` composite uses to authenticate + # against the JFrog cargo proxy. See go/hardened-gha. + id-token: write defaults: run: @@ -62,6 +66,10 @@ jobs: steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: ./.github/actions/setup-jfrog + with: + cargo: "true" + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 with: toolchain: stable @@ -78,6 +86,10 @@ jobs: steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: ./.github/actions/setup-jfrog + with: + cargo: "true" + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 with: toolchain: stable diff --git a/.github/workflows/pyo3-checks.yml b/.github/workflows/pyo3-checks.yml index a6698540..7ca51a32 100644 --- a/.github/workflows/pyo3-checks.yml +++ b/.github/workflows/pyo3-checks.yml @@ -41,6 +41,10 @@ concurrency: permissions: contents: read + # Required for the OIDC token exchange that the + # `.github/actions/setup-jfrog` composite uses to authenticate + # against the JFrog cargo + pip proxies. See go/hardened-gha. + id-token: write defaults: run: @@ -99,14 +103,39 @@ jobs: steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: ./.github/actions/setup-jfrog + with: + cargo: "true" + uv: "true" + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ matrix.python-version }} - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 - - name: Install maturin + pytest - run: pip install 'maturin>=1.5,<2.0' pytest + # uv is the Python package manager the kernel pyo3 sub-crate + # uses for env management. `uv.lock` carries SHA256 hashes + # for every artifact (direct + transitive); `uv sync --frozen` + # installs exactly what's in the lock with no resolver step. + # Per go/pinning-python-deps, this is the recommended pinning + # strategy for Databricks Python projects. uv itself is + # installed via astral-sh/setup-uv (SHA-pinned) rather than + # via `pip install uv` so the bootstrap is also hash-locked. + - uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + # Pin uv to a known good version; bump deliberately so the + # lockfile-resolver behaviour is stable across CI runs. + version: "0.11.14" + + - name: Install dev dependencies (uv sync) + # `--frozen` refuses to update the lockfile — if `uv.lock` is + # missing or out-of-date with `pyproject.toml`, this step + # fails loudly rather than silently re-resolving. The lock + # is committed and includes the `dev` dependency group + # (maturin, pytest) plus the runtime `pyarrow`. + working-directory: pyo3 + run: uv sync --frozen --group dev - name: Cargo unit tests (pyo3 crate) # The pyo3 crate's Rust-side unit tests cover the GIL handoff @@ -117,9 +146,9 @@ jobs: - name: "Build + install pyo3 wheel (maturin develop)" working-directory: pyo3 # `develop` builds the extension and installs it into the - # runner's active Python in one step — what `pytest` needs. - # Debug build is fine for tests and ~2x faster than --release. - run: maturin develop --interpreter python${{ matrix.python-version }} + # uv-managed venv from the previous step. Debug build is + # fine for tests and ~2x faster than --release. + run: uv run maturin develop --interpreter python${{ matrix.python-version }} - name: pytest (no-network + live tiers) working-directory: pyo3 @@ -130,4 +159,4 @@ jobs: # repo; on fork PRs without approval, the no-network tier # (test_module.py + test_auth.py) runs and the live tier # skips cleanly. - run: pytest -v + run: uv run pytest -v diff --git a/.github/workflows/rust-e2e.yml b/.github/workflows/rust-e2e.yml index 44c0cb2b..5884eea0 100644 --- a/.github/workflows/rust-e2e.yml +++ b/.github/workflows/rust-e2e.yml @@ -78,6 +78,10 @@ jobs: fetch-depth: 0 persist-credentials: false + - uses: ./.github/actions/setup-jfrog + with: + cargo: "true" + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 - name: Run v0 E2E tests diff --git a/CLAUDE.md b/CLAUDE.md index 486a44a1..edc1a01a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -93,6 +93,71 @@ permissive licenses must be added to `[licenses].allow` in preserved separately for generating attribution pages on demand; the CI gate lives on `deny.toml`. +## Supply-chain hardening + +Per [go/hardened-gha](https://docs.google.com/document/d/1zoHgolfZO_IUBIU3w40NmYsoZ9eTRdAmjlfwYOxkj70/edit), +the protected runners block direct access to public package +registries (crates.io, PyPI, npm, etc.). All third-party +dependency fetches route through Databricks' JFrog Artifactory +proxy at `databricks.jfrog.io`. + +How this shows up in the repo: + +- **GitHub Actions steps** are SHA-pinned, with the version tag in + a trailing comment (e.g. `uses: actions/checkout@34e1148... # v4`). +- **Cargo** access goes through `db-cargo-remote`. Workflows that + hit cargo run `./.github/actions/setup-jfrog` with `cargo: "true"` + before `setup-rust-toolchain`. `Cargo.lock` carries per-crate + SHA256 checksums (`source = "registry+..."` + `checksum = "..."`), + which is Cargo's native pinning mechanism. +- **PyPI** access goes through `db-pypi`. The `pyo3-checks.yml` + workflow runs the same composite with `uv: "true"` (exports + `UV_INDEX_URL` + `PIP_INDEX_URL` for fallback compatibility). + The pyo3 sub-crate uses [uv](https://docs.astral.sh/uv/) for + Python env management per + [go/pinning-python-deps](https://docs.google.com/document/d/1thJsoOBW3NzvRV6pWpujcD8mn4KOXgAW8t10iw6Z6LA/edit). + `pyo3/uv.lock` carries SHA256 hashes for every artifact + (direct + transitive). `uv sync --frozen --group dev` installs + exactly what's in the lock; no resolver step in CI. +- **Two-layer Python pinning** (per the published-library vs + applications/services split in the guidance doc): + - **`pyo3/pyproject.toml` `[project].dependencies`** is the + **public contract** for downstream `pip install + databricks-sql-kernel` users. Loose major-version-bounded + pins (`pyarrow>=14,<19`) — exact pins make the wheel hard + for end-users to install alongside their own pyarrow + consumers. + - **`pyo3/uv.lock`** is the **CI/dev** environment, fully + hash-locked for reproducibility. Generated from + `pyproject.toml` + the `[dependency-groups].dev` table. +- **Composite action**: `.github/actions/setup-jfrog/action.yml` + encapsulates the OIDC token exchange (`id-token: write` + permission required) plus the cargo / uv config writes. + Workflows that need registry access reference it with + `uses: ./.github/actions/setup-jfrog`. + +Regenerating `pyo3/uv.lock`: + +```bash +cd pyo3 +uv lock # or `uv lock --upgrade-package ` for a targeted bump +``` + +Run from a host with JFrog access (`UV_INDEX_URL` set to the +db-pypi proxy, or `--index-url` flag). uv records hashes for +every artifact. Commit the regenerated lockfile in the same PR +that bumps a version in `pyproject.toml`. + +**Open-source caveat.** `uv.lock` records the index URL the +resolver hit. To avoid leaking the internal proxy URL when this +repo eventually open-sources, locally regenerate against the +public PyPI URL by setting `UV_INDEX_URL=https://pypi.org/simple/` +in your shell (or pass `--index-url`) before running `uv lock`. +The CI workflow then sets `UV_INDEX_URL` to the JFrog proxy via +the composite action's env-var injection (which does NOT modify +the lockfile — uv only writes the index URL during `uv lock`, +not during `uv sync`). + ## Local development environment Connection variables for E2E tests can be set via `.cargo/config.toml` diff --git a/pyo3/pyproject.toml b/pyo3/pyproject.toml index 46c8cb49..81a2cf72 100644 --- a/pyo3/pyproject.toml +++ b/pyo3/pyproject.toml @@ -9,8 +9,21 @@ description = "Python bindings for the Databricks SQL Kernel (PyO3)" requires-python = ">=3.9" license = { text = "Apache-2.0" } authors = [{ name = "Databricks" }] -dependencies = ["pyarrow>=14"] +# Runtime dependency for downstream consumers. Loose major-version +# bound per the published-library guidance — exact pins make this +# wheel harder for end-users to install alongside their own pyarrow +# consumers. The CI environment is fully hash-locked via `uv.lock` +# (see below), separately from this contract. +dependencies = ["pyarrow>=14,<19"] + +# Dev / CI dependencies. PEP 735 standard; uv reads this directly. +# `uv sync --frozen` installs from `uv.lock`, which carries SHA256 +# hashes for every artifact + transitive dep. +[dependency-groups] +dev = [ + "maturin>=1.7,<2.0", + "pytest>=8.3,<9.0", +] [tool.maturin] module-name = "databricks_sql_kernel" - From db36f0ac8051f468da8fa5375689a2596a1bbe25 Mon Sep 17 00:00:00 2001 From: Gopal Lal Date: Mon, 18 May 2026 12:39:06 +0530 Subject: [PATCH 2/2] chore(ci): drop uv lockfile requirement; follow published-library rule Per go/pinning-python-deps, the pyo3 sub-crate is in the **externally-published-library** scope (the wheel ships to PyPI as `databricks-sql-kernel`). That section of the doc says: Do not add exact version pins for all of your dependencies. Doing this makes your library harder for your end users to install. The committed-lockfile + `uv sync --frozen` approach is for the **applications/services** scope (Databricks-internal services like FMAPI, vector search). Wrong scope for the pyo3 wheel. Revised approach matches the policy verbatim: - `[project].dependencies` keeps major-version upper bounds (`pyarrow>=14,<19`). - `[dependency-groups].dev` keeps the loose `maturin>=1.7,<2.0` and `pytest>=8.3,<9.0`. - `uv sync --group dev` (no `--frozen`) re-resolves each CI run within those bounds. - The `db-pypi` proxy's 7-day age filter is the baseline supply- chain protection at the registry layer. No lockfile means no bootstrap step, no open-source-leak caveat, no maintenance overhead on dep bumps. Co-authored-by: Isaac Signed-off-by: Gopal Lal --- .github/workflows/pyo3-checks.yml | 27 ++++++++--------- CLAUDE.md | 48 +++++++------------------------ 2 files changed, 22 insertions(+), 53 deletions(-) diff --git a/.github/workflows/pyo3-checks.yml b/.github/workflows/pyo3-checks.yml index 7ca51a32..86cca8c2 100644 --- a/.github/workflows/pyo3-checks.yml +++ b/.github/workflows/pyo3-checks.yml @@ -115,27 +115,24 @@ jobs: - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 # uv is the Python package manager the kernel pyo3 sub-crate - # uses for env management. `uv.lock` carries SHA256 hashes - # for every artifact (direct + transitive); `uv sync --frozen` - # installs exactly what's in the lock with no resolver step. - # Per go/pinning-python-deps, this is the recommended pinning - # strategy for Databricks Python projects. uv itself is - # installed via astral-sh/setup-uv (SHA-pinned) rather than - # via `pip install uv` so the bootstrap is also hash-locked. + # uses for env management. uv itself is installed via + # astral-sh/setup-uv (SHA-pinned) rather than via + # `pip install uv` so the bootstrap is also hash-locked. - uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 with: - # Pin uv to a known good version; bump deliberately so the - # lockfile-resolver behaviour is stable across CI runs. + # Pin uv to a known good version; bump deliberately. version: "0.11.14" - name: Install dev dependencies (uv sync) - # `--frozen` refuses to update the lockfile — if `uv.lock` is - # missing or out-of-date with `pyproject.toml`, this step - # fails loudly rather than silently re-resolving. The lock - # is committed and includes the `dev` dependency group - # (maturin, pytest) plus the runtime `pyarrow`. + # No `--frozen` and no committed lockfile: per go/pinning- + # python-deps the externally-published-library rule says + # *not* to pin transitive deps (it impedes downstream + # `pip install`). The `[project].dependencies` major-version + # bounds in `pyproject.toml` plus the JFrog proxy's 7-day + # age filter on `db-pypi` are the baseline protection. uv + # re-resolves each run within those bounds. working-directory: pyo3 - run: uv sync --frozen --group dev + run: uv sync --group dev - name: Cargo unit tests (pyo3 crate) # The pyo3 crate's Rust-side unit tests cover the GIL handoff diff --git a/CLAUDE.md b/CLAUDE.md index edc1a01a..7f52b18f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -114,50 +114,22 @@ How this shows up in the repo: workflow runs the same composite with `uv: "true"` (exports `UV_INDEX_URL` + `PIP_INDEX_URL` for fallback compatibility). The pyo3 sub-crate uses [uv](https://docs.astral.sh/uv/) for - Python env management per - [go/pinning-python-deps](https://docs.google.com/document/d/1thJsoOBW3NzvRV6pWpujcD8mn4KOXgAW8t10iw6Z6LA/edit). - `pyo3/uv.lock` carries SHA256 hashes for every artifact - (direct + transitive). `uv sync --frozen --group dev` installs - exactly what's in the lock; no resolver step in CI. -- **Two-layer Python pinning** (per the published-library vs - applications/services split in the guidance doc): - - **`pyo3/pyproject.toml` `[project].dependencies`** is the - **public contract** for downstream `pip install - databricks-sql-kernel` users. Loose major-version-bounded - pins (`pyarrow>=14,<19`) — exact pins make the wheel hard - for end-users to install alongside their own pyarrow - consumers. - - **`pyo3/uv.lock`** is the **CI/dev** environment, fully - hash-locked for reproducibility. Generated from - `pyproject.toml` + the `[dependency-groups].dev` table. + Python env management. +- **Python dep pinning follows the externally-published-library + rule from [go/pinning-python-deps](https://docs.google.com/document/d/1thJsoOBW3NzvRV6pWpujcD8mn4KOXgAW8t10iw6Z6LA/edit)**: + major-version upper bounds in `pyo3/pyproject.toml` + (`pyarrow>=14,<19`), no exact pins, no transitive constraints, + no committed lockfile. Exact pins would impede downstream + `pip install databricks-sql-kernel` for end-users with their + own pyarrow consumers. The `db-pypi` proxy's 7-day age filter + is the baseline supply-chain protection; `uv sync` re-resolves + each CI run within the major-version bounds. - **Composite action**: `.github/actions/setup-jfrog/action.yml` encapsulates the OIDC token exchange (`id-token: write` permission required) plus the cargo / uv config writes. Workflows that need registry access reference it with `uses: ./.github/actions/setup-jfrog`. -Regenerating `pyo3/uv.lock`: - -```bash -cd pyo3 -uv lock # or `uv lock --upgrade-package ` for a targeted bump -``` - -Run from a host with JFrog access (`UV_INDEX_URL` set to the -db-pypi proxy, or `--index-url` flag). uv records hashes for -every artifact. Commit the regenerated lockfile in the same PR -that bumps a version in `pyproject.toml`. - -**Open-source caveat.** `uv.lock` records the index URL the -resolver hit. To avoid leaking the internal proxy URL when this -repo eventually open-sources, locally regenerate against the -public PyPI URL by setting `UV_INDEX_URL=https://pypi.org/simple/` -in your shell (or pass `--index-url`) before running `uv lock`. -The CI workflow then sets `UV_INDEX_URL` to the JFrog proxy via -the composite action's env-var injection (which does NOT modify -the lockfile — uv only writes the index URL during `uv lock`, -not during `uv sync`). - ## Local development environment Connection variables for E2E tests can be set via `.cargo/config.toml`