- Bittensor Development Workflow
Bittensor's codebase consists of two main branches: master and staging.
master
- This is Bittensor's live production branch, which should only be updated by the core development team. This branch is protected, so refrain from pushing or merging into it unless authorized.
staging
- This branch is continuously updated and is where you propose and merge changes. It's essentially Bittensor's active development branch.
- Branch off from:
staging
- Merge back into:
staging
- Naming convention:
feature/<ticket>/<descriptive-sentence>
Feature branches are used to develop new features for upcoming or future releases. They exist as long as the feature is in development, but will eventually be merged into staging
or discarded. Always delete your feature branch after merging to avoid unnecessary clutter.
- Branch off from:
staging
- Merge back into:
staging
and thenmaster
- Naming convention:
release/<version>/<descriptive-message>/<creator's-name>
Release branches support the preparation of a new production release, allowing for minor bug fixes and preparation of metadata (version number, configuration, etc). All new features should be merged into staging
and wait for the next big release.
General workflow:
- Branch off from:
master
orstaging
- Merge back into:
staging
thenmaster
- Naming convention:
hotfix/<version>/<descriptive-message>/<creator's-name>
Hotfix branches are meant for quick fixes in the production environment. When a critical bug in a production version must be resolved immediately, a hotfix branch is created.
- Branch from the staging branch.
- Command:
git checkout -b feature/my-feature staging
- Command:
Rebase frequently with the updated staging branch so you do not face big conflicts before submitting your pull request. Remember, syncing your changes with other developers could also help you avoid big conflicts.
In other words, integrate your changes into a branch that will be tested and prepared for release.
- Switch branch to staging:
git checkout staging
- Merging feature branch into staging:
git merge --no-ff feature/my-feature
- Pushing changes to staging:
git push origin staging
- Delete feature branch:
git branch -d feature/my-feature
(alternatively, this can be navigated on the GitHub web UI)
This operation is done by Github when merging a PR.
So, what you have to keep in mind is:
- Open the PR against the
staging
branch. - After merging a PR you should delete your feature branch. This will be strictly enforced.
- Create branch from staging:
git checkout -b release/3.4.0/descriptive-message/creator's_name staging
- Updating version with major or minor:
./scripts/update_version.sh major|minor
- Commit file changes with new version:
git commit -a -m "Updated version to 3.4.0"
This involves releasing stable code and generating a new version for bittensor.
- Switch branch to master:
git checkout master
- Merge release branch into master:
git merge --no-ff release/3.4.0/optional-descriptive-message
- Tag changeset:
git tag -a v3.4.0 -m "Releasing v3.4.0: some comment about it"
- Push changes to master:
git push origin master
- Push tags to origin:
git push origin --tags
To keep the changes made in the release branch, we need to merge those back into staging
:
- Switch branch to staging:
git checkout staging
. - Merging release branch into staging:
git merge --no-ff release/3.4.0/optional-descriptive-message
This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit.
- Create branch from master:
git checkout -b hotfix/3.3.4/descriptive-message/creator's-name master
- Update patch version:
./scripts/update_version.sh patch
- Commit file changes with new version:
git commit -a -m "Updated version to 3.3.4"
- Fix the bug and commit the fix:
git commit -m "Fixed critical production issue X"
Finishing a hotfix branch involves merging the bugfix into both master
and staging
.
- Switch branch to master:
git checkout master
- Merge hotfix into master:
git merge --no-ff hotfix/3.3.4/optional-descriptive-message
- Tag new version:
git tag -a v3.3.4 -m "Releasing v3.3.4: descriptive comment about the hotfix"
- Push changes to master:
git push origin master
- Push tags to origin:
git push origin --tags
- Switch branch to staging:
git checkout staging
- Merge hotfix into staging:
git merge --no-ff hotfix/3.3.4/descriptive-message/creator's-name
- Push changes to origin/staging:
git push origin staging
- Delete hotfix branch:
git branch -d hotfix/3.3.4/optional-descriptive-message
The one exception to the rule here is that, when a release branch currently exists, the hotfix changes need to be merged into that release branch, instead of staging
. Back-merging the bugfix into the release branch will eventually result in the bugfix being merged into develop
too, when the release branch is finished. (If work in develop immediately requires this bugfix and cannot wait for the release branch to be finished, you may safely merge the bugfix into develop now already as well.)
Finally, we remove the temporary branch:
git branch -d hotfix/3.3.4/optional-descriptive-message
Continuous Integration (CI) is a software development practice where members of a team integrate their work frequently. Each integration is verified by an automated build and test process to detect integration errors as quickly as possible.
Continuous Deployment (CD) is a software engineering approach in which software functionalities are delivered frequently through automated deployments.
- CircleCI job: Create jobs in CircleCI to automate the merging of staging into master and release version (needed to release code) and building and testing Bittensor (needed to merge PRs).
Semantic versioning helps keep track of the different versions of the software. When code is merged into master, generate a new version.
Release notes provide documentation for each version released to the users, highlighting the new features, improvements, and bug fixes. When merged into master, generate GitHub release and release notes.
- Determine if master and staging are different
- Determine what is in staging that is not merged yet
- Document not released developments
- When merged into staging, generate information about what's merged into staging but not released.
- When merged into master, generate GitHub release and release notes.
- CircleCI jobs
- Merge staging into master and release version (needed to release code)
- Build and Test Bittensor (needed to merge PRs)
This document can be improved as the Bittensor project continues to develop and change.