Github and automated tests
Whatever service you choose for automation, you will need to enable the "hooks" in your Github repositories so that the automated testing will happen. The goal is for automated tests to run every time a "pull request" is created. This way, if the pull request would have broken something, you will know in advance.
The procedure is the same for both the site repository and the data repository:
Initial pull-requests¶
First you will need to have created any pull request and merged it. You can skip this part if you have already created a pull request and merged it in both repositories.
- Go to the repository in GitHub.
- Go to any file in the repository, such as README.md, and click the pencil icon to edit it.
- Make any change to the file.
- Towards the bottom, select "Create a new branch for this commit and start a pull request."
- Beneath this, click "Propose changes".
- Click on the green "Create pull request" button.
- Wait a moment to see the message that says "Test PRs / test (pull_request) - in progress"
- Wait until you see "All checks have passed". This takes about 5 minutes.
- Click on the green "Merge pull request" button.
Perform the steps above for both the site repository and the data repository.
Add branch protection rules¶
Next you can add the "branch protection rule" to require these tests to pass:
- Go to the repository in GitHub.
- Under the repository name, click "Settings".
- In the left sidebar, click "Branches".
- Make sure the "default" branch is:
develop
- Under "Branch protection rules" click "Add rule"
- Under "Branch name pattern" enter
develop
- Check the box "Require status checks to pass before merging"
- In "Search for status checks in the last week for this repository" type "test" and select the "test" option.
The last step above may be different depending on your choice of automation service, but that is where you tell GitHub that some tests need to pass.
Perform the steps above for both the site repository and the data repository.
Results¶
Now that you have set up these branch protection rules, any time a pull-request is created, the "Merge" button will be disabled until the pull-requests passed all tests. This helps avoid the possibility of a breaking change making it onto your site.