-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
249 additions
and
124 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,153 @@ | ||
************* | ||
Git Workflows | ||
************* | ||
************ | ||
Git Workflow | ||
************ | ||
|
||
Branches | ||
======== | ||
Background | ||
========== | ||
|
||
The development team employs a GitFlow workflow with personal branching. This means that code in the `main` branch should always be in a releasable state. Developers should maintain their own development branches and commit changes to a `release-x.y.z` branch. When it's time to release, a dedicated team member will merge the `release-x.y.z` branch with the `main` branch and tag it accordingly. | ||
Dysh uses the `OpenAstronomy model for its branching and release structure <https://packaging-guide.openastronomy.org/en/latest/releasing.html#releasing-from-branches>`_. In practice, this essentially means that we are using a standard "feature branch" workflow, where new features are added via Pull Requests based on ``main``. | ||
|
||
If you are an external collaborator, you will need to create Pull Requests from a fork of Dysh, but the instructions below should otherwise be fairly similar. | ||
|
||
Developers are welcome to manage their git workflow however they want, but using the `GitHub CLI <https://cli.github.com/>`_ or `GitHub Desktop <https://desktop.github.com/>`_ simplify many operations. | ||
|
||
How to Contribute | ||
================= | ||
|
||
|
||
There are two types of workflow: | ||
1. Contributing to a future release. This is the most common workflow | ||
2. Patching a previous release. This involves changes to a "release branch" -- changes will *not* go on `main` | ||
|
||
Below is a diagram demonstrating both of these workflows. They are explored in more depth farther down. | ||
|
||
.. mermaid:: | ||
|
||
%%{init: { 'theme': 'base' } }%% | ||
%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'showBranches': true, 'showCommitLabel':true,'mainBranchOrder': 10}} }%% | ||
|
||
gitGraph | ||
commit id: "1" | ||
commit id: "2" | ||
branch release-x.y.z order: 1 | ||
commit id: "3" | ||
branch personB-devel order: 3 | ||
branch personA-devel order: 2 | ||
commit id: "4" | ||
checkout personB-devel | ||
commit id: "5" | ||
commit id: "6" | ||
checkout personA-devel | ||
commit id: "7" | ||
commit id: "8" | ||
checkout release-x.y.z | ||
merge personA-devel id: "9" | ||
commit id: "10" | ||
checkout personB-devel | ||
merge release-x.y.z id: "11" | ||
commit id: "12" | ||
commit id: "13" | ||
checkout release-x.y.z | ||
merge personB-devel id: "14" | ||
|
||
commit id: "freeze 0.2" tag: "v0.3dev" | ||
branch v0.2 order: 11 | ||
|
||
checkout v0.2 | ||
commit id: "start v0.2 beta test" tag: "v0.2.0b1" | ||
|
||
branch v0.2.0b1_fix order: 14 | ||
commit id: "fix bugs from beta" | ||
checkout v0.2 | ||
merge v0.2.0b1_fix id: "Release v0.2.0rc1" tag: "v0.2.0rc1" | ||
commit id: "Release v0.2.0" tag: "v0.2.0" | ||
commit id: "Bug fix for v0.2" tag: "v0.2.1" | ||
checkout v0.2 | ||
|
||
checkout main | ||
branch feature_x order:3 | ||
commit id: "start feature x" | ||
commit id: "finish feature x" | ||
checkout main | ||
merge release-x.y.z id: "15" tag: "release-x.y.z" | ||
merge feature_x id: "freeze 0.3" tag: "v0.4dev" | ||
|
||
Releases | ||
======== | ||
branch v0.3 order:100 | ||
commit id: "start v0.3 beta test" tag: "v0.3.0b1" | ||
checkout main | ||
|
||
Release branches will be locked once work on the next release begins. | ||
branch feature_y order:1 | ||
checkout feature_y | ||
commit id:"implement feature y" | ||
checkout main | ||
|
||
Setting up your own development branch | ||
====================================== | ||
Contribute to ``main`` (Add to a Future Release) | ||
++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
In the directory you want to work in, set up the repo: | ||
|
||
`$ git clone git@github.com:GreenBankObservatory/dysh.git` | ||
Primary development is always done on a feature branch off of `main`. The only way for code to get into `main` is via a `Pull Request <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests>`_ on the `Dysh GitHub <https://github.com/GreenBankObservatory/dysh>`_. A Pull Request is essentially a group of commits with a common purpose, and it is associated with a discussion thread. It encapsulates both the code changes themselves, and the explanation of why they are being made, how they work, etc. | ||
|
||
`$ cd dysh` | ||
Here is the lifecycle of a simple Pull Request: | ||
|
||
`$ git checkout [branch-name]` | ||
.. code-block:: sh | ||
with the [branch-name] replaced by the current release or other branch. Currently, this is "release-0.2.0". Then setup your own development branch with your first name followed by "-devel": | ||
git checkout main | ||
git fetch origin main | ||
git checkout -b my-cool-new-feature | ||
# <make some code changes> | ||
git commit -am "Desc of changes" | ||
# <make some code changes> | ||
git commit -am "More changes" | ||
git push origin my-cool-new-feature | ||
`$ git checkout [name-devel]` | ||
At this point, the developer considers the work complete, and the Dysh GitHub has a new branch, ``my-cool-new-feature``, and the developer's repo will look like: | ||
|
||
Now make and activate a python virtual environment so your work doesn't impede or break other concurrent projects. Whenever you do some work, make sure you are in your own development branch. When you are ready to merge changes made by other developers into your own branch, | ||
.. mermaid:: | ||
|
||
`$ git checkout release-0.2.0` | ||
%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'showBranches': true, 'showCommitLabel':true}} }%% | ||
|
||
`$ git pull` | ||
gitGraph | ||
commit id:" " | ||
branch my-cool-new-feature | ||
checkout my-cool-new-feature | ||
commit id: "Desc of changes" | ||
commit id: "More changes" | ||
|
||
`$ git checkout [name-devel]` | ||
Now they can open a Pull Request in the Dysh repo on GitHub. | ||
|
||
`$ git merge release-0.2.0` | ||
At this point, a few things happen: | ||
|
||
When you are ready to commit changes, review what's been changed with | ||
1. GitHub CI kicks off, which runs code quality checks and unit tests | ||
2. Another developer will review your code contribution | ||
3. Discussion of the new feature will occur | ||
4. Eventually, the PR will be accepted or rejected | ||
- If it is accepted, it will be merged into ``main`` and be a part of the next release | ||
- If it is rejected, it will go nowhere | ||
|
||
`$ git status` | ||
|
||
and then add the intended files using | ||
If accepted, the Dysh repo will now look like: | ||
|
||
`$ git add [path/to/changed/file]` | ||
.. mermaid:: | ||
|
||
check `dysh/.gitignore` to make sure you are not adding ignored files (virtual environment data, `_build/`, etc.). Then commit and push with | ||
%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'showBranches': true, 'showCommitLabel':true}} }%% | ||
|
||
`$ git commit -m "[this is my commit message]"` | ||
gitGraph | ||
commit id:" " | ||
branch my-cool-new-feature | ||
checkout my-cool-new-feature | ||
commit id: "Desc of changes" | ||
commit id: "More changes" | ||
checkout main | ||
merge my-cool-new-feature | ||
|
||
`$ git push` | ||
|
||
The first time you run this, it will give a command about setting the origin upstream. Simply copy and run that command. Users of GitHub Desktop can also achieve all of these above steps using the app interface. Next, go to the `dysh GitHub page <https://github.com/GreenBankObservatory/dysh/>`_ and submit a pull request. | ||
|
||
|
||
Contribute to a Previous Release (Add to a release branch) | ||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
In this example, release ``v0.2.0`` has been released, and development has started on ``v0.3.0`` (on ``main``). Then, a bug is reported in ``v0.2.0``, necessitating a bug fix. | ||
|
||
|
||
.. mermaid:: | ||
|
||
%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'showBranches': true, 'showCommitLabel':true}} }%% | ||
|
||
gitGraph | ||
|
||
commit id: "freeze 0.2" tag: "v0.3dev" | ||
branch v0.2 | ||
|
||
checkout v0.2 | ||
|
||
checkout main | ||
commit id: " " | ||
checkout v0.2 | ||
|
||
commit id: "Release 0.2.0" tag: "v0.2.0" | ||
branch v0.2.0-bug-fix | ||
commit id: "fix bug" | ||
checkout v0.2 | ||
merge v0.2.0-bug-fix id: "Release v0.2.1" | ||
commit id: "Release 0.2.1" tag: "v0.2.1" | ||
|
||
checkout v0.2 | ||
|
||
checkout main | ||
commit id: " " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
************************************ | ||
Setting Up a Development Environment | ||
************************************ | ||
|
||
|
||
Pre-Requisites | ||
============== | ||
|
||
There are a few core things you will need to develop Dysh: | ||
|
||
1. A Linux computer (Mac and Windows should also work, but we don't have docs for those) | ||
2. Python (specifically you should be using the minimum-supported version of Python; see ``pyproject.toml``) | ||
3. `pre-commit <https://pre-commit.com/>`_: used to enforce code quality checks | ||
4. `Hatch <https://hatch.pypa.io/latest/install/#pipx>`_ (optional, technically) | ||
|
||
Python | ||
------ | ||
|
||
See site-specific instructions [TODO] for GBO, UMD, etc. instructions -- the necessary version of Python is probably already available somewhere. | ||
|
||
|
||
If you do not already have access to the minimum-supported version of Python, you will need to install it. This can be done manually via `the official site <https://www.python.org/downloads/>`_, but it is much easier to use pyenv. | ||
|
||
|
||
Once you can run ``python --version`` and see the correct version pop up, you are ready to move on. | ||
|
||
pre-commit | ||
---------- | ||
|
||
|
||
|
||
Dysh Development Environment | ||
============================ | ||
|
||
Start to finish, how do you initialize a Dysh development environment? | ||
|
||
|
||
Via Hatch | ||
--------- | ||
|
||
.. code-block:: sh | ||
git clone [email protected]:GreenBankObservatory/dysh.git | ||
cd dysh | ||
hatch shell # | ||
hatch run test # Prove that the tests can run and pass | ||
Manual Virtual Environment | ||
-------------------------- | ||
|
||
In some environments it makes more sense to manage your environments yourself. For example, at GBO we have a variety of hosts that all mount a common filesystem, but can have different OS versions. Here the standard "one env per project per user" breaks down, and it is better to manage things yourself. | ||
|
||
.. code-block:: sh | ||
git clone [email protected]:GreenBankObservatory/dysh.git | ||
cd dysh | ||
python3.9 -m venv /path/to/venv # Create your venv | ||
source /path/to/venv/bin/activate # Activate your venv | ||
pip install -e .[all] # Install dysh in edit mode, including all extra deps | ||
hatch run test # Use hatch to trigger pytest inside your manually-created venv | ||
Advanced Cases | ||
============== | ||
|
||
If you need to exactly replicate the Python dependencies of either: | ||
1. A given CI deployment | ||
2. A given Dysh deployment at GBO (or elsewhere) | ||
|
||
You will instead be relying on the lockfile (``requirements.txt``) to provide exact version pins of all of your dependencies. | ||
|
||
With the same version of Python as the environment you are trying to replicate, and with the same OS (or as similar as possible): | ||
|
||
.. code-block:: sh | ||
python3.9 -m venv /path/to/venv # Create your venv | ||
source /path/to/venv/bin/activate # Activate your venv | ||
pip install -r requirements.txt # Install from lockfile |
Oops, something went wrong.