Commit 5b72273
committed
[SPARK-56018][INFRA][FOLLOW-UP] Install black for older branches in Python CodeGen check
### What changes were proposed in this pull request?
This PR adds a conditional step in the `buf` job of `build_and_test.yml` to install `black` for older branches while keeping `ruff` for `master` and newer branches.
### Why are the changes needed?
SPARK-56018 replaced `black` with `ruff` as the Python formatter in the "Install dependencies for Python CodeGen check" step. However, this workflow is also used by scheduled builds for older branches, whose `gen-protos.sh` still calls `black` for formatting. This causes those builds to fail with:
```
+ black --config /home/runner/work/spark/spark/dev/pyproject.toml gen/proto/python
/home/runner/work/spark/spark/dev/gen-protos.sh: line 119: black: command not found
Traceback (most recent call last):
File "/home/runner/work/spark/spark/./dev/check-protos.py", line 84, in <module>
Start checking the generated codes in pyspark-connect.
RUN: /home/runner/work/spark/spark/dev/gen-protos.sh connect /tmp/check_connect__protos6imuoe88
check_protos(
File "/home/runner/work/spark/spark/./dev/check-protos.py", line 49, in check_protos
run_cmd(f"{SPARK_HOME}/dev/gen-protos.sh {module_name} {tmp}")
File "/home/runner/work/spark/spark/./dev/check-protos.py", line 43, in run_cmd
return subprocess.check_output(cmd.split(" ")).decode("utf-8")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/home/runner/work/spark/spark/dev/gen-protos.sh', 'connect', '/tmp/check_connect__protos6imuoe88']' returned non-zero exit status 127.
```
For example: https://github.com/apache/spark/actions/runs/24597946594/job/71931532850
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Monitor the daily test results for branch-4.1 after merging.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #55407 from LuciferYang/SPARK-56018-FOLLOWUP.
Authored-by: YangJie <yangjie01@baidu.com>
Signed-off-by: yangjie01 <yangjie01@baidu.com>1 parent 6805ed8 commit 5b72273
1 file changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
843 | 848 | | |
| 849 | + | |
844 | 850 | | |
845 | 851 | | |
846 | 852 | | |
| |||
0 commit comments