This is an automated email from the ASF dual-hosted git repository.

viirya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark-connect-rust.git


The following commit(s) were added to refs/heads/master by this push:
     new 1aed3b16 [SPARK-61420][CONNECT][INFRA] Enforce coverage floors in the 
Coverage workflow, and remove the Rust checks job that duplicates rust.yml
1aed3b16 is described below

commit 1aed3b16d68f650659766df45f4af82e5df8b5e8
Author: Liang-Chi Hsieh <[email protected]>
AuthorDate: Tue Nov 10 18:07:08 2026 -0800

    [SPARK-61420][CONNECT][INFRA] Enforce coverage floors in the Coverage 
workflow, and remove the Rust checks job that duplicates rust.yml
    
    ### What changes were proposed in this pull request?
    
    **Coverage floors.** The Coverage workflow now fails when a measured number 
is below its floor. The floors are two variables in the `env` block of 
`coverage.yml`:
    
    | | Latest on `master` | Last 12 runs of `master` | Floor |
    |---|---|---|---|
    | Rust (line coverage, `cargo llvm-cov`) | 92.9% | 92.3 – 92.9% | 
`RUST_COVERAGE_FLOOR: "92.0"` |
    | Python (lines and branches, `coverage.py`, scope of `python/.coveragerc`) 
| 93.5% | 93.5 – 93.9% | `PYTHON_COVERAGE_FLOOR: "93.0"` |
    
    The measured values are read from the history of the `badges` branch 
(latest `92d4178`). The check is the last step of the job, after the badge and 
the artifacts are published, so a run below a floor still reports the number it 
measured. It reads only the environment, because on a push to `master` the 
badge step leaves the checkout on the `badges` branch.
    
    **Offline Python suite.** `python/tests/test_dropin_offline.py`, 
`test_arrow_handoff.py` and `test_ml_offline.py` already run in this workflow 
on every pull request, and a failing test fails the job, so no test step is 
added elsewhere. The step is renamed for what it gates and passes `-rs`, so 
that a test skipped for a missing or too-old dependency shows in the log 
(`test_ml_offline.py` skips as a whole module when protobuf is older than 
6.33.5).
    
    **Duplicate job.** Remove the `rust-checks` job of 
`build_python_connect.yml`. It ran `cargo build --release`, `cargo test -p 
apache-spark-connect -p apache-spark-connect-core --release` and 
`scripts/audit_no_stubs.sh` with `RUSTFLAGS="-D warnings"`. The 
`rust-build-and-test` job of `rust.yml` runs the same three commands with the 
same flags on the same push and pull_request triggers, plus the datafusion and 
polars features. The two jobs have different cache keys, so each pull request 
[...]
    
    `dev/design/ci.md` gains a section on the Coverage workflow.
    
    ### Why are the changes needed?
    
    `AGENTS.md` states a coverage target above 90% on both sides, but the 
percentage only picked the colour of a badge: nothing failed when coverage 
dropped. The floors are regression floors set just below what `master` 
measures, so they hold the current level without going red on merge.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. CI only.
    
    ### How was this patch tested?
    
    - Both workflow files parse as YAML; `build_python_connect.yml` has the 
four remaining jobs.
    - The three changed step scripts were extracted from the workflow and run 
locally on sample reports: at the measured values and exactly at the floors the 
last step exits 0; with either side below its floor it exits 1 and prints the 
`::error::` line.
    - The Coverage run of this pull request is the first run of the floor check 
on GitHub Actions. Worth a look in its log: the two `coverage: … (floor …): ok` 
lines, and the skip list that `-rs` prints for the offline suite.
    
    A manual dispatch of `build_python_connect.yml` no longer runs the Rust 
build, tests and audit; `rust.yml` has no manual trigger.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Yes.
    
    Closes #496 from viirya/offline-tests-gate-d46f1d.
    
    Authored-by: Liang-Chi Hsieh <[email protected]>
    Signed-off-by: Liang-Chi Hsieh <[email protected]>
---
 .github/workflows/build_python_connect.yml | 39 +----------------------
 .github/workflows/coverage.yml             | 50 ++++++++++++++++++++++++++++--
 dev/design/ci.md                           | 28 +++++++++++++++++
 3 files changed, 77 insertions(+), 40 deletions(-)

diff --git a/.github/workflows/build_python_connect.yml 
b/.github/workflows/build_python_connect.yml
index 1e13414a..8d2ba74f 100644
--- a/.github/workflows/build_python_connect.yml
+++ b/.github/workflows/build_python_connect.yml
@@ -28,7 +28,7 @@ concurrency:
 # Rust-backed client: download the Spark 4.3.0 Connect server, start it, pull 
