Skip to content

Commit 34eaba7

Browse files
authored
add github workflow document for contributors (#327)
Signed-off-by: Karen Almog <[email protected]>
1 parent cffa7f5 commit 34eaba7

File tree

2 files changed

+158
-0
lines changed

2 files changed

+158
-0
lines changed
Loading

docs/contributors/github_workflow.md

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
![](contributor_workflow_github_diagram.png)
2+
3+
#### 1. Fork The Project
4+
1. Go to http://github.com/Mirantis/mke
5+
2. On the top, right-hand side, click on "fork" and select your username for the fork destination.
6+
7+
#### 2. Clone fork to local directory
8+
Per Go's [workspace instructions](https://golang.org/doc/gopath_code.html#ImportPaths), place mke's repository clone in your GOPATH, per the instructions below:
9+
10+
```
11+
1. export WORKDIR=$(go env GOPATH)/src/github.com/Mirantis
12+
2. mkdir -p $WORKDIR
13+
```
14+
If you already have a few development projects from github, the `github.com` directory will already exist.
15+
```
16+
export user={ your github's profile name }
17+
```
18+
19+
Clone the project
20+
```
21+
cd $WORKDIR
22+
23+
# create ${GOPATH}/Mirantis/mke with your forked repo
24+
git clone https://github.com/$user/mke.git
25+
```
26+
Configure the Upstream Remote
27+
```
28+
cd $WORKDIR/mke
29+
git remote add upstream [email protected]:Mirantis/mke.git
30+
31+
# Never push to upstream main
32+
git remote set-url --push upstream no_push
33+
34+
# Confirm that your remotes make sense:
35+
git remote -v
36+
```
37+
#### 3. Create a feature branch
38+
39+
First, make sure your local fork is up-to-date:
40+
```
41+
cd $WORKDIR/mke
42+
git fetch upstream
43+
git checkout main
44+
git rebase upstream/main
45+
```
46+
Create a feature branch:
47+
```
48+
git branch -b my_feature_branch
49+
```
50+
##### Make sure your feature builds
51+
Build instructions can be found [here](https://github.com/Mirantis/mke/blob/fba8a20cef8a66f6ae1e4f5ec248591085e02aa5/README.md#build)
52+
53+
#### 4. Keep your branch in sync
54+
```
55+
# While on your my_feature_branch branch
56+
git fetch upstream
57+
git rebase upstream/main
58+
```
59+
Please don't use `git pull` instead of the above `fetch / rebase`. `git pull` does a merge, which leaves merge commits. These make the commit history messy and violate the principle that commits ought to be individually understandable and useful (see below). You can also consider changing your `.git/config` file via `git config branch.autoSetupRebase always` to change the behavior of `git pull`, or another non-merge option such as `git pull --rebase`.
60+
61+
#### 5. Commit
62+
63+
Commit and sign your changes.
64+
65+
```
66+
git commit -m "my commit title" --signoff
67+
```
68+
You can go back and edit/build/test some more, then `commit --amend` in a few cycles.
69+
70+
#### 6. Push
71+
72+
When ready to review (or just to establish an offsite backup of your work), push your branch to your fork on github.com:
73+
74+
```
75+
git push -f origin my_feature_branch
76+
```
77+
78+
#### 7. Create a pull request
79+
80+
Visit your fork at https://github.com/$user/mke
81+
Click the `Compare & Pull Request` button next to your my_feature_branch branch.
82+
83+
##### Get a code review
84+
85+
Once your pull request has been opened it will be assigned to one or more reviewers. Those reviewers will do a thorough code review, looking for correctness, bugs, opportunities for improvement, documentation and comments, and style.
86+
87+
Commit changes made in response to review comments should be added to the same branch on your fork.
88+
89+
Very small PRs are easy to review. Very large PRs are very difficult to review.
90+
91+
##### Squash commits
92+
93+
After a review, prepare your PR for merging by squashing your commits.
94+
95+
All commits left on your branch after a review should represent meaningful milestones or units of work. Use commits to add clarity to the development and review process.
96+
97+
Before merging a PR, squash the following kinds of commits:
98+
99+
* Fixes/review feedback
100+
* Typos
101+
* Merges and rebases
102+
* Work in progress
103+
104+
Aim to have every commit in a PR compile and pass tests independently if you can, but it's not a requirement. In particular, `merge commits` must be removed, as they will not pass tests.
105+
106+
To squash your commits, perform an interactive rebase:
107+
1. Check your git branch:
108+
```
109+
git status
110+
```
111+
112+
Output is similar to:
113+
```
114+
Your branch is up to date with 'origin/my_feature_branch'.
115+
```
116+
2. Start an interactive rebase for your PR commits. If you PR has 3 commits, count backwards from your last commit using HEAD~<n>, where <n> represents the number of commits to include in the rebase.
117+
```
118+
git rebase -i HEAD~3
119+
```
120+
Output is similar to:
121+
```
122+
pick 2ebe926 Original commit
123+
pick 31f33e9 Address feedback
124+
pick b0315fe Second unit of work
125+
126+
# Rebase 7c34fc9..b0315ff onto 7c34fc9 (3 commands)
127+
#
128+
# Commands:
129+
# p, pick <commit> = use commit
130+
# r, reword <commit> = use commit, but edit the commit message
131+
# e, edit <commit> = use commit, but stop for amending
132+
# s, squash <commit> = use commit, but meld into previous commit
133+
# f, fixup <commit> = like "squash", but discard this commit's log message
134+
135+
...
136+
```
137+
3. Use a command line text editor to change the word `pick` to `fixup` for the commits you want to squash, then save your changes and continue the rebase:
138+
```
139+
pick 2ebe926 Original commit
140+
squash 31f33e9 Address feedback
141+
pick b0315fe Second unit of work
142+
...
143+
```
144+
145+
Output (after saving changes) is similar to:
146+
```
147+
[detached HEAD 61fdded] Second unit of work
148+
Date: Thu Mar 5 19:01:32 2020 +0100
149+
2 files changed, 15 insertions(+), 1 deletion(-)
150+
...
151+
Successfully rebased and updated refs/heads/main.
152+
```
153+
154+
4. Force push your changes to your remote branch:
155+
```
156+
git push --force
157+
```
158+

0 commit comments

Comments
 (0)