A GitHub bot that drops a comment into the PR about what to test when specific files change. It is done by providing source file to test-suite mapping, and the test-suite files itself.
By default, this bot will look into wordpress-mobile/test-cases repo for test cases and file mapping.
It is possible to override default configuration by adding a .github/test-case-reminder.json
into a repository where this bot is installed. Config accepts 3 parameters:
tests_repo
- Repository with test suites andmapping.json
tests_dir
- Path to test-suites directorymapping_file
- Path tomapping.json
filecomment_footer
- Markdown-formatted text that will be added after list of test cases. Useful for suggestions on how to improve/extend existing test cases
Example config:
{
"tests_repo": "brbrr/jetpack",
"tests_dir": "docs/regression-checklist/test-suites/",
"mapping_file": "docs/regression-checklist/mapping.json",
"comment_footer": "Text explaining how to extend and improve existing test suites"
}
To run the code, make sure you have Bundler installed; then enter bundle install
on the command line.
- Create a copy of the
.env-example
file called.env
. - Create a test app with the following permissions: "Read access to code", "Read access to metadata", "Read and write access to pull requests"
- Add your GitHub App's private key, app ID, and webhook secret to the
.env
file.
- Run
bundle exec ruby server.rb
on the command line. - View the default Sinatra app at
localhost:3000
.
This guide will walk through the steps needed to configure a GitHub App and run it on a server.
After completing the necessary steps in the guide you can use this command in this directory to run the smee client(replacing https://smee.io/4OcZnobezZzAyaw
with your own domain):
smee --url https://smee.io/4OcZnobezZzAyaw --path /event_handler --port 3000
If you want server to reload automatically as you save the file you can start the server as below instead of using ruby server.rb
:
bundle exec rerun 'ruby server.rb'
Unit tests live in unittest.rb
If you want to test potential changes to mapping.json file you can first apply the changes to test_mapping.json
in this repo and test in your local as explained below.
- Checkout this repo
- Change
test_mapping.json
- Change
unittests.rb
this line with the filenames you want to test with. - Change assertions accordingly
Run below command to run unittests:
ruby unittests.rb