the
 # official v4.3.0 connect test files, and run them through our client - the 
gate is
 # "every test passes except the checked-in known-environmental-failures 
manifest".
-# A separate job enforces Rust test coverage across all crates.
+# The build, the tests and the no-stub audit of the pure-Rust crates run in 
rust.yml.
 
 on:
   push:
@@ -654,40 +654,3 @@ jobs:
             /tmp/bench_ours.json
             /tmp/bench_compare.txt
           if-no-files-found: warn
-
-  # ---------------------------------------------------------------------------
-  # Rust checks - must be fully green.
-  # ---------------------------------------------------------------------------
-  rust-checks:
-    name: Rust checks
-    runs-on: ubuntu-latest
-    # Hard-fail on any compiler warning in our workspace crates (cargo caps 
dependency
-    # lints to `allow`, so third-party deps are unaffected). Job-scoped on 
purpose: the
-    # parity job above builds the pyspark-rs extension, which this must not 
gate.
-    env:
-      RUSTFLAGS: "-D warnings"
-    steps:
-      - uses: actions/checkout@v4
-      - name: Install Rust toolchain
-        run: |
-          rustup toolchain install stable --profile minimal
-          rustup default stable
-      - name: Cache cargo & target
-        uses: actions/cache@v4
-        with:
-          path: |
-            ~/.cargo/registry
-            ~/.cargo/git
-            target
-          key: ${{ runner.os }}-cargo-checks-${{ hashFiles('**/Cargo.lock') }}
-          restore-keys: ${{ runner.os }}-cargo-checks-
-      - name: Install system dependencies
-        run: |
-          sudo apt-get update && sudo apt-get install -y protobuf-compiler
-      - name: Cargo build
-        run: cargo build --release
-      - name: Cargo test
-        run: cargo test -p apache-spark-connect -p apache-spark-connect-core 
--release
-      - name: No-stub audit
-        run: bash scripts/audit_no_stubs.sh
-
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 4c5783e3..9b92b156 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -33,6 +33,14 @@ on:
 env:
   CARGO_TERM_COLOR: always
   SPARK_VERSION: "4.3.0"
+  # Coverage floors, in percent, enforced by the last step of the job. They 
are regression
+  # floors set just below what master measures, not the target: AGENTS.md 
states the target
+  # (>90% on both sides). Rust is the line coverage of cargo-llvm-cov; Python 
is the
+  # percent_covered of coverage.py (lines and branches) within the scope of 
python/.coveragerc.
+  # The Rust number moves by about 0.1 between runs of the same commit, since 
the e2e tests
+  # run against a live server. Raise a floor as coverage grows; lower one only 
on purpose.
+  RUST_COVERAGE_FLOOR: "92.0"
+  PYTHON_COVERAGE_FLOOR: "93.0"
 
 jobs:
   coverage:
@@ -174,6 +182,7 @@ jobs:
         run: |
           python3 << 'PYTHON_EOF'
           import json
+          import os
 
           # Read the llvm-cov output. NB: this report is named 
coverage-rust-llvm.json,
           # NOT coverage-rust.json - the latter is the badge file published at 
the root of
@@ -219,6 +228,10 @@ jobs:
           with open("coverage-rust-badge.json", "w") as f:
               json.dump(badge_json, f)
 
+          # The floor is checked in the last step, after the badge is 
published.
+          with open(os.environ["GITHUB_ENV"], "a") as f:
+              f.write(f"RUST_COVERAGE_PCT={coverage_pct}\n")
+
           print(f"Rust coverage: {coverage_pct:.1f}% ({color})")
           PYTHON_EOF
 
@@ -227,10 +240,14 @@ jobs:
           cargo build -p pyspark-rs --release
           cp target/release/lib_pyspark.so python/pyspark/_pyspark.so
 
-      - name: Measure Python coverage with offline test suite
+      - name: Offline Python test suite (under coverage)
+        # This step is the only place the offline suite runs, on every pull 
request and
+        # every push, so it is the gate for these tests as well as the 
coverage measurement:
+        # a failing test fails the job here. -rs lists every skipped test with 
its reason,
+        # so that a test skipped for a missing or too-old dependency shows in 
the log.
         run: |
           cd python
-          PYTHONPATH=$(pwd) python -m coverage run --rcfile=.coveragerc -m 
pytest \
+          PYTHONPATH=$(pwd) python -m coverage run --rcfile=.coveragerc -m 
pytest -rs \
             tests/test_dropin_offline.py tests/test_arrow_handoff.py 
