-
Notifications
You must be signed in to change notification settings - Fork 4
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
Run qunit tests as a pre-commit hook #90
Comments
I committed a first draft for a script that can be used to automatically run unit tests as a precommit hook. Testing the timing to see if it is fast enough to be used for every commit:
|
If we move forward with this, here is the commit hook file that we could use. If linting fails, it doesn't run unit tests:
|
@pixelzoom can you please take a look and recommend whether we should adopt this qunit test phase for phet-info/git-template-dir/hooks/pre-commit ? |
How long does qunit-main.js take to complete? If it's significantly longer than lint-main.js, then perhaps it should be done in pre-push instead of pre-commit. |
I reported timing in #90 (comment) |
I wasn't clear on whether the timing you reported in #90 (comment) was for qunit-main.js or the entire pre-commit hook (lint-main.js + qunit-main.js). Assume that the timing is for the pre-commit hook.... I guess I don't mind waiting up to 1 second on each commit. But you might want to run this past other developers. If there's push back, then moving qunit-main.js to pre-push would likely accomplish the same goal. |
Doing this in a git hook raises another issue... Is everyone using git hooks? (I suspect not.) Should they be? (I think so.) |
The timing I reported is for the qunit tests only. @pixelzoom do you want to bring this to developer meeting? |
I missed |
Have you experimented with pre-push hooks using the Webstorm push interface? Does it respect the hooks and behave accordingly? |
I have not experimented with WebStorm + pre-push hook. I didn't find anything relevant in a Google search for "IntelliJ pre-push hook". |
Having a hardcoded slash after the localTestingURL was causing bugs for me on Windows http-server, and this was not how we used localTestingURL when generating PhET-iO API files. I removed that hard coded slash, and added support for dynamically adding it if it isn't provided from the client's build-local. I also found it very hard to debug this, so I added some error logging before process.exit( 1 ) calls. I'm not sure if the @samreid please review my changes. |
Looks good, thanks! Also, I realized we can use the same strategy we proposed for API file generation, to have node serve the files to puppeteer instead of relying on each developer's localhost. |
Discussed on 5/21/20 - Went over the PSA and all say its OK to remove lint-main.js. |
lint-main.js has been deleted. |
This is super cool! I tried a commit that should break a unit test and the commit failed. Thanks! |
unit tests in phet-io-wrappers are designed to take a sim as a query parameter. This doesn't seem suitable for committing to |
Another way to address this would be to have node serve the files to puppeteer instead of relying on the developer localhost. We implemented this for https://github.com/phetsims/phet-io/issues/1664 and the same should be possible here. I'll open a side issue for that and close this one. |
In phetsims/chipper#921 we streamlined the usage of linting as a pre-commit hook, and it has been working extremely well. I recommend we also add unit tests as a precommit hook.
This was inspired by conversations in https://github.com/phetsims/phet-io/issues/1648 about how we can automatically test phet-io specifications.
The text was updated successfully, but these errors were encountered: