diff --git a/.github/workflows/close-stale.yml b/.github/workflows/close-stale.yml new file mode 100644 index 00000000..63dff6ac --- /dev/null +++ b/.github/workflows/close-stale.yml @@ -0,0 +1,45 @@ +# 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. + +# Port of databricks/databricks-jdbc's closeStale.yml. Closes issues +# and PRs after 30 days of inactivity (with a 7-day stale window). + +name: Close stale issues and PRs + +on: + schedule: + # 06:30 UTC daily + - cron: "30 6 * * *" + workflow_dispatch: + +permissions: + issues: write + pull-requests: write + +jobs: + stale: + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + steps: + - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 # v8 + with: + stale-issue-message: "This issue has been marked as Stale because it has been open for 30 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue." + stale-pr-message: "This PR has been marked as Stale because it has been open for 30 days with no activity. If you would like the PR to remain open, please remove the stale label or comment on the PR." + close-pr-message: "This PR was closed because it has been inactive for 7 days since being marked as stale." + close-issue-message: "This issue was closed because it has been inactive for 7 days since being marked as stale." + days-before-stale: 30 + days-before-close: 7 + exempt-issue-labels: "epic, discussion, kernel-v0, tracked" + exempt-pr-labels: "kernel-v0, tracked" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..f48a9d7f --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,83 @@ +# 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. + +# Code coverage report. Runs `cargo llvm-cov` against the unit / +# integration test suite (E2E tests stay #[ignore]'d) and uploads +# the lcov result to Codecov via OIDC. + +name: Coverage + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} + cancel-in-progress: true + +permissions: + contents: read + id-token: write + pull-requests: write + +defaults: + run: + shell: bash + +jobs: + coverage: + name: Coverage + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + fetch-depth: 0 + + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 + with: + toolchain: stable + components: llvm-tools-preview + + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@a416ddeedbd372e614cc1386e8b642692f66865e # v2.57.1 + with: + tool: cargo-llvm-cov + + - name: Run coverage + # E2E tests stay #[ignore]'d; coverage runs the same suite + # as `pr-checks.yml`'s `test` job. + run: cargo llvm-cov --workspace --lcov --output-path lcov.info + + # Codecov upload. + # + # `use_oidc: true` is tokenless, but it requires the repo to be + # enrolled in Codecov's GitHub App with OIDC enabled in the + # Codecov dashboard. Until that is set up, the action falls + # back to anonymous upload which Codecov silently rate-limits + # and may drop. `fail_ci_if_error: false` keeps the job green + # in that case (we don't want a one-off Codecov outage to red- + # light unrelated PRs) — but it does mean coverage data may not + # actually land. Watch for the Codecov check on the first few + # PRs to confirm uploads are flowing. + - name: Upload to Codecov + uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3 + with: + files: lcov.info + fail_ci_if_error: false + use_oidc: true diff --git a/.github/workflows/dco-check.yml b/.github/workflows/dco-check.yml new file mode 100644 index 00000000..106925e1 --- /dev/null +++ b/.github/workflows/dco-check.yml @@ -0,0 +1,92 @@ +# 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. + +# Verbatim port of the dco-check workflow used across the other +# databricks/databricks-sql-* repos. Enforces `git commit -s` sign-off +# on every commit in a PR — CLAUDE.md mandates this convention. + +name: DCO Check + +on: + pull_request: + types: [opened, synchronize, reopened] + branches: [main] + +permissions: + contents: read + +jobs: + dco-check: + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + name: Check DCO Sign-off + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + + - name: Check DCO Sign-off + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + #!/bin/bash + set -e + + echo "Checking commits from $BASE_SHA to $HEAD_SHA" + + COMMITS=$(git rev-list --no-merges "$BASE_SHA..$HEAD_SHA") + + if [ -z "$COMMITS" ]; then + echo "No commits found in this PR" + exit 0 + fi + + FAILED_COMMITS=() + + for commit in $COMMITS; do + echo "Checking commit: $commit" + COMMIT_MSG=$(git log --format=%B -n 1 "$commit") + if echo "$COMMIT_MSG" | grep -q "^Signed-off-by: "; then + echo " Commit $commit has DCO sign-off" + else + echo " Commit $commit is missing DCO sign-off" + FAILED_COMMITS+=("$commit") + fi + done + + if [ ${#FAILED_COMMITS[@]} -ne 0 ]; then + echo "" + echo "DCO Check Failed!" + echo "The following commits are missing the required 'Signed-off-by' line:" + for commit in "${FAILED_COMMITS[@]}"; do + echo " - $commit: $(git log --format=%s -n 1 "$commit")" + done + echo "" + echo "To fix this, you need to sign off your commits. You can:" + echo "1. Add sign-off to new commits: git commit -s -m 'Your commit message'" + echo "2. Amend existing commits: git commit --amend --signoff" + echo "3. For multiple commits, use: git rebase --signoff HEAD~N (where N is the number of commits)" + echo "" + echo "The sign-off should be in the format:" + echo "Signed-off-by: Your Name " + echo "" + echo "For more details, see CONTRIBUTING.md" + exit 1 + else + echo "" + echo "All commits have proper DCO sign-off!" + fi diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml new file mode 100644 index 00000000..fe3a9bf0 --- /dev/null +++ b/.github/workflows/license-check.yml @@ -0,0 +1,71 @@ +# 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. + +# Enforces the dependency-licence allowlist in `deny.toml`. New +# transitive dependencies with licenses outside `[licenses].allow` +# fail the build; the contributor either adds the licence (with +# justification in the PR description) or swaps the dep. +# +# Uses `cargo-deny` (the standard Rust ecosystem tool for this) — +# `cargo-about` is for generating attribution pages, not for gating +# on an allowlist. `about.toml` is preserved for when an attribution +# page is needed; CI gates on `deny.toml`. + +name: License Check + +on: + push: + branches: [main] + paths: + - "Cargo.toml" + - "Cargo.lock" + - "deny.toml" + - ".github/workflows/license-check.yml" + pull_request: + branches: [main] + paths: + - "Cargo.toml" + - "Cargo.lock" + - "deny.toml" + - ".github/workflows/license-check.yml" + +permissions: + contents: read + +defaults: + run: + shell: bash + +jobs: + cargo-deny: + name: cargo-deny + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 + + - name: Install cargo-deny + uses: taiki-e/install-action@a416ddeedbd372e614cc1386e8b642692f66865e # v2.57.1 + with: + tool: cargo-deny + + - name: Check licenses, advisories, bans, sources + # `licenses` is the load-bearing check; `advisories` flags + # RustSec security advisories; `bans` and `sources` are + # empty-permissive in our deny.toml today but the slots are + # there for future hardening. + run: cargo deny check diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml new file mode 100644 index 00000000..87e2b3f8 --- /dev/null +++ b/.github/workflows/pr-checks.yml @@ -0,0 +1,90 @@ +# 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. + +# Per-PR build / format / lint / unit-test gate. Runs on every PR +# against `main` and on every push to `main`. Mirrors the +# `code-quality-checks` workflow in databricks/databricks-sql-python +# and the `prCheck` workflow in databricks/databricks-jdbc. + +name: PR Checks + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize, reopened] + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} + cancel-in-progress: true + +permissions: + contents: read + +defaults: + run: + shell: bash + +jobs: + fmt: + name: Formatting + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 + with: + toolchain: stable + components: rustfmt + + - name: cargo fmt --check + run: cargo +stable fmt --all -- --check + + clippy: + name: Clippy + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 + with: + toolchain: stable + components: clippy + + - name: cargo clippy + run: cargo clippy --all-targets -- -D warnings + + test: + name: Unit + doc tests + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + + - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 + with: + toolchain: stable + + - name: cargo test + # Runs every test the default suite executes: unit tests, + # doc tests, and wiremock-backed integration tests. Does NOT + # run the v0_*_e2e suites — those are #[ignore]'d and require + # a live workspace; `rust-e2e.yml` runs them separately. + run: cargo test --workspace diff --git a/.github/workflows/pyo3-checks.yml b/.github/workflows/pyo3-checks.yml new file mode 100644 index 00000000..a6698540 --- /dev/null +++ b/.github/workflows/pyo3-checks.yml @@ -0,0 +1,133 @@ +# 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. + +# 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. + +name: PyO3 Checks + +on: + push: + branches: [main] + paths: + - "pyo3/**" + - "Cargo.toml" + - "Cargo.lock" + - ".github/workflows/pyo3-checks.yml" + pull_request: + branches: [main] + paths: + - "pyo3/**" + - "Cargo.toml" + - "Cargo.lock" + - ".github/workflows/pyo3-checks.yml" + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} + cancel-in-progress: true + +permissions: + contents: read + +defaults: + run: + 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@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + + - 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 + # `azure-prod` holds the Databricks secrets used by the live + # pytest suite below. Fork PRs are paused at "Waiting / approval + # required" until a maintainer clicks through, preventing secret + # exfil. PRs from forks that don't get approval still run the + # cargo-test step (no secrets needed) but the pytest step skips + # the `@live`-marked tests automatically when env vars are unset. + environment: azure-prod + env: + DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }} + DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }} + DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }} + RUST_LOG: databricks_sql_kernel=info + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.12"] + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + + - 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 + + - name: Cargo unit tests (pyo3 crate) + # The pyo3 crate's Rust-side unit tests cover the GIL handoff + # in isolation. Runs before any maturin build so a pure-Rust + # break is caught fast. + run: cargo test -p databricks-sql-kernel-pyo3 + + - 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 }} + + - name: pytest (no-network + live tiers) + working-directory: pyo3 + # `conftest.py` decorates the warehouse-bound tests with + # `@live`; they auto-skip when DATABRICKS_HOST/HTTP_PATH/ + # TOKEN are unset. With the env: block above the live tier + # runs against the configured warehouse on PRs from this + # 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 diff --git a/.github/workflows/rust-e2e.yml b/.github/workflows/rust-e2e.yml index 2b1214c7..44c0cb2b 100644 --- a/.github/workflows/rust-e2e.yml +++ b/.github/workflows/rust-e2e.yml @@ -12,149 +12,78 @@ # See the License for the specific language governing permissions and # limitations under the License. +# End-to-end tests against a live Databricks workspace. +# +# Single `e2e` job covers the v0 surface (Session::open, execute, +# submit, await_result, metadata) via PAT + OAuth M2M. OAuth U2M is +# intentionally absent: it requires a browser flow that can't run in +# CI; `tests/oauth_u2m_integration.rs` covers it on developer +# machines. +# +# Proxy + TLS coverage will land alongside the v0.1 work that fleshes +# out `ProxyConfig` / `TlsConfig` in `src/config.rs` and plumbs them +# through `src/client/http.rs`. Tracked in `docs/migration-plan.md` +# §7. + name: Rust E2E Tests on: push: - branches: - - main + branches: [main] paths: - "src/**" - - .github/workflows/rust-e2e.yml + - "tests/**" + - "Cargo.toml" + - "Cargo.lock" + - ".github/workflows/rust-e2e.yml" pull_request: - branches: - - main + branches: [main] paths: - "src/**" - - .github/workflows/rust-e2e.yml + - "tests/**" + - "Cargo.toml" + - "Cargo.lock" + - ".github/workflows/rust-e2e.yml" concurrency: group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-rust-e2e cancel-in-progress: true +permissions: + contents: read + id-token: write + defaults: run: shell: bash jobs: - proxy: - name: "Proxy" - runs-on: ubuntu-latest + e2e: + name: "v0 E2E surface" + runs-on: + group: databricks-protected-runner-group + labels: linux-ubuntu-latest + environment: azure-prod env: DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }} DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }} + DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }} DATABRICKS_TEST_CLIENT_ID: ${{ secrets.DATABRICKS_TEST_CLIENT_ID }} DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }} - - services: - # Unauthenticated forward proxy (no volume mounts needed) - squid: - image: ubuntu/squid:latest@sha256:6a097f68bae708cedbabd6188d68c7e2e7a38cedd05a176e1cc0ba29e3bbe029 - ports: - - 3128:3128 - + RUST_LOG: databricks_sql_kernel=debug + RUST_BACKTRACE: 1 steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 with: fetch-depth: 0 persist-credentials: false - # Start authenticated proxy after checkout so config files are available - - name: Start authenticated proxy - run: | - docker run -d --name squid-auth \ - -p 3129:3128 \ - -v ${{ github.workspace }}/ci/proxy/squid-auth.conf:/etc/squid/squid.conf \ - -v ${{ github.workspace }}/ci/proxy/htpasswd:/etc/squid/htpasswd \ - ubuntu/squid:latest@sha256:6a097f68bae708cedbabd6188d68c7e2e7a38cedd05a176e1cc0ba29e3bbe029 - # Wait for squid to be ready - for i in $(seq 1 10); do - if docker exec squid-auth squid -k check 2>/dev/null; then - echo "Authenticated proxy is ready" - break - fi - echo "Waiting for authenticated proxy to start... ($i/10)" - sleep 1 - done - - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 - - name: Run proxy E2E tests - run: cargo test --test proxy_e2e -- --ignored --nocapture - - - name: Verify proxy was used (unauthenticated) - if: always() - run: | - docker logs $(docker ps -q --filter "publish=3128") 2>&1 \ - | grep -i "CONNECT" \ - || (echo "FAIL: No CONNECT entries found in squid logs — proxy was not used" && exit 1) - - - name: Verify proxy was used (authenticated) - if: always() - run: | - docker logs squid-auth 2>&1 \ - | grep -i "CONNECT" \ - || (echo "FAIL: No CONNECT entries found in squid-auth logs — proxy was not used" && exit 1) - - - name: Cleanup authenticated proxy - if: always() - run: docker rm -f squid-auth 2>/dev/null || true - - tls: - name: "TLS" - runs-on: ubuntu-latest - env: - DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }} - DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }} - DATABRICKS_TEST_CLIENT_ID: ${{ secrets.DATABRICKS_TEST_CLIENT_ID }} - DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }} - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - fetch-depth: 0 - persist-credentials: false - - # Start mitmproxy in intercepting mode (mitmdump logs all flows to stdout) - - name: Start mitmproxy + - name: Run v0 E2E tests run: | - docker run -d --name mitmproxy \ - -p 8080:8080 \ - mitmproxy/mitmproxy:12.2.1@sha256:743b6cdc817211d64bc269f5defacca8d14e76e647fc474e5c7244dbcb645141 \ - mitmdump --set stream_large_bodies=0 - # Wait for mitmproxy to generate its CA cert - for i in $(seq 1 15); do - if docker exec mitmproxy test -f /home/mitmproxy/.mitmproxy/mitmproxy-ca-cert.pem 2>/dev/null; then - echo "mitmproxy CA cert is ready" - break - fi - echo "Waiting for mitmproxy CA cert... ($i/15)" - sleep 1 + for suite in v0_session_e2e v0_execute_e2e v0_async_execute_e2e v0_metadata_e2e; do + echo "::group::cargo test --test ${suite}" + cargo test --test "${suite}" -- --ignored --nocapture + echo "::endgroup::" done - - # Extract mitmproxy CA certificate for the trusted_certificate_path test - - name: Extract mitmproxy CA certificate - run: | - docker cp mitmproxy:/home/mitmproxy/.mitmproxy/mitmproxy-ca-cert.pem /tmp/mitmproxy-ca-cert.pem - echo "MITMPROXY_CA_CERT=/tmp/mitmproxy-ca-cert.pem" >> "$GITHUB_ENV" - echo "Extracted mitmproxy CA cert:" - openssl x509 -in /tmp/mitmproxy-ca-cert.pem -noout -subject -issuer - - - uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 - - - name: Run TLS E2E tests - run: cargo test --test tls_e2e -- --ignored --nocapture - - - name: Verify traffic flowed through mitmproxy - if: always() - run: | - echo "=== mitmproxy logs ===" - docker logs mitmproxy 2>&1 | tail -50 - echo "=== checking for CONNECT entries ===" - docker logs mitmproxy 2>&1 \ - | grep -i "CONNECT\|clientconnect\|<<" \ - || (echo "FAIL: No traffic entries found in mitmproxy logs — proxy was not used" && exit 1) - - - name: Cleanup mitmproxy - if: always() - run: docker rm -f mitmproxy 2>/dev/null || true diff --git a/.github/workflows/rust_coverage_report.yaml b/.github/workflows/rust_coverage_report.yaml deleted file mode 100644 index 2bf8fb93..00000000 --- a/.github/workflows/rust_coverage_report.yaml +++ /dev/null @@ -1,65 +0,0 @@ -# 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. - -# This workflow runs in the context of the base repository after the -# "Rust Test" workflow completes. It downloads the coverage artifact -# and posts the coverage report as a PR comment. This two-workflow -# approach is necessary because fork PRs do not receive write -# permissions on the GITHUB_TOKEN. - -name: Rust Coverage Report - -on: - workflow_run: - workflows: ["Rust Test"] - types: - - completed - -defaults: - run: - shell: bash - -jobs: - report: - name: "Post Coverage Report" - runs-on: ubuntu-latest - if: > - github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'success' - permissions: - contents: read - pull-requests: write - statuses: write - actions: read - steps: - - name: Download coverage artifact - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 - with: - name: rust-coverage - path: coverage - run-id: ${{ github.event.workflow_run.id }} - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Coverage report - uses: getsentry/codecov-action@bee8d919178e87c35ada22280d7da8b77dda2cbb # main (2025-02-10) - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: coverage/lcov.info - coverage-format: lcov - post-pr-comment: true - commit-sha: ${{ github.event.workflow_run.head_sha }} - target-project: auto - threshold-project: 1 - target-patch: 80 - fail-on-error: false diff --git a/.github/workflows/rust_test_pr.yaml b/.github/workflows/rust_test_pr.yaml deleted file mode 100644 index 6a87118a..00000000 --- a/.github/workflows/rust_test_pr.yaml +++ /dev/null @@ -1,111 +0,0 @@ -# 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. - -# This is a common workflow for testing a PR when permissions are needed. - -name: Rust Test PR - -on: - workflow_dispatch: - inputs: - pr: - description: "The ID of the PR to test (e.g. 42)" - required: true - type: string - ref: - description: "The commit/ref to checkout" - required: true - type: string - -concurrency: - group: ${{ github.repository }}-${{ github.workflow }}-${{ inputs.pr }} - cancel-in-progress: true - -defaults: - run: - shell: bash - -permissions: - contents: read - packages: read - pull-requests: read - -jobs: - setup: - name: configure job - runs-on: ubuntu-slim - outputs: - repository: ${{ steps.get_repo.outputs.repository }} - steps: - - name: get repository - id: get_repo - env: - GH_TOKEN: ${{ github.token }} - run: | - echo repository=$(gh pr --repo ${{ github.repository }} view ${{ inputs.pr }} --json headRepository,headRepositoryOwner --jq '"\(.headRepositoryOwner.login)/\(.headRepository.name)"') | tee -a $GITHUB_OUTPUT - - - name: set job summary - run: | - echo "**PR:** https://github.com/${{ github.repository }}/pull/${{ inputs.pr }}" >> $GITHUB_STEP_SUMMARY - echo "**Remote:** ${{ steps.get_repo.outputs.repository }}@${{ inputs.ref }}" >> $GITHUB_STEP_SUMMARY - - test: - # TODO(kernel): port the reusable `rust_test.yaml` workflow from - # adbc-drivers/databricks into this repo's .github/workflows/. Until then - # this job will fail because the referenced workflow does not exist here. - uses: adbc-drivers/databricks/.github/workflows/rust_test.yaml@main - needs: - - setup - with: - repository: ${{ needs.setup.outputs.repository }} - ref: ${{ inputs.ref }} - secrets: - # https://github.com/orgs/community/discussions/25238#discussioncomment-3247035 - DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }} - TEST_PECO_WAREHOUSE_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }} - DATABRICKS_TEST_CLIENT_ID: ${{ secrets.DATABRICKS_TEST_CLIENT_ID }} - DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }} - - report: - name: comment on PR - runs-on: ubuntu-slim - if: ${{ always() }} - needs: - - setup - - test - permissions: - actions: read - pull-requests: write - steps: - - id: get_run - env: - GH_TOKEN: ${{ github.token }} - run: | - echo workflow_run_url=$(gh run --repo ${{ github.repository }} view ${{ github.run_id }} --json url --jq '.url') | tee -a $GITHUB_OUTPUT - if [[ '${{ needs.test.result }}' == 'success' ]]; then - echo message=":heavy_check_mark: **Test passed:** " | tee -a $GITHUB_OUTPUT - else - echo message=":x: **Test failed:** " | tee -a $GITHUB_OUTPUT - fi - - - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - github-token: ${{ github.token }} - script: | - github.rest.issues.createComment({ - issue_number: ${{ inputs.pr }}, - owner: context.repo.owner, - repo: context.repo.repo, - body: '${{ steps.get_run.outputs.message }} ${{ needs.setup.outputs.repository }}@${{ inputs.ref }}\nWorkflow run: ${{ steps.get_run.outputs.workflow_run_url }}' - }) diff --git a/.gitignore b/.gitignore index 8100817b..d13f947a 100644 --- a/.gitignore +++ b/.gitignore @@ -27,9 +27,14 @@ # Code coverage profiles and other test artifacts *.out -coverage.* +coverage.json +coverage.lcov +coverage.txt +coverage.html +coverage.info *.coverprofile profile.cov +lcov.info # Dependency directories (remove the comment below to include it) # vendor/ diff --git a/CLAUDE.md b/CLAUDE.md index 5fb17961..486a44a1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -49,7 +49,7 @@ cargo test ## PR conventions - Title follows [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/): `type(scope): description`. No JIRA prefixes — CI rejects them. -- Commits must be DCO-signed (`git commit -s`). +- Commits must be DCO-signed (`git commit -s`). Enforced by `.github/workflows/dco-check.yml`. ## Architecture @@ -84,31 +84,14 @@ constructors on `Error` (`Error::invalid_argument()`, `Error::io()`, `Error::not_implemented()`, `Error::invalid_state()`, …) chained with `.message(...)` / `.with_source(...)` / `.sqlstate(...)`. -## License headers - -Apache 2.0 headers are required on all source files; CI runs Apache RAT. - -Rust: -```rust -// Copyright (c) 2026 Databricks, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// ... -``` - -Markdown (HTML comment): -```html - -``` - ## Adding Cargo dependencies -CI runs `cargo-about` and fails on unapproved licenses. New permissive licenses must be added to the `accepted` list in `about.toml`. +CI runs `cargo-deny check` (`.github/workflows/license-check.yml`) +and fails on unapproved licenses or RustSec advisories. New +permissive licenses must be added to `[licenses].allow` in +`deny.toml` with PR-description justification. `about.toml` is +preserved separately for generating attribution pages on demand; +the CI gate lives on `deny.toml`. ## Local development environment diff --git a/ci/test_package.py b/ci/test_package.py deleted file mode 100644 index 50db64bd..00000000 --- a/ci/test_package.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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. - -import adbc_driver_manager.dbapi -import pytest - - -def test_package() -> None: - with pytest.raises(adbc_driver_manager.dbapi.Error): - with adbc_driver_manager.dbapi.connect(driver="databricks"): - pass diff --git a/deny.toml b/deny.toml new file mode 100644 index 00000000..19b1171e --- /dev/null +++ b/deny.toml @@ -0,0 +1,54 @@ +# 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. + +# Configuration for cargo-deny. See https://embarkstudios.github.io/cargo-deny/. +# Enforced by .github/workflows/license-check.yml. + +[graph] +all-features = true + +[advisories] +yanked = "warn" +ignore = [] + +[licenses] +# Permissive licenses we allow in transitive deps. Adding a new +# entry requires PR-description justification. +allow = [ + "Apache-2.0", + "BSD-2-Clause", + "BSD-3-Clause", + "CDLA-Permissive-2.0", + "ISC", + "MIT", + "MIT-0", + "MPL-2.0", + "Unicode-3.0", + "Unicode-DFS-2016", + "Unlicense", + "Zlib", +] +# Confidence threshold for license-text matching. 0.8 is the +# cargo-deny default; 0.93 reduces false positives for crates with +# slightly non-standard licence text. +confidence-threshold = 0.93 + +[bans] +# Tighten over time. Today we just want license enforcement live. +multiple-versions = "allow" +wildcards = "allow" + +[sources] +unknown-registry = "warn" +unknown-git = "warn" diff --git a/docs/migration-plan.md b/docs/migration-plan.md index 1aee40b4..4bbf56c8 100644 --- a/docs/migration-plan.md +++ b/docs/migration-plan.md @@ -932,6 +932,38 @@ clear it. session are visibly grouped (matches the legacy ADBC layer's `_log_span` pattern). +### Proxy + TLS E2E coverage (v0.1) + +The legacy ADBC layer carried live-network proxy and TLS E2E tests +(`tests/proxy_e2e.rs`, `tests/tls_e2e.rs`); both were deleted in +PR #11 alongside the ADBC code. The v0 ports of those files were +briefly staged behind a `proxy_tls_e2e` cargo feature in an earlier +revision of PR #17 but were removed: the kernel-side `ProxyConfig` +/ `TlsConfig` fields they referenced don't exist yet (both structs +are `#[non_exhaustive]` placeholders in `src/config.rs`), so the +test files didn't compile and the gating churn was strictly +clutter. + +`ci/proxy/{squid-auth.conf,htpasswd}` is preserved on the branch +for reuse when the v0.1 work lands. + +v0.1 work is a single PR off `main`: + +1. **Flesh `ProxyConfig`** in `src/config.rs` with fields + `url: String`, `username: Option`, + `password: Option`, `bypass_hosts: Vec`. +2. **Flesh `TlsConfig`** with `trusted_certificate_path: Option`, + `allow_self_signed: bool`, `allow_hostname_mismatch: bool`. +3. **Plumb both through** `src/client/http.rs` so the HTTP client + actually honours them (the legacy `crate::client::http::{ProxyConfig, + TlsConfig}` already had working production-shaped impls in the + ADBC layer — this is a lift, not a re-invent). +4. **Port `tests/proxy_e2e.rs` + `tests/tls_e2e.rs`** fresh against + the new struct shape (the ADBC-era versions in git history are + the reference) and add `proxy` + `tls` jobs to + `.github/workflows/rust-e2e.yml` with the inline `docker run` + pattern the `e2e` job already uses. + ## 8. Estimated scope | PR | LoC est | Risk | Notes | diff --git a/manifest.toml b/manifest.toml deleted file mode 100644 index c5afd579..00000000 --- a/manifest.toml +++ /dev/null @@ -1,26 +0,0 @@ -# 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. - -# TODO(kernel): Remove this ADBC driver manifest once the kernel surfaces its -# own non-ADBC FFI and ADBC becomes one of several optional adapters rather -# than the primary identity. Kept for now so `adbc-driver-manager` can still -# discover the kernel as an ADBC driver during the transition. - -name = "Databricks Driver" -description = "Databricks SQL Kernel — exposed via the ADBC trait layer" -publisher = "Databricks, Inc." -license = "Apache-2.0" - -[ADBC] -version = "v1.1.0"