mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[robotpy] Run black on robotpy files (#9017)
This piggy-backs off #8362. `wpiformat` will handle all the non-python files (C++ trailing spaces in yaml files, etc), and the robotpy files (guarded by being under src/main/python or src/test/python) will be handled by black only.
This commit is contained in:
41
.github/workflows/bazel.yml
vendored
41
.github/workflows/bazel.yml
vendored
@@ -233,3 +233,44 @@ jobs:
|
||||
name: robotpy-pregeneration-fixes
|
||||
path: robotpy-pregeneration.patch
|
||||
if: ${{ failure() }}
|
||||
|
||||
# RobotPy does not want to run the additional python linting that wpiformat
|
||||
# implements, only the black linter. Here we run black on only the files
|
||||
# that get transferred to the upstream mostrobotpy repository
|
||||
robotpy_format:
|
||||
name: "RobotPy Formatting"
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Install black
|
||||
run: |
|
||||
python -m venv ${{ runner.temp }}/black
|
||||
# Keep version in sync with .github/workflows/lint-format.yml
|
||||
${{ runner.temp }}/black/bin/pip3 install black
|
||||
- name: Run black on RobotPy files
|
||||
run: |
|
||||
shopt -s globstar
|
||||
${{ runner.temp }}/black/bin/black **/src/main/python/**/*.py **/src/test/python/**/*.py robotpyExamples --force-exclude "thirdparty"
|
||||
- name: Check output
|
||||
run: git --no-pager diff --exit-code HEAD
|
||||
- name: Generate diff
|
||||
run: git diff HEAD > robotpy-format-fixes.patch
|
||||
if: ${{ failure() }}
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
archive: false
|
||||
path: robotpy-format-fixes.patch
|
||||
if: ${{ failure() }}
|
||||
- name: Write to job summary
|
||||
run: |
|
||||
echo '```diff' >> $GITHUB_STEP_SUMMARY
|
||||
cat robotpy-format-fixes.patch >> $GITHUB_STEP_SUMMARY
|
||||
echo '' >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
if: ${{ failure() }}
|
||||
|
||||
Reference in New Issue
Block a user