diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index 5d36f510b9..0ed148bc88 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -9,13 +9,26 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: - python-version: '3.10' + python-version: '3.10' + + # Fork PRs: Check formatting and fail with diff if issues exist + # (Cannot create fix PR because we don't have write access to fork branches) + - name: (Python) Check formatting with black (fork PRs) + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository + run: | + pip install black + cd GrpcInterface + black --check --diff . + + # Same-repo PRs and pushes: Apply fixes and create PR if needed - name: (Python) Use black to do linting + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository run: | pip install black cd GrpcInterface black . - uses: peter-evans/create-pull-request@v8 + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Python code linting changes detected by black"