/
Github Repositories

Github Repositories

Welcome puritan. Where version control is concerned we treat sorcery like the inhabitants of Salem. Only repositories with the upmost level of seriousness, transparency and rigor are allowed.

Creating a Repository

Not rocket science but bear in mind the following checklist:

  • By default Github makes the person who has created the repository the admin. However it is better to set the systems team (or in the future groups within systems) as admin.

  • Ensure file contains the registry .gitignore template.

  • Consider if repo should be open source.

  • Add static testing with tox as a minimum but unit tests should be included whenever possible. As a general rule this is just a case of copy pasting a tox.ini file from elsewhere.

    • Code formatting - Black, ruff

    • Linter/Typechecker - mypy, pyright as appropriate

    • Security - bandit

    • Unit testing - pytest

  • Enable registry ssh secret. This is required for github actions to use any of the private repos.

  • If it’s a package consider publishing it to pypi, if it’s a service consider dockerising it.

  • We use python poetry as standard for python dependency management

Updating a Repository

Commits should, as much as possible, contain changes that relate to a specific feature or ticket. This is to allow them to be reversed later if needed. The branch should be named after the Jira ticket or Epic where ever possible.

The commit message should describe what has changed. If the change relates to a JIRA ticket it should be prefixed with the ticket identifier.

git commit -m "RR-123 I changed function val_banana to add a check for apples"

commit messages should clearly describe changes and the version of the repository should be amended accordingly.

Resolving Conflicts

Urghh we don’t do conflict unless it is putting cavaliers in their place with walls of musket fire.

Maintaining a Repository

Using Multiple Deploy Keys

One way to pull code from Git to a server is to add a public SSH key as a Deploy Key in the Repo Settings. There is a problem though that each Deploy Key can only be used on one GitHub repo which requires multiple Keys. You then have the problem of telling Git which key to use with which repo.

  1. Generate an SSH keypair per repo as usual (albeit with a unique filename) and add it to the repo as a Deploy Key.

  2. Create a .ssh/config file which looks similar to the following -

Host github.com Hostname github.com IdentityFile=/home/ukrdc/.ssh/bamboo Host github.com-data_extract Hostname github.com IdentityFile=/home/ukrdc/.ssh/data_extract_key Host github.com-ukrdc_database Hostname github.com IdentityFile=/home/ukrdc/.ssh/ukrdc_database_key Host github.com-ukrr_quarterly_extract Hostname github.com IdentityFile=/home/ukrdc/.ssh/ukrr_quarterly_extract_key

Useful reference Articles/Sites