Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ jobs:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
Expand All @@ -75,6 +78,9 @@ jobs:
toolchain: stable
components: llvm-tools-preview

- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@07b4745e0c39a41822af610387492e3e53aa222b # v2.83.4
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ on:
- "napi/Cargo.lock"
- ".github/workflows/license-check.yml"

concurrency:
# A newer commit makes an older run for the same PR irrelevant.
# Main pushes remain distinct and must finish independently.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read
# Required for the OIDC token exchange that the
Expand Down
42 changes: 11 additions & 31 deletions .github/workflows/napi-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,16 @@ concurrency:

permissions:
contents: read
# `id-token: write` is NOT granted workflow-wide: the `precondition`
# job only checks out and inspects the tree, so least-privilege keeps
# it on the single job that needs it (`check-and-test`, below).
# `id-token: write` is scoped to the single job that exchanges an OIDC
# token for JFrog access.

defaults:
run:
shell: bash

jobs:
# Cheap gate job — runs once, no toolchain installs. The check-and-test
# job depends on this and is skipped (no runner boot beyond the
# precondition runner itself) when the napi/ sub-crate doesn't
# exist. Avoids wasted setup cost on kernel-only PRs that trigger
# this workflow via root Cargo.toml changes before the napi crate
# has merged.
precondition:
name: "Check napi sub-crate exists"
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
outputs:
ready: ${{ steps.check.outputs.ready }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

- name: "Check for napi/Cargo.toml"
id: check
run: |
if [[ -f "napi/Cargo.toml" ]]; then
echo "ready=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::napi/ sub-crate does not exist yet — skipping napi checks. (Workflow may fire on root Cargo.toml changes before the napi crate has merged.)"
echo "ready=false" >> "$GITHUB_OUTPUT"
fi

check-and-test:
name: "napi fmt + clippy + test"
needs: precondition
if: needs.precondition.outputs.ready == 'true'
# Scoped here (not workflow-wide): `id-token: write` is only needed
# for the OIDC token exchange in `.github/actions/setup-jfrog` that
# authenticates against the JFrog cargo proxy. See go/hardened-gha.
Expand All @@ -97,6 +68,9 @@ jobs:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
defaults:
run:
# All cargo commands run from the napi/ standalone workspace.
Expand All @@ -116,6 +90,12 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
components: rustfmt, clippy
# napi is a standalone workspace; cache its actual target and
# lockfile instead of the unused repository-root target.
cache-workspaces: "napi -> target"

- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- name: cargo fmt --all -- --check
run: cargo fmt --all -- --check
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ jobs:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

Expand All @@ -92,6 +95,9 @@ jobs:
toolchain: stable
components: clippy

- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- name: cargo clippy
run: cargo clippy --all-targets -- -D warnings

Expand All @@ -100,6 +106,9 @@ jobs:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

Expand All @@ -111,6 +120,9 @@ jobs:
with:
toolchain: stable

- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- name: cargo test
# Runs every test the default suite executes: unit tests,
# doc tests, and wiremock-backed integration tests. Does NOT
Expand All @@ -123,6 +135,9 @@ jobs:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

Expand All @@ -134,6 +149,9 @@ jobs:
with:
toolchain: stable

- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- name: make c-abi-test
# Builds the cdylib and compiles + runs the hand-written C smoke
# tests in tests/c/ against the C ABI exported from src/c_abi/.
Expand All @@ -146,6 +164,9 @@ jobs:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
env:
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

Expand All @@ -158,6 +179,9 @@ jobs:
toolchain: stable
components: clippy

- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- name: cargo check (tls-rustls)
# Default features pull in `tls-native`; the napi binding crate
# opts INTO `tls-rustls` instead. Without this job, a feature-
Expand Down
72 changes: 30 additions & 42 deletions .github/workflows/pyo3-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# PyO3 sub-crate CI. Path-gated on `pyo3/**` so this workflow
# only fires when the directory exists (it lands in PR #13). The
# job is skipped automatically on every PR that doesn't touch
# the pyo3/ tree.
# PyO3 sub-crate CI. Path-gated so the matrix runs only when the
# binding or one of its root Cargo inputs changes.

name: PyO3 Checks

Expand Down Expand Up @@ -51,36 +49,8 @@ defaults:
shell: bash

jobs:
# Cheap gate job — runs once, no matrix, no toolchain installs.
# The matrix `build-and-test` job depends on this and is skipped
# entirely (no runner boot, no checkout) when the pyo3/ sub-crate
# doesn't exist. This avoids the per-Python-version setup cost on
# kernel-only PRs that trigger this workflow via root Cargo.toml
# / Cargo.lock changes.
precondition:
name: "Check pyo3 sub-crate exists"
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
outputs:
ready: ${{ steps.check.outputs.ready }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

- name: "Check for pyo3/Cargo.toml"
id: check
run: |
if [[ -f "pyo3/Cargo.toml" ]]; then
echo "ready=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::pyo3/ sub-crate does not exist yet — skipping pyo3 build/test matrix. (Workflow fires on root Cargo.toml changes; the pyo3 sub-crate lands in PR #13.)"
echo "ready=false" >> "$GITHUB_OUTPUT"
fi

build-and-test:
name: "PyO3 build + test (Python ${{ matrix.python-version }})"
needs: precondition
if: needs.precondition.outputs.ready == 'true'
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
Expand All @@ -96,6 +66,10 @@ jobs:
DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }}
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
RUST_LOG: databricks_sql_kernel=info
RUSTC_WRAPPER: sccache
# Select sccache's GitHub Actions backend. Without this, the
# protected runner's local cache disappears with the job.
SCCACHE_GHA_ENABLED: "true"
strategy:
fail-fast: false
matrix:
Expand All @@ -119,6 +93,17 @@ jobs:
python-version: ${{ matrix.python-version }}

- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
# pyo3 is a standalone workspace. The default "." mapping
# cached the unused root target/ and root Cargo.lock while
# every pyo3/target build remained cold.
cache-workspaces: "pyo3 -> target"
# PyO3 build-script output is interpreter-specific even though
# the published extension uses abi3.
cache-key: "py${{ matrix.python-version }}"

- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

# uv is the Python package manager the kernel pyo3 sub-crate
# uses for env management. uv itself is installed via
Expand All @@ -139,12 +124,10 @@ jobs:
# re-resolves each run within those bounds.
working-directory: pyo3
# `--no-install-project` installs only the dependency groups,
# NOT the kernel cdylib itself. Without it, `uv sync` runs a
# full maturin/cargo RELEASE build of the extension here — and
# then the `maturin develop` step below rebuilds it again in
# debug, so the kernel compiled twice per matrix Python version
# (~5 min each, x5 versions). The Rust extension is built
# exactly once, by `maturin develop`.
# NOT the kernel cdylib itself. The later `uv run --no-sync`
# calls preserve that choice: plain `uv run` would implicitly
# sync and build the project before invoking maturin, compiling
# the extension twice per matrix entry.
run: uv sync --group dev --no-install-project

- name: Cargo unit tests (pyo3 crate)
Expand All @@ -168,9 +151,12 @@ jobs:
#
# maturin's `develop` always targets the active virtualenv's
# interpreter and (unlike `build`) has no --interpreter flag;
# `uv run` already activates the venv `uv sync` created for the
# matrix Python version, so the interpreter is selected for us.
run: uv run maturin develop
# `uv run` activates the venv `uv sync` created for the matrix
# Python version, so the interpreter is selected for us.
# `--no-sync` is load-bearing: without it uv first installs the
# project through its maturin build backend, then this command
# asks maturin to build and install it a second time.
run: uv run --no-sync maturin develop

- name: pytest (no-network + live tiers)
working-directory: pyo3
Expand All @@ -181,4 +167,6 @@ 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: uv run pytest -v
# The extension and dependencies are already installed above;
# avoid another implicit project sync before starting pytest.
run: uv run --no-sync pytest -v
10 changes: 10 additions & 0 deletions .github/workflows/rust-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ jobs:
DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }}
RUST_LOG: databricks_sql_kernel=debug
RUST_BACKTRACE: 1
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
Expand All @@ -85,6 +87,9 @@ jobs:

- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0

- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- name: Run v0 E2E tests
run: |
for suite in v0_session_e2e v0_execute_e2e v0_async_execute_e2e v0_metadata_e2e v0_query_tags_headers_e2e; do
Expand Down Expand Up @@ -123,6 +128,8 @@ jobs:
DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }}
RUST_LOG: databricks_sql_kernel=debug
RUST_BACKTRACE: 1
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
Expand All @@ -135,6 +142,9 @@ jobs:

- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0

- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- name: Start mitmproxy
run: |
docker run -d --name mitmproxy \
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/securityScan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ on:
- cron: '0 0 * * 0' # Every Sunday at midnight UTC
workflow_dispatch:

concurrency:
# Coalesce only PR activity. Scheduled and manual scans remain
# distinct runs so one audit cannot cancel another.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
id-token: write
contents: read
Expand Down
16 changes: 14 additions & 2 deletions src/auth/oauth/m2m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ impl AuthProvider for ClientCredentialsProvider {
mod tests {
use super::*;
use crate::client::http::HttpClientConfig;
use crate::client::retry::{build_retry_configs, RetryConfig};
use std::collections::HashMap;
use wiremock::matchers::{header, method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

Expand Down Expand Up @@ -522,9 +524,19 @@ mod tests {
.mount(&mock_server)
.await;

// This test covers OIDC error propagation, not retry timing. A
// production retry ladder turns the one mocked 500 into more than a
// minute of real backoff sleeps.
let retry = RetryConfig {
max_retries: 0,
..RetryConfig::default()
};
let http_client = Arc::new(
DatabricksHttpClient::with_default_retry(HttpClientConfig::default())
.expect("Failed to create HTTP client"),
DatabricksHttpClient::new(
HttpClientConfig::default(),
build_retry_configs(&retry, &HashMap::new()),
)
.expect("Failed to create HTTP client"),
);

// Provider creation should fail with descriptive error
Expand Down
Loading
Loading