GitHub Guide
Welcome to the RESN GitHub Guide! This will aim to describe how to contribute to RESN’s Tech Projects, including both submitting code and reviewing code.
Submitting Code
Summary
- Any code in the main branch is stable and designed to be deployable.
- Whenever you want to make any changes, you should create a temporary branch.
- Once you are happy with your changes in the branch, submit a pull request into main.
- After dealing with any conflicts, this code can be reviewed and then merged.
- Delete the temporary branch, and branch off main to start work on the next change.
Some Tips
- Try to use a descriptive name for temporary branches (e.g. refactor-authentication).
- Create branches for smaller tasks rather than an entire large project (“commit early and commit often”).
Workflow
Pull Request Size
- A good convention is to keep the amount of code changed to <200 lines, with a hard limit of <400 lines.
- Anything above this becomes much more difficult for the reviewer, and the reviewer is likely to “skim” without thoroughly checking.
Reviewing Code
Summary
- Everyone should participate in the code review process as it helps the team learn from each other.
- However, if you go to review the PR and don’t understand what is going on in the code, you should not accept the PR because you “trust” it to work, but rather someone else should review the pull request.
Shortcuts
- Have the PR changes been described in sufficient detail?
- Have <400 lines of code been changed?
- Have correct file/folder conventions been followed?
- Is the code readable? Could someone new to RESN follow what is going on?
- The Code Review Pyramid
Resources
- Understanding the GitHub flow
- GitHub Team Onboarding Guide
- Git & GitHub Tutorial for Beginners #11 - Collaborating on GitHub
- Branching and Merging
- The Perfect Code Review Process. The Code Review Process is an import… | by Robert Cooper
- Optimal pull request size
- Proof your thousand-line pull requests result in more bugs
- The unwritten guide to pull requests - Work Life by Atlassian