tests/test_ml_offline.py
           PYTHONPATH=$(pwd) python -m coverage json --rcfile=.coveragerc -o 
coverage-python.json
 
@@ -238,6 +255,7 @@ jobs:
         run: |
           python3 << 'PYTHON_EOF'
           import json
+          import os
 
           # Read the coverage JSON output
           with open("python/coverage-python.json", "r") as f:
@@ -265,6 +283,10 @@ jobs:
           with open("coverage-python-badge.json", "w") as f:
               json.dump(badge_json, f)
 
+          # The floor is checked in the last step, after the badge is 
published.
+          with open(os.environ["GITHUB_ENV"], "a") as f:
+              f.write(f"PYTHON_COVERAGE_PCT={coverage_pct}\n")
+
           print(f"Python coverage: {coverage_pct:.1f}% ({color})")
           PYTHON_EOF
 
@@ -317,6 +339,30 @@ jobs:
             python/coverage-python.json
           retention-days: 5
 
+      - name: Enforce coverage floors
+        # After the badge and the artifacts, so that a run below a floor still 
publishes the
+        # number it measured. Reads only the environment: on a push to master 
the step that
+        # updates the badges has left the checkout on the badges branch.
+        run: |
+          python3 << 'PYTHON_EOF'
+          import os
+          import sys
+
+          failed = False
+          for side in ("RUST", "PYTHON"):
+              measured = float(os.environ[f"{side}_COVERAGE_PCT"])
+              floor = float(os.environ[f"{side}_COVERAGE_FLOOR"])
+              ok = measured >= floor
+              failed = failed or not ok
+              print(f"{side.lower()} coverage: {measured:.2f}% (floor 
{floor:.2f}%): {'ok' if ok else 'BELOW FLOOR'}")
+              if not ok:
+                  print(
+                      f"::error::{side.lower()} coverage {measured:.2f}% is 
below the floor of "
+                      f"{floor:.2f}% ({side}_COVERAGE_FLOOR in 
.github/workflows/coverage.yml)"
+                  )
+          sys.exit(1 if failed else 0)
+          PYTHON_EOF
+
       - name: Upload Connect server log
         if: always()
         uses: actions/upload-artifact@v4
diff --git a/dev/design/ci.md b/dev/design/ci.md
index d08bf5a9..5cbb9d21 100644
--- a/dev/design/ci.md
+++ b/dev/design/ci.md
@@ -157,6 +157,34 @@ releases retain their six-hour limit. Check artifacts 
expire after one day;
 release artifacts retain the repository default. Checkout credentials are not
 persisted in either build.
 
+## Coverage and the offline Python suite (`coverage.yml`)
+
+This workflow runs on pushes and pull requests targeting `master` and 
`branch-*`. Its
+one job does three things:
+
+- **Rust coverage**: `cargo llvm-cov` over the unit and golden tests of
+  `apache-spark-connect` and `apache-spark-connect-core`, plus the behavioral 
e2e tests
+  against a live Connect server, merged into one report.
+- **Offline Python suite**: builds the extension and runs
+  `python/tests/test_dropin_offline.py`, `test_arrow_handoff.py` and 
`test_ml_offline.py`
+  under `coverage.py`. No other workflow runs these files, so this step is 
their gate: a
+  failing test fails the job. `-rs` prints every skipped test with its reason. 
The scope
+  of the Python number is the hand-written shim, as `python/.coveragerc` 
defines it.
+- **Coverage floors**: the last step fails the job when a number is below its 
floor,
+  `RUST_COVERAGE_FLOOR` (Rust line coverage) or `PYTHON_COVERAGE_FLOOR` 
(Python line and
+  branch coverage), both set in the `env` block of the workflow. The step runs 
after the
+  badge and the artifacts are published, so a run below a floor still reports 
the number
+  it measured.
+
+The floors are regression floors, set just below what `master` measures; the 
target
+(above 90% on both sides) is in `AGENTS.md`. Raise a floor when coverage has 
grown and
+stayed there. The Rust number moves by about 0.1 between runs of the same 
commit, since
+the e2e tests run against a live server, so keep a floor a few tenths below 
the measured
+value.
+
+On a push to `master` the job also publishes both numbers to the `badges` 
branch, which
+the README badges read.
+
 ## Continuous improvement
 
 The parity ledger (`dev/parity/inventory.csv`) is the source of truth:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to