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

Add husky for pre commit hooks 🐶 #174

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

idobetesh
Copy link
Collaborator

No description provided.

@request-info
Copy link

request-info bot commented Jul 7, 2022

Thanks for opening this PR! We would appreciate it if you could provide us with more info about your PR 🙏

@idobetesh
Copy link
Collaborator Author

idobetesh commented Jul 7, 2022

From now on, whenever we commit a change, Husky checks it against the .prettierrc.json file. 🐶

Husky helps you know whether you're good to go:
1

Or need to get some fixes:
2

cc: @relsteiner, fixed 🍻

@codecov
Copy link

codecov bot commented Jul 7, 2022

Codecov Report

Merging #174 (e75622f) into main (2472c3b) will not change coverage.
The diff coverage is n/a.

❗ Current head e75622f differs from pull request most recent head 45f9769. Consider uploading reports for the commit 45f9769 to get more accurate results

@@           Coverage Diff           @@
##             main     #174   +/-   ##
=======================================
  Coverage   75.20%   75.20%           
=======================================
  Files           4        4           
  Lines         125      125           
  Branches       15       15           
=======================================
  Hits           94       94           
  Misses         16       16           
  Partials       15       15           
Flag Coverage Δ
unittests 75.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2472c3b...45f9769. Read the comment docs.

Copy link
Collaborator

@rluvaton rluvaton left a comment

Choose a reason for hiding this comment

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

great addition! thanks

package.json Outdated
@@ -18,7 +18,8 @@
"copy-templates": "rsync -av --exclude '*node_modules*' ./src/code-templates/ ./.dist/src/code-templates",
"build:watch": "tsc --watch",
"start:cli": "node ./.dist/bin/cli.js interactive",
"publish:build": "npm run build && npm publish ./.dist --access public"
"publish:build": "npm run build && npm publish ./.dist --access public",
"prepare": "cd .. && husky install front/.husky"
Copy link
Collaborator

@rluvaton rluvaton Jul 15, 2022

Choose a reason for hiding this comment

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

Hey, why do you go one folder back and what is the front folder? I don't see this folder 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rluvaton
Thank you for pointing that out :)
In the CI process, npm ci completed successfully:
image

but when the tests were run, the process failed:
image

I followed that issue solutions here but it still fails.
Any idea what else can cause that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I know how to fix this, I'll create a PR, we shouldn't only publish the dist folder

Copy link
Collaborator

Choose a reason for hiding this comment

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

I won't be able to create the PR at the moment so maybe copy the husky script in build for now until I fix this issue

Copy link
Contributor

Choose a reason for hiding this comment

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

@rluvaton Can you share your thoughts: What is the failure reason, what would you fix?

@idobetesh Does it fail locally or only in CI? Should indeed install huskey in CI?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you share your thoughts: What is the failure reason, and what would you fix?

the failure reason is that the .git folder is missing in the .dist folder, husky doesn't think to go one folder up as the .dist folder contains the package.json file

Does it fail locally or only in CI

this issue happen both on local and on the CI

Should indeed install huskey in CI?

There are valid use cases adding husky to the CI:
e.g. part of publishing a package we could generate a CHANGELOG file and commit + push it

Copy link
Contributor

Choose a reason for hiding this comment

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

About the failure - Publishing to root won't necessary solve it, users who generate code might not have (yet) a git repo. I suggest that the optional solution is thoughtful Husky install command that fails if no Git exists. Can you find one like this please @rluvaton ? Other ideas?

About the need in CI - The idea of Husky is to prevent human mistakes, I don't see why a robot (CI) that publishes docs need another (robot) to check that it didn't forget to run tests

Copy link
Contributor

@goldbergyoni goldbergyoni left a comment

Choose a reason for hiding this comment

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

@idobetesh Awesome contribution, this can trigger early failures for the good

Left one significant comment + CI is failing, we can sort this out with @rluvaton

Let's do it 💪

@@ -1 +1,15 @@
{}
{
"arrowParens": "avoid",
Copy link
Contributor

Choose a reason for hiding this comment

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

The main selling point of Prettier is "Put aside your personal opinion, avoid team arguments, just use the industry standards that we've set". Should we really adjust its defaults?

package.json Outdated
@@ -18,7 +18,8 @@
"copy-templates": "rsync -av --exclude '*node_modules*' ./src/code-templates/ ./.dist/src/code-templates",
"build:watch": "tsc --watch",
"start:cli": "node ./.dist/bin/cli.js interactive",
"publish:build": "npm run build && npm publish ./.dist --access public"
"publish:build": "npm run build && npm publish ./.dist --access public",
"prepare": "cd .. && husky install front/.husky"
Copy link
Contributor

Choose a reason for hiding this comment

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

@rluvaton Can you share your thoughts: What is the failure reason, what would you fix?

@idobetesh Does it fail locally or only in CI? Should indeed install huskey in CI?

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.

Prevent commits that violates quality standards using git hooks (Husky)
3 participants