Skip to content

Add GitHub push action enforcing Prettier style #451

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

Merged
merged 2 commits into from
Aug 21, 2023

Conversation

eemeli
Copy link
Collaborator

@eemeli eemeli commented Aug 15, 2023

The styles we use to write markdown vary, and the result is occasionally a bit messy.

Prettier defines some pretty decent defaults, and using them allows us to care less about the style we use. This PR adds a GitHub Action that runs Prettier after every commit that touches a .md file and pushes any changes to the current branch with a style: Apply Prettier commit message.

The first commit here fixes the one place where the styling appeared to cause an issue in spec/syntax.md; the second commit has been automatically generated by the action.

@eemeli eemeli requested a review from aphillips August 15, 2023 00:17
@CLAassistant
Copy link

CLAassistant commented Aug 15, 2023

CLA assistant check
All committers have signed the CLA.

@eemeli
Copy link
Collaborator Author

eemeli commented Aug 15, 2023

It looks like the action's email address will need to match one that's acceptable to the CLA bot.

@aphillips @macchiati Is there any such bot email address yet that could be used?

@srl295
Copy link
Member

srl295 commented Aug 15, 2023

I'll add it as an exception.
Same as dependabot.

Ok to fix tomorrow?

@eemeli
Copy link
Collaborator Author

eemeli commented Aug 15, 2023

Tomorrow's completely fine; this is fixing a long-running annoyance.

Right now the email address is empty in the generated commits, so please tell me which address to use once you've got it set up? For example, [email protected] could work.

@srl295
Copy link
Member

srl295 commented Aug 15, 2023

I don't know what a good email would be. But i wonder if actions would be a better username since that's already reserved. Someone could sign up and spoof this one!

Anyway i added it to the allow list so you should be able to pass this

Copy link
Member

@srl295 srl295 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM can update the id later

@eemeli
Copy link
Collaborator Author

eemeli commented Aug 15, 2023

I set the action to use github-actions <[email protected]>. Not sure if the CLA checked has re-run itself though?

@srl295
Copy link
Member

srl295 commented Aug 15, 2023

github-actions seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.

@srl295
Copy link
Member

srl295 commented Aug 15, 2023

I set the action to use github-actions <[email protected]>. Not sure if the CLA checked has re-run itself though?

seemed to make it not work… i just added github-actions as the exclusion (by the github id not the email)

@srl295
Copy link
Member

srl295 commented Aug 15, 2023

🎉

@eemeli
Copy link
Collaborator Author

eemeli commented Aug 15, 2023

Phew, I think it's now sorted? Thank you @srl295 for your help here!

@srl295
Copy link
Member

srl295 commented Aug 15, 2023

image seems ok

Copy link
Member

@srl295 srl295 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 for persistence

Copy link
Collaborator

@stasm stasm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds a GitHub Action that runs Prettier after every commit that touches a .md file and pushes any changes to the current branch with a style: Apply Prettier commit message.

Please don't auto-commit to main like this. It will generate needless diffs, making browsing the history and blaming files more difficult. Instead, let's set up a CI check on all PRs and require it to pass before merging. All changes to the spec should go through PRs anyways.

@eemeli
Copy link
Collaborator Author

eemeli commented Aug 16, 2023

This would have the same effect on PRs as a CI check, because it's run on all pushes on all forks. The benefit of doing it this way is that the style corrections are automatic rather than blocking.

For example, if a PR review suggestion commit introduces some trailing whitespace to a spec PR, this would immediately fix that, rather than blocking the PR with a failing check which would need manual action.

The only way this would add a spec/ changing commit directly on main is if someone else first edits it directly, without going through the PR process.

@eemeli eemeli requested a review from stasm August 16, 2023 11:52
@srl295
Copy link
Member

srl295 commented Aug 16, 2023

This PR adds a GitHub Action that runs Prettier after every commit that touches a .md file and pushes any changes to the current branch with a style: Apply Prettier commit message.

Please don't auto-commit to main like this. It will generate needless diffs, making browsing the history and blaming files more difficult. Instead, let's set up a CI check on all PRs and require it to pass before merging. All changes to the spec should go through PRs anyways.

that's what CLDR and Unicodetools do. if you forget, your PR just doesn't pass until it's fixed.

Auto committing to a PR seems reasonable.

@stasm
Copy link
Collaborator

stasm commented Aug 16, 2023

This would have the same effect on PRs as a CI check, because it's run on all pushes on all forks. The benefit of doing it this way is that the style corrections are automatic rather than blocking.

Oh, do you mean that there will be automatic commits in the PR's branch, but since we merge by squashing, they will never make it to main?

@srl295
Copy link
Member

srl295 commented Aug 16, 2023

@eemeli i would recommend having the action only apply to PRs and not to main.

@macchiati
Copy link
Member

macchiati commented Aug 16, 2023 via email

@eemeli
Copy link
Collaborator Author

eemeli commented Aug 16, 2023

@stasm:
Oh, do you mean that there will be automatic commits in the PR's branch, but since we merge by squashing, they will never make it to main?

Yes. Going forward, to submit a PR you'll need a branch here or a fork of this repo that'll include the .github/workflows/prettier.yaml that's added by this PR, and it'll trigger the action which will (if necessary) add a commit to the PR branch with the style fixes.

@srl295:
i would recommend having the action only apply to PRs and not to main.

The problem is that if/as we do occasionally commit directly to main e.g. most recently with 828d4cb adding meeting notes, if those commits do introduce something that doesn't match the Prettier styles, they would get picked up by all subsequent PR branches until one of them is merged -- it's much trickier to configure Prettier to only apply itself to the files actually changed on a branch, rather than all files.

Allowing commits also on main only really affects meeting notes and similar administrativia, not the spec. If we do want to prevent the action from running on main, then really we should protect the branch and require all its changes to land via PRs. This would probably inconvenience @aphillips more than anyone else; do you have an opinion on such a change?

Copy link
Collaborator

@stasm stasm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As agreed in today's meeting, let's try this as-is and see how many auto-commits actually make it to main.

@aphillips aphillips merged commit c3b31e4 into unicode-org:main Aug 21, 2023
@eemeli eemeli deleted the force-pretty branch August 21, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants