prettier_action icon indicating copy to clipboard operation
prettier_action copied to clipboard

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

Open rutajdash opened this issue 3 years ago • 5 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

rutajdash avatar Nov 28 '21 15:11 rutajdash

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

creyD avatar Nov 30 '21 16:11 creyD

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 avatar Dec 06 '21 11:12 creyD

@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?

fsz-codeshop avatar Dec 07 '21 14:12 fsz-codeshop

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.

rutajdash avatar Dec 07 '21 14:12 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?

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

rutajdash avatar Dec 07 '21 14:12 rutajdash

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".

semseysandor avatar Sep 13 '22 20:09 semseysandor

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

creyD avatar Sep 15 '22 09:09 creyD