Skip to content

Commit fa776f0

Browse files
Makes everyone fail the pre-commit checks in the morning session (MetOffice#72)
* Makes everyone fail the pre-commit checks in the morning session * Fix image links and delete JPEGs --------- Co-authored-by: Ronnie Dutta <[email protected]>
1 parent 6c63bd9 commit fa776f0

20 files changed

+88
-38
lines changed

episodes/01-issues.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Here's some advice for writing good Issues:
3232
- Break up large Issues into several small ones and or
3333
use checklists to track tasks in the Issue
3434

35-
Open an Issue on the `git-training-demo` repository
35+
Open an Issue on the `git-training-demo` repository
3636
to add a file stating your favourite cloud type.
3737

3838
Navigate to the **Issues** tab:
@@ -46,7 +46,7 @@ to provide templates for bugs and feature requests.
4646
Click on the green **Get started** button next to the
4747
**Feature request** option:
4848

49-
![](fig/github-fork-issue-1.jpeg){alt='A screenshot of the git-training-demo repository showing an Issue being opened. The template has automatically added text to the description and labelled the Issue as an enhancement.'}
49+
![](fig/github-fork-issue-1.png){alt='A screenshot of the git-training-demo repository showing an Issue being opened. The template has automatically added text to the description and labelled the Issue as an enhancement.'}
5050

5151
You can see the Issue has text in the description already.
5252
This is from the template which provides a consistent
@@ -93,7 +93,7 @@ On the right hand side of the Issue you can:
9393
you are working on it.
9494
2. Add the Issue to a Project by clicking on the cog
9595
next to the Projects section. (If you don't see a project
96-
related to the training you might not have been granted permissions,
96+
related to the training you might not have been granted permissions,
9797
ask your instructors for help)
9898
3. Assign the Issue to a milestone.
9999

episodes/03-feature-branch.md

Lines changed: 79 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,18 @@ $ cat cloud-mo-fitzroy.md
109109
```output
110110
# My Favourite Cloud
111111
112-
Light and fluffy cumulus.
112+
Light and fluffy cumulus.
113113
```
114114

115+
::: caution
116+
117+
## Add in whitespace!
118+
119+
To demonstrate automated testing via GitHub,
120+
add some spaces to the end of a line in your file.
121+
122+
:::
123+
115124
Add and commit your changes:
116125

117126
```bash
@@ -139,10 +148,10 @@ Compressing objects: 100% (2/2), done.
139148
Writing objects: 100% (3/3), 357 bytes | 178.00 KiB/s, done.
140149
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
141150
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
142-
remote:
151+
remote:
143152
remote: Create a pull request for '1_favourite_cloud' on GitHub by visiting:
144153
remote: https://github.com/MetOffice/git-training-demo/pull/new/1_favourite_cloud
145-
remote:
154+
remote:
146155
To github.com:metoffice/git-training-demo.git
147156
* [new branch] 1_favourite_cloud -> 1_favourite_cloud
148157
branch '1_favourite_cloud' set up to track 'origin/1_favourite_cloud'.
@@ -222,7 +231,6 @@ associated with a repository. Here are some of the most useful ones:
222231
- `git remote rename [oldname] [newname]` changes the local alias by which a remote
223232
is known - its name. For example, one could use this to change `upstream` to `mo-fitzroy`.
224233

225-
226234
::::::::::::::::::::::::::::::::::::::::::::::::::
227235

228236
## Open a PR
@@ -277,7 +285,7 @@ In the description scroll down to the checklists
277285
which look like this:
278286

279287
```md
280-
- [ ] I have read `CONTRIBUTING.md` and added my name as a Code Contributor.
288+
- [ ] I have read `CONTRIBUTING.md`.
281289
```
282290

283291
Some open source projects require you to add your name
@@ -287,45 +295,33 @@ Replace the space in the square checkbox brackets with an `x`
287295
to mark the task as complete:
288296

289297
```md
290-
- [x] I have read `CONTRIBUTING.md` and added my name as a Code Contributor.
298+
- [x] I have read `CONTRIBUTING.md`.
291299
```
292300

293301
Now when you open the PR it should look something like this:
294302

295-
![](fig/github-fork-pr-1.jpeg){alt='A screenshot of a users pull request from their fork back to the upstream git-training-demo repository.'}
303+
![](fig/github-fork-pr-1.png){alt='A screenshot of a users pull request from their fork back to the upstream git-training-demo repository.'}
296304

297-
This image shows PR number `#8`.
298-
This PR will close/fix Issue number `#7` (the top left arrow).
305+
This image shows PR number `#2`.
306+
This PR will close/fix Issue number `#1` (the top left arrow).
299307
You can request a review on the top right.
300308
Some repositories will be set up to automatically assign
301309
a reviewer based on how many reviews each team member
302310
currently has open[^auto-assign-pr-review].
311+
The middle arrow is where you assign yourself to the PR.
303312
The bottom arrow shows the checklist items we marked as complete.
304313

305314
At the bottom of your PR you can see that a review is required
306-
before merging.
307-
All checks have passed, this repository has automatic checks
315+
before merging and some checks were not successful.
316+
This repository has automatic checks
308317
for trailing whitespace, accidentally adding large files etc.
309-
More information can be found in the optional episode on
318+
More information on setting up these checks
319+
can be found in the optional episode on
310320
[pre-commit hooks](./09-pre-commit.md).
311321

312-
::: caution
313-
314-
## Help: Some checks have failed
315-
316-
If your now open Pull Request says some checks have failed
317-
this is because your changes did not pass the automatic
318-
pre-commit checks.
319-
320-
Click on the **Details** link next to the failed test
321-
and fix your code on your local repository.
322-
Commit and then push this fix to GitHub.
323-
Your PR will automatically update and re-run the tests,
324-
you may need to refresh the page.
322+
::: callout
325323

326-
:::
327-
328-
### Automatically closing Issues via PRs
324+
## Automatically closing Issues via PRs
329325

330326
A PR can automatically close an Issue when it is merged into `main`.
331327
To use this GitHub functionality
@@ -345,8 +341,61 @@ Make sure you change `1` to your Issue number.
345341
The [GitHub Documentation](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue) has more information
346342
on linking PRs to Issues.
347343

344+
:::
345+
346+
## Fixing Failing Checks
347+
348+
Your changes did not pass the automatic pre-commit checks.
349+
The quickest way to check why a test failed is to click on
350+
the **Pull request checks / pre-commit** link near the bottom
351+
of the PR.
352+
Or you can navigate to the **Checks** tab in the PR,
353+
then select **Pull request checks** and click on the failing test.
354+
355+
![](fig/pre-commit-check-fail-1.png){alt='A screenshot of a users failing pre-commit check showing the whitespace test has failed.'}
356+
357+
You can see in the test output trailing whitespace has been found.
358+
This caused the tests to fail.
359+
Lower down in the output you will see the filename,
360+
and a diff of the line with the whitespace.
361+
362+
Go back to your local repository and remove the whitespace:
363+
364+
```bash
365+
$ nano cloud-mo-fitzroy.md
366+
$ cat cloud-mo-fitzroy.md
367+
```
368+
369+
```output
370+
# My Favourite Cloud
371+
372+
Light and fluffy cumulus.
373+
```
374+
375+
Add and commit your changes:
376+
377+
```bash
378+
$ git add cloud-mo-fitzroy.md
379+
$ git commit -m "Removes whitespace"
380+
```
381+
382+
```output
383+
[1_favourite_cloud c74c7e1] Removes whitespace
384+
1 file changed, 1 insertion(+), 1 deletion(-)
385+
```
386+
387+
Push these changes to GitHub:
388+
389+
```bash
390+
$ git push
391+
```
392+
393+
Navigate back to your PR.
394+
You should now see a message saying all checks have passed.
395+
Merging is still blocked until a colleague reviews our code.
396+
348397
In the next episode we will look at how these changes
349-
are reviewed and merged back into `main` in more detail.
398+
are reviewed and merged back into `main`.
350399

351400
::::::::::::::::::::::::::::::::::::::: challenge
352401

@@ -361,7 +410,7 @@ On the right hand side of the PR you can also:
361410
2. Add labels to the PR.
362411
3. Add the PR to a Project by clicking on the cog
363412
next to the Projects section. (If you don't see a project
364-
related to the training you might not have been granted permissions,
413+
related to the training you might not have been granted permissions,
365414
ask your instructors for help)
366415
4. Assign the PR to a milestone.
367416

episodes/04-review.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ When you're finished click the green **Submit review** button.
103103

104104
![](fig/pr-suggestion-2.png){alt='A screenshot of a PR showing the diff in the Files changed tab showing the review popup.'}
105105

106-
The PRs **Conversation** tab now looks like this:
106+
The PRs **Conversation** tab now looks like this
107+
towards the bottom of the page:
107108

108109
![](fig/pr-review-1.png){alt='A screenshot of a PR showing the Conversation tab with a review that has requested changes.'}
109110

episodes/05-forks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ Compressing objects: 100% (3/3), done.
152152
Writing objects: 100% (3/3), 369 bytes | 123.00 KiB/s, done.
153153
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
154154
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
155-
remote:
155+
remote:
156156
remote: Create a pull request for '2_update_favourite_cloud' on GitHub by visiting:
157157
remote: https://github.com/mo-fitzroy/git-training-demo/pull/new/2_update_favourite_cloud
158-
remote:
158+
remote:
159159
To github.com:mo-fitzroy/git-training-demo.git
160160
* [new branch] 2_update_favourite_cloud -> 2_update_favourite_cloud
161161
branch '2_update_favourite_cloud' set up to track 'origin/2_update_favourite_cloud'.
@@ -173,7 +173,7 @@ from a Fork[^link-pr-issue].
173173
[^link-pr-issue]: The [GitHub Documentation](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue) has more information
174174
on linking PRs to Issues.
175175

176-
![](fig/github-fork-pr-open.jpeg){alt='A screenshot of a user opening a pull request from their fork back to the upstream git-training-demo repository. The description has been autofilled with the pull request template contents.'}
176+
![](fig/github-fork-pr-open.png){alt='A screenshot of a user opening a pull request from their fork back to the upstream git-training-demo repository. The description has been autofilled with the pull request template contents.'}
177177

178178
The PR will now need to be approved and merged by your instructors.
179179

@@ -339,7 +339,7 @@ sequenceDiagram
339339
- A fork is a server side, in our case GitHub, copy
340340
of the repository.
341341
- Forks allow collaborators to contribute to the main
342-
repository without being given
342+
repository without being given
343343
collaborator access or write permissions.
344344

345345
::::::::::::::::::::::::::::::::::::::::::::::::::
-90.9 KB
Binary file not shown.
45.6 KB
Loading

episodes/fig/github-fork-issue-1.jpeg

-82 KB
Binary file not shown.

episodes/fig/github-fork-issue-1.png

42.3 KB
Loading
-1.67 KB
Loading
-1.61 KB
Loading

0 commit comments

Comments
 (0)