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

tests: use husky to run tests before commits and pushes #11111

Merged
merged 8 commits into from Apr 2, 2018
Merged

tests: use husky to run tests before commits and pushes #11111

merged 8 commits into from Apr 2, 2018

Conversation

DanielRuf
Copy link
Contributor

@DanielRuf DanielRuf commented Mar 30, 2018

We should force to run npm test on each commit / push.

Should we use precommit and prepush or just one of both?

Closes #11042

The rest of it will be probably covered in future code quality related PRs for all devs.

@DanielRuf
Copy link
Contributor Author

PS: I did not add the changed package-lock.json file but we may have to update it.

Also see #11046

Copy link
Contributor

@ncoden ncoden left a comment

Choose a reason for hiding this comment

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

That's nice 🐶

Because a common rule in Git is that the code should always run, I guess we can use precommit. And prepush does not harm :).

@ncoden
Copy link
Contributor

ncoden commented Mar 30, 2018

I seen #11046. I think I'll take care of adding it after manually upgraded all our dependencies to prepare v6.5. There's no benefit in adding it if we're not already up-to-date.

@ncoden
Copy link
Contributor

ncoden commented Mar 31, 2018

I just noticed this PR is number #11111 😄

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

chore: add message for about Husky at precommit & prepush

screen shot 2018-04-01 at 18 25 14

@DanielRuf
Copy link
Contributor Author

This will probably not work on most Windows machines @ncoden, why not ouput it directly with Node.js?

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

Ah, yeah...

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

Actually, what would not run on Windows ? The whole NPM environement with npm scripts is based on bash, and Windows users are invited to set by themselve the program to use for commands.

Also, using JS scripts does not resolve the compatibility issue as we have to run npm test at the middle on the script, which is far more complicated to do in JS than in Bash..

@DanielRuf
Copy link
Contributor Author

DanielRuf commented Apr 1, 2018

bash can not be used in cmd and git and npm are globally available on the path but bash isn't, just in the extra environment.

Will test later on my machine but it will not run afaik.

@DanielRuf
Copy link
Contributor Author

$ npm run precommit

> foundation-sites@6.4.3 precommit C:\Users\Daniel\GITHUB\foundation-sites
> ./script/husky-precommit

Der Befehl "." ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! foundation-sites@6.4.3 precommit: `./script/husky-precommit`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the foundation-sites@6.4.3 precommit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Daniel\AppData\Roaming\npm-cache\_logs\2018-04-01T19_34_49_592Z-debug.log

I'll provide a working solution.

@DanielRuf
Copy link
Contributor Author

There you go =)

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

Thanks 👍

@DanielRuf
Copy link
Contributor Author

Oops, small copy paste error =/
Forgot to rename it in package.json.

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

Fixed :)

@DanielRuf
Copy link
Contributor Author

Actually had it prepared here but not commited anymore.

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

Also, the Sass tests output is not colored anymore. Do you have an idea of what is causing this ?

@DanielRuf
Copy link
Contributor Author

DanielRuf commented Apr 1, 2018

I guess this is because it is running in another context now and the color support is disabled there. I'm checking if we can use another solution here.

@DanielRuf
Copy link
Contributor Author

Should be colored again now.

@DanielRuf
Copy link
Contributor Author

Forcing the colors mode now by default. For sass-lint we might move to stylelint somewhere in the future.

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

94b956b fix: always use color mode
02d08db Merge branch 'tests/use-husky' of github.com:danielruf/foundation-sit…
202576f fix: always use color mode

Rebase instead of merging when your commits are not pushed yet. git pull [...] --rebase

@DanielRuf
Copy link
Contributor Author

I guesset I should set the setting to rebase by default here too.

Should I squash merge or rebase now and push force the last 3 commits as one?

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

360380d chore: remove code test output

Please always put the context in your commits. "chore: remove code test output in husky scripts" 😉

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

Should I squash merge or rebase now and push force the last 3 commits as one?

Since no reviews are based on these commits, yes please do shash them ;).

@ncoden
Copy link
Contributor

ncoden commented Apr 1, 2018

Side note: I really love this emoji 🐶

@ncoden
Copy link
Contributor

ncoden commented Apr 2, 2018

I guess it's good to go 👍

@ncoden ncoden merged commit 70aecf9 into foundation:develop Apr 2, 2018
@DanielRuf DanielRuf deleted the tests/use-husky branch April 2, 2018 15:26
ncoden added a commit to ncoden/foundation-sites that referenced this pull request Jun 16, 2018
…v6.5.0

d9d307e tests: use husky to run tests before commits and pushes
eaeebbf chore: add message for about Husky at precommit & prepush
c353e26 chore: use Node.js for precommit and prepush output
38f97aa chore: change prepush script to use the new script
adfbb8f chore: update package-lock.json
e6e8614 fix: fix wrong script for husky prepush hook
6fcaa0c fix: force color mode of mocha, remove code test output in husky scripts
073d0f2 fix: force color mode for gulp and husky scripts

Co-Authored-By: Nicolas Coden <nicolas@ncoden.fr>
Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants