black icon indicating copy to clipboard operation
black copied to clipboard

[ISSUE] Github Action Black failing after successful reformatting.

Open tikendraw opened this issue 2 years ago • 1 comments

Describe the bug

Trying to use Black in github actions and it is failing after reformatting. Shouldn't it be passing after reformatting without errors ?

name: Lint

on: [push, pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: psf/black@stable

To Reproduce use black in github action

The resulting error is: failing github action after reformatting

would reformat /home/runner/work/catsay/catsay/catsay/cat.py

Oh no! 💥 💔 💥
1 file would be reformatted, 4 files would be left unchanged.
Error: Process completed with exit code 1.

Expected behavior If black has reformatted files witout any errors then actions should pass a success, not a fail

tikendraw avatar Jan 18 '24 04:01 tikendraw

Hi @tikendraw,

The black GitHub action doesn't format your files by default. See the following lines in the documentation,

You can also configure the arguments passed to Black via options (defaults to '--check --diff') and src (default is '.').

The action's default behavior is simply to notify you of changes it would've made if called without the --check flag

If you're looking for the action to make the changes for you then you may find this documentation helpful.

dankrzeminski32 avatar Jan 22 '24 20:01 dankrzeminski32