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

In PR's, exclusively run the designated service tests e.g. [cran discord] #1111

Merged
merged 4 commits into from
Oct 2, 2017
Merged

In PR's, exclusively run the designated service tests e.g. [cran discord] #1111

merged 4 commits into from
Oct 2, 2017

Conversation

paulmelnikow
Copy link
Member

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:

  • [Travis] Fix timeout issues
  • [Travis Sonar] Support user token authentication
  • [CRAN CPAN CTAN] Add test coverage

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 and describe.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 use request or node-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.

@paulmelnikow paulmelnikow added bug Bugs in badges and the frontend developer-experience Dev tooling, test framework, and CI labels Sep 28, 2017
@paulmelnikow paulmelnikow changed the title In PR's, run exclusively the designated service tests In PR's, run exclusively the designated service tests e.g. [cran discord] Sep 28, 2017
@paulmelnikow
Copy link
Member Author

I added [cran discord] to the title to demonstrate.

@paulmelnikow paulmelnikow changed the title In PR's, run exclusively the designated service tests e.g. [cran discord] In PR's, exclusively run the designated service tests e.g. [cran discord] Sep 28, 2017
Copy link
Member

@Daniel15 Daniel15 left a 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.
Copy link
Member

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.

@paulmelnikow
Copy link
Member Author

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!

@paulmelnikow paulmelnikow merged commit 0068f31 into badges:master Oct 2, 2017
@paulmelnikow paulmelnikow deleted the exclusive-service-tests branch October 2, 2017 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs in badges and the frontend developer-experience Dev tooling, test framework, and CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants