diff --git a/.github/workflows/black-lint.yml b/.github/workflows/black-lint.yml deleted file mode 100644 index e0b5e1379..000000000 --- a/.github/workflows/black-lint.yml +++ /dev/null @@ -1,13 +0,0 @@ -# https://black.readthedocs.io/en/stable/integrations/github_actions.html - -name: Black Lint - -on: [push, pull_request] - -jobs: - black-lint: - permissions: {} # Remove all permissions - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: psf/black@23.12.1 diff --git a/.github/workflows/black-suggest.yml b/.github/workflows/black-suggest.yml deleted file mode 100644 index e9201b786..000000000 --- a/.github/workflows/black-suggest.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: black Suggest -on: [pull_request] -jobs: - formatting-check: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'pip' # caching pip dependencies - - run: - pip install black==23.12.1 - - name: Run black style check. - run: | - black . - - uses: parkerbxyz/suggest-changes@v1 - with: - comment: 'Please commit the suggested changes from black.' diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 000000000..d4f782d13 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,36 @@ +name: Black lint and suggest changes + +on: [pull_request] + +jobs: + black-lint-and-suggest: + permissions: # needed in forks? + contents: read + pull-requests: write + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' # caching pip dependencies + - run: pip install black==23.12.1 + + - name: Run black + run: black . # if this fails nothing else will run, this is correct behavior + + - name: Suggest changes via comment + uses: parkerbxyz/suggest-changes@v1 + with: + comment: 'Please commit the suggested changes from black.' + + - name: Fail if changes were made + run: | + if git diff --quiet; then + echo "Black formatting applied no changes." + exit 0 + else + run: | + echo "Black formatting applied changes. Please format with black." + exit 1 + fi \ No newline at end of file