Git¶
Git is way to organize your code and reason about historical changes that has happened to the codebase. Technically, its a "version control system" (vcs) tool. There are many vcs tools available, but we use Git and host all our repositories in GitHub.
General Process¶
- You checkout from main to your own branch. Your branch should be prefixed with your initials, for example
ms/sprint-fixes. - You regularly pull from source branch into your branch using
git pull origin main --no-rebase, resolve conflicts and commit it. - You can commit frequently to your branch and keep pushing to remote.
- In general practice present continuous tense for branch names and commit messages. Examples for branch names
ms/are fixes-iteration-1,ms/adds-wallet-featureetc. Examples for commit messages areadds wallet feature,fixes copy mistake in home page,introduces feature toggle to view transactions pageetc. - You add pull request to the
mainbranch and get it reviewed, implement feedback and get it merged. - All the PRs should be squash merged to keep the main line history clean.
- You checkout to main branch,
git pulland then branch out to your work branch. Repat steps #1
Github Workflows¶
Github workflows provide necessary hooks to ensure consistency of code repository through their workflows. Here are some of the important workflows we must follow
- Repository settings should ensure that
delete head branchesis checked. mainbranch should be added to protected branches and only PRs should be allowed to commit to main. If necessary uncheck admin overrides as well.- PRs setting should have only squash and merge option checked, rest of the options like rebase, merge commit should be un checked.
- Ensure that PRs have a PR template and a reviewer to your PR is assigned.
- Use github workflows to run lint checks, builds and tests, if they fail, the PR should not provide merge option.
- Use github workflows to automate important things on the PR like test coverage, failures, deploy previews urls etc as a bot comment.
- Use environments to setup different deployment targets and use workflow actions to run deployments via actions trigger to particular environments. Each environment can maintain their own set of variables.
- Connect github repository to slack channel and involve collaboration with team.
Leverage workflows as much as possible to automate day to routine tasks.