creyD/prettier_action

[BUG] Prettier exits with code 1 in dry run when all files are already formatted.

Closed this issue · 7 comments

What exactly happened?
Prettier exited with code 1 resulting in a failed step even when it found all files formatted correctly.

What should've happened?
Prettier should exit with code 0 (no error)

How did it look?
If applicable, add screenshots to help explain your problem.

Where did you encounter the problem?

  • OS: ubuntu-latest
  • Action Version - v4.0

The repo is private and it was running on a fork but all permissions were given, even write permissions which wouldn't be required IMO.

Screenshots
Error:
image

The configurations:
Action:
image

Prettierrc:
image

creyD commented

@fsz-codeshop This seems like its happening inside the lines 94-97 in entrypoint.sh. Could you please take a look here?

creyD commented

Could you please try to reproduce and look if it still happens with v4.1.1? I tried a similar process and it worked alright with the current version @rutajdash

@creyD sorry for the late reply. I was checking this issue and something if off.
According to the print screens "prettier options" is using --check, so the _git_changed() should not be entering block 92-132 and should run the block 133-142.

I suspect there is something on the workflow that is making the "git status -s" return true for his particular case.
@rutajdash is your workflow doing any other work on the local checked out code that might be making the "git status -s" be returning true?

Could you please try to reproduce and look if it still happens with v4.1.1? I tried a similar process and it worked alright with the current version @rutajdash

I'll definitely test this out and get back to you.

@creyD sorry for the late reply. I was checking this issue and something if off.
According to the print screens "prettier options" is using --check, so the _git_changed() should not be entering block 92-132 and should run the block 133-142.

I suspect there is something on the workflow that is making the "git status -s" return true for his particular case.
@rutajdash is your workflow doing any other work on the local checked out code that might be making the "git status -s" be returning true?

I'm using a fresh workflow but I'm also using GitHub Artifacts, so that may be adding some files. It's possible.

I had the exact same issue. Running git status -s before prettier in the workflow revealed that a previous step (code style check with php-cs-fixer) created a cache file with unexpected (at least for me) name.
After changing that filename to what was already ignored in .gitignore , git status -s reported no change and prettier finished successfully.

So, I think this issue could be closed as "user error".

creyD commented

@rutajdash Could you please check out @semseysandor answer and reopen if needed? Thank you @semseysandor