-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update prettier entrypoint.sh to consider dry run #8
Conversation
80a727f
to
74a9c2d
Compare
prettier/entrypoint.sh
Outdated
|
||
# case when --write is used with dry-run so if something is unpretty there will always have _git_changed | ||
if _dry_run; then | ||
summarize_changes 'Unpretty Files Changes' | ||
echo "Finishing dry-run. Exiting before committing." | tee -a "$GITHUB_STEP_SUMMARY" | ||
exit 1 | ||
fi | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have two git push
in this workflow, I think it makes sense to extract the dry-run check into a function and call it immediately before each git push
.
2cd4b3e
to
af98583
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build-actions/prettier/action.yml
Line 42 in 9c0188e
description: Running the script in dry mode just shows whether there are files that should be prettified or not |
Should be changed to clarify that the changes that are made will be included in the github job summary.
prettier/entrypoint.sh
Outdated
# case when --write is used with dry-run so if something is unpretty there will always have _git_changed | ||
if _dry_run; then | ||
summarize_changes 'Unpretty Files Changes' | ||
echo "Finishing dry-run. Exiting before committing." | tee -a "$GITHUB_STEP_SUMMARY" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
un-indent by 2 spaces
When dry-run is set to true and we use the --write flag, we expect to see what files we'll need to reformat without pushing to remote. However, this requires us to commit the updated changes caused by prettier. Previously, the placement of the dry run logic was done before committing the formatted files, resulting to us not seeing the expected files format. And only using the '--write' flag will not result to a failure even if there are files that requires formatting. By moving the logic after committing the prettier files, it will show us the comparison between two files, without pushing to remote (given that we use dry flag to true).
b8ac09f
to
67de674
Compare
prettier/action.yml
Outdated
@@ -39,7 +39,7 @@ inputs: | |||
required: false | |||
default: "**" | |||
dry: | |||
description: Running the script in dry mode just shows whether there are files that should be prettified or not | |||
description: Running the script in dry mode just shows whether there are files that should be prettified or not and changes made by prettier will be displayed in github job summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: Running the script in dry mode just shows whether there are files that should be prettified or not and changes made by prettier will be displayed in github job summary | |
description: Run prettier in dry-run mode. Display which files are/aren't prettied and changes made by prettier in the GitHub job summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be prettified
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lzm0: how about this?
prettier/action.yml
Outdated
@@ -39,7 +39,7 @@ inputs: | |||
required: false | |||
default: "**" | |||
dry: | |||
description: Running the script in dry mode just shows whether there are files that should be prettified or not | |||
description: Run prettier in dry-run mode. Display which files are/aren't prettied and changes made by prettier in the GitHub job summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: Run prettier in dry-run mode. Display which files are/aren't prettied and changes made by prettier in the GitHub job summary | |
description: Run prettier in dry-run mode. Display which files are/aren't pretty and changes made by prettier (to make them pretty) in the GitHub job summary |
When dry-run is set to true and we use the
--write
flag, we expect to see what files we'll need to reformat without pushing to remote. However, this requires us to commit the updated changes caused by prettier. Previously, the placement of the dry run logic was done before committing the formatted files, resulting to us not seeing the expected files format. And only using the '--write' flag will not result to a failure even if there are files that requires formatting.By moving the logic after committing the prettier files, it will show us the comparison between two files, without pushing to remote (given that we use dry flag to true). The dry run will exit with code 1 if there are changes done to the files.
This is the following result using the
--write
flag and dry set to true; when encountering files that need formatting:https://github.com/GarnerCorp/gala-testing/actions/runs/8802209844
Versus when we don't have any files to format:
https://github.com/GarnerCorp/gala-testing/actions/runs/8802264992