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

Enable tests to run without a GitHub personal access token #87

Merged
merged 6 commits into from
Jul 20, 2020

Conversation

johnboyes
Copy link
Contributor

@johnboyes johnboyes commented Jul 16, 2020

  • Document how to contribute to the project:
    • how to run the tests

This ensures that if/when we have a need to store test data permanently
in the `testdata` directory (e.g. for mocks), the `testdata` directory
won't be inadvertently deleted.
@johnboyes johnboyes added the major Semantic versioning: new functionality that is not backwards compatible label Jul 16, 2020
@johnboyes johnboyes force-pushed the mock-github-test branch 15 times, most recently from a933e8c to 6da5d4d Compare July 16, 2020 13:23
This means that we no longer need to provide a GitHub `INPUT_REPO_TOKEN`
environment variable when running the tests (fixes #85).

The tests now use Hoverfly[1] by default, which proxies the calls to the
GitHub API and returns simulated responses[2] instead.
Also used Hoverfly to capture[3] these simulated responses.

The tests can also be run with an -integration flag, which means they
will make calls to the real GitHub API, requring a GitHub
`INPUT_REPO_TOKEN` environment variable to have been set.

Steps to install Hoverfly locally (you must do this on your local
machine before you can run the tests):

1. Install Hoverfly[4]
2. Download the Hoverfly default cert[5]
3. Add and trust the Hoverfly default cert[6] (how to add and trust
   a cert)[7]

[1] https://docs.hoverfly.io/
[2] https://docs.hoverfly.io/en/latest/pages/keyconcepts/simulations/simulations.html
[3] https://docs.hoverfly.io/en/latest/pages/keyconcepts/modes/capture.html
[4] https://docs.hoverfly.io/en/latest/pages/introduction/downloadinstallation.html
[5] https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem
[6] https://docs.hoverfly.io/en/latest/pages/tutorials/advanced/configuressl/configuressl.html
[7] https://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html
The original captured GitHub API responses were gzip encoded, which made
them unreadable (without manually decoding them).

There is a feature request to have Hoverfly to do this translation
automatically when exporting captured simulations, but it is not
available yet[1].

So this commit has manually placed the decoded JSON in the simulated
responses.

[1] SpectoLabs/hoverfly#787
Update the GitHub Action to run the tests in both default mode (with
virtualised service calls), and integration mode (with calls to the real
GitHub API).
Also added and trusted the Hoverfly default certificate[1], so that
Hoverfly https calls work

And also set the tests to run in verbose mode in Visual Studio Code, so
we get more informative output when running them.

[1] https://raw.githubusercontent.com/SpectoLabs/hoverfly/master/core/cert.pem

https://hoverfly.readthedocs.io/
@johnboyes johnboyes force-pushed the mock-github-test branch 9 times, most recently from 02e2e6b to 31684d1 Compare July 20, 2020 06:49
@johnboyes johnboyes force-pushed the mock-github-test branch 7 times, most recently from c6c85a8 to 7b0cb9d Compare July 20, 2020 07:42
@johnboyes johnboyes merged commit 79000ff into master Jul 20, 2020
@johnboyes johnboyes deleted the mock-github-test branch July 20, 2020 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major Semantic versioning: new functionality that is not backwards compatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant