-
Notifications
You must be signed in to change notification settings - Fork 156
chore: Add commit hooks for testing and linting #149
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
Changes from 9 commits
25f9d5c
19728a9
3147952
40906ec
3714ccb
9d8bc12
0243e20
074e8eb
b08d0df
a7cbb03
5605966
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run lerna-lint |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
"main": "lib/index.js", | ||
"types": "lib/", | ||
"scripts": { | ||
"init-environment": "husky install", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add this to a postinstal script potentially, so it gets run automatically? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on recommendation from husky I did not add the prepare script to the pre- or post-install steps. Package managers seem to have discouraged this recently. Unless we have a strong opinion, I'd stick with the recommendation from husky. What do you think? If a contributor forgets this step, they should still be able to contribute. They'll see failures in the PR builds if the violate the linting or tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm always a fan of a few manual steps as possible, not a massive problem, but it's an extra step people need to read/act on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The recommendation from package managers appears sensible on the grounds of better security. I think that if we do a good job of documenting the setup of the dev environment on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Our PR builds already lint and test the contributor's code. We can add a checklist step indicating that they should lint&test, but the checklist step is not required to make them aware of failures. I'm not inclined to add a checklist step, as this would repeat work that our PR checks already do. I'm open to adding it, if there's another reason :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. I don't have a good answer though, I think we are all in agreement that the main branch is already protected against untested/un-linted code. On the other hand we want to favor automation as much as possible, so the happy path here would be that a contributor installs and runs the hooks which in turn would mean these steps of the workflow would pass. There's a non-zero chance that some contributors will forget to install (and perhaps run) these hooks and in case their code is not linted the workflow will fail. Its not at all a big deal since the contributor will see the error, fix it and commit again. My reasoning was that having an additional check on the list that says "lint your code (this is done automatically via husky [link to relevant script/explanation])" could help avoid some frustration for some, especially those who are new to all this kind of tooling. Either way all this is a supposition on my part, am more than happy to not add the item and reconsider if this ever becomes a problem :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I understand now, great idea! I'll work that in :) |
||
"test": "npm run lerna-test", | ||
"commit": "commit", | ||
"lerna-ci": "lerna exec -- npm ci", | ||
"lerna-test": "lerna exec -- npm run test", | ||
|
@@ -39,6 +41,7 @@ | |
"@typescript-eslint/eslint-plugin": "^4.11.1", | ||
"@typescript-eslint/parser": "^4.11.1", | ||
"eslint": "^7.16.0", | ||
"husky": "^7.0.1", | ||
"jest": "^27.0.4", | ||
"lerna": "^4.0.0", | ||
"ts-jest": "^27.0.3", | ||
|
Uh oh!
There was an error while loading. Please reload this page.