-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
In PR's, exclusively run the designated service tests e.g. [cran discord] #1111
In PR's, exclusively run the designated service tests e.g. [cran discord] #1111
Conversation
I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. However, the build failed. Is it related?
Error: 403 Forbidden
at Error (native)
at fetch.then.res (/home/travis/build/badges/shields/service-tests/runner/pull-request-services-cli.js:36:15)
at process._tickCallback (internal/process/next_tick.js:109:7)
// easier to reason about and much easier to debug on a dev machine. | ||
// 3. Getting "pipefail" to work cross platform with an npm script seems tricky. | ||
// Relying on npm scripts is safer. Using "pre" makes it impossible to run | ||
// the second step without the first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love these comments. Very useful.
The build failure is only tangentially related. This is only one part of solving #979. 403 Forbidden error is what happens when the test runner tries to fetch the PR metadata. Thanks for the review! |
The intended behavior of the bracketed [github], [bower], [discord] service names in the pull request title is to trigger the designated service tests. That way, affected services can be proven working during code review, without needing to run tests on a dev machine, nor running all the slow (and flaky) service tests.
Example pull request titles:
The observed behavior is that, whenever bracketed service names are provided, all of the service tests run.
This is due to a Mocha limitation, which is that exclusive tests (
it.only
anddescribe.only
) can only be applied synchronously. In other words, if we try to fetch the PR title and then add exclusive tests in the callback, all the tests will run anyway. This is true even when using_mocha --delay
, as we are, and is true whether I userequest
ornode-fetch
.Undoubtedly this could be fixed, though it's not worth it. The problem is obscure and therefore low priority for Mocha, which is quite backlogged.
And, there is an easy workaround, which is to generate the list of services to test in a separate process.
The pull request script test:services:pr is now split into two parts. First the :prepare script infers the pull request context, fetches the PR title, and writes the list of affected services to a file. Then the :run script reads the list of affected services and runs the appropriate tests.
In addition to sidestepping the Mocha bug, this setup makes it easier to reason about and debug these two steps of the test runner on a dev machine, and since I can't get pipefail to work – and want to be able to run the steps separately – I'm not using Node's built in
pre
scripts.Overall, separating these concerns this makes the test runner easier to reason about.