Skip to content
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

Replace Pre-Commit Hook with GitHub Actions #65

Merged
merged 12 commits into from
Feb 5, 2021

Conversation

justin-lyon
Copy link
Collaborator

This PR replaces the Pre-Commit Hook for linting and formatting with GitHub Actions.

husky and lint-staged have been uninstalled, but the pattern matching has been reused for prettier.

eslint was failing on aura js files, so currently only linting lwc js files.

@justin-lyon
Copy link
Collaborator Author

Gosh I half expected they would run here on this PR.

They ran when I merged my feature/ branch to my fork master branch here
https://github.com/jlyon87/lwc-utils/pull/1/checks

@@ -0,0 +1 @@
**/luxon/**
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ignoring luxon from eslint as it is technically a "lib"

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: PR Gate - Format All
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This job validates formatting of all files matching the same glob pattern used in the pre-commit hook. Maybe a little aggressive, definitely verbose.

Options to improve by adding a .prettierrc and/or .prettierignore to make it more readable for the mere mortals. And that would allow us to simplify the prettier command to just... prettier --check .

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: PR Gate - Lint LWC
Copy link
Collaborator Author

@justin-lyon justin-lyon Feb 5, 2021

Choose a reason for hiding this comment

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

This job lints js files inside lwc folders using the **/lwc/**/*.js glob pattern

@@ -1,17 +1,17 @@
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the prettierrc wasn't pretty, lol

Copy link
Owner

Choose a reason for hiding this comment

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

Lol oops, I only ran it recursively within my aura and lwc folders

"prettier:validate": "prettier --check '**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}'",
"prettier:fix": "prettier --write '**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}'",
"reinstall": "npm ci"
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

White space changes when this file was pretty-fied make it hard to read. Note the husky and lint-staged blocks are removed. Also note that the scripts block has been updated.

@justin-lyon justin-lyon added the chore Devil is in the detail label Feb 5, 2021
@tsalb tsalb mentioned this pull request Feb 5, 2021
@tsalb
Copy link
Owner

tsalb commented Feb 5, 2021

Feel free to merge this when you finish it up (I defer to your judgement here, I have no experience with GH Actions).

My understanding is that this will remove some minor friction during local commits (deprecate husky / lint-staged) and catch everything during a PR. Based on that, I don't think there is a going to be a significant impact on the workflow but please chime in if I'm misunderstanding.

Any gotchas/considerations please document them here, otherwise we can use #66 to test this out!

@justin-lyon
Copy link
Collaborator Author

There are some settings on the repository that synergize with GH Actions.

Setup a Rule for Master that Requires GH Actions before enabling the Merge Button on a PR. (optionally repo admins can ignore this rule)

  • Repo > Settings > Branches > Branch Protection Rules > Add Rule

I'll merge this in now, but I'll cut out a chore branch on this repo to confirm it's working and showcase the feature on a PR - (if it doesn't start spinning jobs right away for #66 that is)

@justin-lyon justin-lyon merged commit 98a8fa3 into tsalb:master Feb 5, 2021
@justin-lyon justin-lyon mentioned this pull request Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Devil is in the detail
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants