| name: Isort and Black Formatting |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| on: |
| pull_request_target: |
| paths: |
| - "**.py" |
| types: [opened, synchronize, reopened, labeled, unlabeled] |
|
|
| defaults: |
| run: |
| shell: bash -x -e -u -o pipefail {0} |
|
|
| jobs: |
| reformat_with_isort_and_black: |
| runs-on: ubuntu-latest |
| permissions: |
| |
| contents: write |
| steps: |
| - name: Checkout branch |
| uses: actions/checkout@v6 |
| with: |
| |
| |
| repository: ${{ github.event.pull_request.head.repo.full_name }} |
| ref: ${{ github.event.pull_request.head.ref }} |
| |
| token: ${{ secrets.NEMO_REFORMAT_TOKEN }} |
| fetch-depth: 0 |
|
|
| - name: Get changed files |
| id: changed-files |
| uses: step-security/changed-files@v45.0.1 |
| with: |
| files: | |
| **.py |
| |
| - name: Setup Python env |
| uses: actions/setup-python@v6 |
| with: |
| python-version: "3.10" |
|
|
| - name: black |
| uses: psf/black@stable |
| if: ${{ steps.changed-files.outputs.any_changed == 'true' }} |
| with: |
| options: "--verbose" |
| |
| src: "${{ steps.changed-files.outputs.all_changed_files }}" |
| version: "~= 24.3" |
|
|
| - name: isort |
| uses: isort/isort-action@v1 |
| if: ${{ steps.changed-files.outputs.any_changed == 'true' }} |
| with: |
| isort-version: "5.13.2" |
| |
| configuration: "" |
|
|
| - uses: EndBug/add-and-commit@v9 |
| |
| with: |
| message: Apply isort and black reformatting |
| commit: --signoff |
|
|