Skip to content

Commit

Permalink
Improve development workflow documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
“quac88” authored and ifrit98 committed Jun 7, 2023
1 parent a4c9b6c commit cf1795f
Showing 1 changed file with 68 additions and 62 deletions.
130 changes: 68 additions & 62 deletions DEVELOPMENT_WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,105 @@

## Table of contents

1. [Main branches](#main-branches)
1. [Development model](#development-model)
1. [Supporting branches](#supporting-branches)
1. [Feature branches](#feature-branches)
1. [Release branches](#release-branches)
1. [Hotfix branches](#hotfix-branches)
1. [Git operations](#git-operations)
1. [Create a feature branch](#create-a-feature-branch)
1. [Merge feature branch into nobunaga](#merge-feature-branch-into-nobunaga)
1. [Create release branch](#create-release-branch)
1. [Finish a release branch](#finish-a-release-branch)
1. [Create a hotfix branch](#create-a-hotfix-branch)
1. [Finishing a hotfix branch](#finishing-a-hotfix-branch)
- [Development Workflow](#development-workflow)
- [Table of contents](#table-of-contents)
- [Main branches](#main-branches)
- [Development model](#development-model)
- [Feature branches](#feature-branches)
- [Release branches](#release-branches)
- [Hotfix branches](#hotfix-branches)
- [Git operations](#git-operations)
- [Create a feature branch](#create-a-feature-branch)
- [Merge feature branch into staging](#merge-feature-branch-into-staging)
- [Create release branch](#create-release-branch)
- [Finish a release branch](#finish-a-release-branch)
- [Create the hotfix branch](#create-the-hotfix-branch)
- [Finishing a hotfix branch](#finishing-a-hotfix-branch)
- [TODO](#todo)

## Main branches

The repo holds two main branches with an infinite lifetime:
- master
- nobunaga
Bittensor is composed of TWO main branches, **master** and **staging**

We consider `origin/master` to be the main branch where the source code of HEAD always reflects a **__production-ready__** state.
**master**
- master Bittensor's live production branch. This branch should only be touched and merged into by the core develpment team. This branch is protected, but you should make no attempt to push or merge into it reguardless.

We consider `origin/nobunaga` to be the main branch where the source code of HEAD always reflects a state with the **__latest delivered development__** changes for the next release. Some would call this the `"integration branch"`. This is where any automatic nightly builds would be built from.
**staging**

## Development model

### Supporting branches
- staging is Bittensor's development branch. This branch is being continuously updated and merged into. This is the branch where you will propose and merge changes.

Each of these branches have a specific purpose and are bound to strict rules as to which branches may be their originating branch and which branches must be their merge targets. We will walk through them in a minute
## Development model

#### Feature branches

<<<<<<< HEAD
- May branch off from: `nobunaga`
- Must merge back into: `nobunaga`
- Branch naming convention:
- Anything except master, nobunaga, finney, release/* or hotfix/*
- Suggested: `feature/<ticket>/<descriptive-sentence>`
=======
When implementing new features, hotfixes, bugfixes, or upgrades, you must adhere to a STRICT naming and merging convention.

**Branch naming and merging convention:**
>>>>>>> Improve development workflow documentation

Feature branches are used to develop new features for the upcoming or a distant future release. When starting development of a feature, the target release in which this feature will be incorporated may well be unknown at that point.

The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged back into `nobunaga` (to definitely add the new feature to the upcoming release) or discarded (in case of a disappointing experiment).
The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged into `staging` (to definitely add the new feature to the upcoming release) or discarded (in case of a disappointing experiment).

Generally, you should try to minimize the lifespan of feature branches. As soon as you merge a feature into 'staging', you must immidiately delete the feature branch. This will be strictly enforced. Excess branches creates tech debt and confusion between development teams and parties.

#### Release branches

- May branch off from: `nobunaga`
- Must merge back into: `nobunaga` and `master`
- MUST branch off from: `staging`
- MUST merge back into: `staging` then into: `master`
- Branch naming convention:
- Suggested format `release/3.4.0/optional-descriptive-message`
- REQUIRED format `release/3.4.0/descriptive-message/creator's-name`

Release branches support preparation of a new production release. Furthermore, they allow for minor bug fixes and preparing meta-data for a release (e.g.: version number, configuration, etc.). By doing all of this work on a release branch, the `nobunaga` branch is cleared to receive features for the next big release.
Release branches support preparation of a new production release. Furthermore, they allow for minor bug fixes and preparing meta-data for a release (e.g.: version number, configuration, etc.). By doing all of this work on a release branch, the `staging` branch is cleared to receive features for the next big release.

This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch, rather than on the `nobunaga` branch. Adding large new features here is strictly prohibited. They must be merged into `nobunaga`, and therefore, wait for the next big release.
This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch, rather than on the `staging` branch. Adding large new features here is strictly prohibited. They must be merged into `staging`, and therefore, wait for the next big release.

#### Hotfix branches

- May branch off from: `master`
- Must merge back into: `nobunaga` and `master`
- MUST branch off from: `master` or `staging`
- MUST merge back into: `staging` then into: `master`
- Branch naming convention:
- Suggested format: `hotfix/3.3.4/optional-descriptive-message`
- REQUIRED format: `hotfix/3.3.4/descriptive-message/creator's-name`

Hotfix branches are very much like release branches in that they are also meant to prepare for a new production release, albeit unplanned. They arise from the necessity to act immediately upon an undesired state of a live production version. When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the master branch that marks the production version.

The essence is that work of team members, on the `nobunaga` branch, can continue, while another person is preparing a quick production fix.
The essence is that work of team members, on the `staging` branch, can continue, while another person is preparing a quick production fix.

### Git operations

#### Create a feature branch

1. Branch from the **nobunaga** branch.
1. Command: `git checkout -b feature/my-feature nobunaga`
1. Branch from the **staging** branch.
1. Command: `git checkout -b feature/my-feature staging`

> Try to rebase frequently with the updated nobunaga 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.
> 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.
#### Merge feature branch into nobunaga
#### Merge feature branch into staging

In other words, integrate your changes into a branch that will be tested and prepared for release.

- Switch branch to nobunaga: `git checkout nobunaga`
- Merging feature branch into nobunaga: `git merge --no-ff feature/my-feature`
- Pushing changes to nobunaga: `git push origin nobunaga`
- Delete feature branch: `git branch -d feature/my-feature`
- 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)

This operation is done by Github when merging a PR.

So, what you have to keep in mind is:
- Open the PR against the `nobunaga` branch.
- After merging a PR you just have to delete your feature branch.
- Open the PR against the `staging` branch.
- After merging a PR you MUST delete your feature branch. This is strictly inforced.

#### Create release branch

- Create branch from nobunaga: `git checkout -b release/3.4.0/optional-descriptive-message nobunaga`
- 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"`

Expand All @@ -106,20 +114,20 @@ In other words, releasing stable code and generating a new version for bittensor
- Pushing changes to master: `git push origin master`
- Pushing tags to origin: `git push origin --tags`

To keep the changes made in the __release__ branch, we need to merge those back into `nobunaga`:
To keep the changes made in the __release__ branch, we need to merge those back into `staging`:

- Switch branch to nobunaga: `git checkout nobunaga`.
- Merging release branch into nobunaga: `git merge --no-ff release/3.4.0/optional-descriptive-message`
- 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.

After this the release branch may be removed, since we don’t need it anymore:

- `git branch -d release/3.4.0/optional-descriptive-message`
- `git branch -d release/3.4.0/descriptive-message/creator's-name`

#### Create the hotfix branch

- Create branch from master:`git checkout -b hotfix/3.3.4/optional-descriptive-message master`
- 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"`

Expand All @@ -128,37 +136,35 @@ Then, fix the bug and commit the fix in one or more separate commits:

#### Finishing a hotfix branch

When finished, the bugfix needs to be merged back into `master`, but also needs to be merged back into `nobunaga`, in order to safeguard that the bugfix is included in the next release as well. This is completely similar to how release branches are finished.
When finished, the bugfix needs to be merged back into `master`, but also needs to be merged back into `staging`, in order to safeguard that the bugfix is included in the next release as well. This is completely similar to how release branches are finished.

First, update master and tag the release.

- Switch branch to master: `git checkout master`
- Merge changes 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: some comment about the hotfix"`
- Tag new version: `git tag -a v3.3.4 -m "Releasing v3.3.4: descriptive comment about the hotfix"`
- Pushing changes to master: `git push origin master`
- Pushing tags to origin: `git push origin --tags`

Next, include the bugfix in `nobunaga`, too:
Next, include the bugfix in `staging`, too:

- Switch branch to nobunaga: `git checkout nobunaga`
- Merge changes into nobunaga: `git merge --no-ff hotfix/3.3.4/optional-descriptive-message`
- Pushing changes to origin/nobunaga: `git push origin nobunaga`
- Switch branch to staging: `git checkout staging`
- Merge changes into staging: `git merge --no-ff hotfix/3.3.4/descriptive-message/creator's-name`
- Pushing changes to origin/staging: `git push origin staging`

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** `nobunaga`. 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.)
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`

## TODO

- Changing the name of the develop branch from nobunaga to `integration`
- Because sometimes nobunaga are going to have a release branch.
- Knowing if master and nobunaga are different
- Knowing what is in nobunaga that is not merge yet
- Knowing if master and staging are different
- Knowing what is in staging that is not merge yet
- Document with not released developments
- When merged into nobunaga, generate the information exposing what's merged into nobunaga but not release.
- When merged into staging, generate the information exposing what's merged into staging but not release.
- When merged into master, generate github release and release notes.
- CircleCI job
- Merge nobunaga into master and release version (needed to release code)
- Build and Test bittensor (needed to merge PRs)
- Merge staging into master and release version (needed to release code)
- Build and Test Bittensor (needed to merge PRs)

0 comments on commit cf1795f

Please sign in to comment.