@@ -86,6 +86,115 @@ accept modifications without having to grant write access to others.
8686:::
8787
8888
89- ## Solution and walk-through
89+ ## Help and discussion
9090
91- We will add this before the lesson.
91+
92+ ### Opening a pull request towards the upstream repository
93+
94+ We have learned in the previous episode that pull requests are always from
95+ branch to branch. But the branch can be in a different repository.
96+
97+ When you open a pull request in a fork, by default GitHub will suggest to
98+ direct it towards the default branch of the upstream repository.
99+
100+ This can be changed and it should always be verified, but in this case this is
101+ exactly what we want to do, from fork towards upstream:
102+ :::{figure} img/forking-workflow/pull-request-form.png
103+ :width: 100%
104+ :class: with-border
105+ :alt: Screenshot of a pull request from fork towards upstream
106+ ::::
107+
108+
109+ ### Pull requests can be coupled with automated testing
110+
111+ We added an automated test here just for fun and so that you see that this is
112+ possible to do.
113+
114+ In this exercise, the test is silly. It will check whether the recipe contains
115+ both an ingredients and an instructions section.
116+
117+ In this example the test failed:
118+ :::{figure} img/forking-workflow/all-checks-failed.png
119+ :width: 60%
120+ :class: with-border
121+ :alt: Screenshot of a failed test in a pull request
122+ ::::
123+
124+ Click on the "Details" link to see the details of the failed test:
125+ :::{figure} img/forking-workflow/check-details.png
126+ :width: 60%
127+ :class: with-border
128+ :alt: Screenshot of details why the test failed
129+ ::::
130+
131+ ** How can this be useful?**
132+ - The project can define what kind of tests are expected to pass before a pull
133+ request can be merged.
134+ - The reviewer can see the results of the tests, without having to run them
135+ locally.
136+
137+ ** How does it work?**
138+ - We added a [ GitHub Actions workflow] ( https://github.com/coderefinery/recipe-book-template/blob/main/.github/workflows/check-recipes.yml )
139+ to automatically run on each push or pull request towards the ` main ` branch.
140+
141+ What tests or steps can you image for your project to run automatically with
142+ each pull request?
143+
144+
145+ ### How to update your fork with changes from upstream
146+
147+ This used to be difficult but now it is two mouse clicks.
148+
149+ Navigate to your fork and notice how GitHub tells you that your fork is behind.
150+ In my case, it is 9 commits behind upstream. To fix this, click on "Sync fork"
151+ and then "Update branch":
152+ :::{figure} img/forking-workflow/sync-fork.png
153+ :width: 80%
154+ :class: with-border
155+ :alt: Screenshot on GitHub fork page showing that the fork is behind
156+ ::::
157+
158+ After the update my "branch is up to date" with the upstream repository:
159+ :::{figure} img/forking-workflow/fork-after-update.png
160+ :width: 80%
161+ :class: with-border
162+ :alt: Screenshot on GitHub after fork has been updated
163+ ::::
164+
165+
166+ ### How to approach other people’s repositories with ideas, changes, and requests
167+
168+ ** Contributing very minor changes**
169+ - Clone or fork+clone repository
170+ - Create a branch
171+ - Commit and push change
172+ - Open a pull request or merge request
173+
174+ ** If you observe an issue and have an idea how to fix it**
175+ - Open an issue in the repository you wish to contribute to
176+ - Describe the problem
177+ - If you have a suggestion on how to fix it, describe your suggestion
178+ - Possibly ** discuss and get feedback**
179+ - If you are working on the fix, indicate it in the issue so that others know that somebody is working on it and who is working on it
180+ - Submit your fix as pull request or merge request which references/closes the issue
181+
182+ :::{admonition} Motivation
183+ - ** Inform others about an observed problem**
184+ - Make it clear whether this issue is up for grabs or already being worked on
185+ :::
186+
187+ ** If you have an idea for a new feature**
188+ - Open an issue in the repository you wish to contribute to
189+ - In the issue, write a short proposal for your suggested change or new feature
190+ - Motivate why and how you wish to do this
191+ - Also indicate where you are unsure and where you would like feedback
192+ - ** Discuss and get feedback before you code**
193+ - Once you start coding, indicate that you are working on it
194+ - Once you are done, submit your new feature as pull request or merge request which references/closes the issue/proposal
195+
196+ :::{admonition} Motivation
197+ - ** Get agreement and feedback before writing 5000 lines of code** which might be rejected
198+ - If we later wonder why something was done, we have the issue/proposal as
199+ reference and can read up on the reasoning behind a code change
200+ :::
0 commit comments