These instructions are to add the ability to block the merge to master of any branch on an open PR that causes a unit test to fail. We do this through Github Actions.
Create a branch for pushing the action to the remote repo
Create a folder .github/workflows in the hmda-platform root directory
Add a yaml file to that workflows folder. It will tell Github to run unit tests when you make a PR. You can call it whatever you want, we'll call ours unit-tests.yml
Add the following lines to this yaml file that tells GH to set up sbt and run the unit tests:
5. Add the yaml file, commit the change and push to the remote repo. Now the workflow should be on Github
6. On Github, go to Settings -> Branches, then click Add Branch Rule. Type in "master" as the branch name and click the box that says "Require status checks to pass before merging". Search up the status check "tests" that you just added to github and add that.
That's it! Now when you make a PR, if it breaks any of the unit tests it will not allow you to merge the PR to master, as seen below
When you fix the code that breaks the test on your branch and push your changes, Github will automatically run the tests action so that you don't have to worry about creating a new PR
Branch Rule
<img width="1512" alt="branch_rule" src="https://github.com/cfpb/hmda-platform/assets/41237993/9cbbdc71-1d4e-4657-a14c-6c016b128398">
Failing test:
<img width="1512" alt="failing_test" src="https://github.com/cfpb/hmda-platform/assets/41237993/27ab4157-f39f-4ae2-a63a-abbfabd7e0ea">
Succeeding test:
<img width="1509" alt="succeeding_test" src="https://github.com/cfpb/hmda-platform/assets/41237993/bf0f4326-c7ba-4a5b-bb08-c50919983d08">
Github Actions PR Status Check Instructions
These instructions are to add the ability to block the merge to master of any branch on an open PR that causes a unit test to fail. We do this through Github Actions.
on: pull_request: branches:
jobs: tests: runs-on: ubuntu-latest