Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Thanks for helping! There are two kinds of contribution here.
- **Lesson 05:** add `practice/greetings/YOUR_NAME.py` and its test. See
[the lesson](lessons/05-second-pr-from-terminal/).

Bots check and merge these PRs. Change only your own files.
Bots check these PRs, and a maintainer reviews and merges them. Change only
your own files.

## 2. Improving the course

Expand Down
22 changes: 15 additions & 7 deletions lessons/05-second-pr-from-terminal/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lesson 05: Your second PR, from the terminal

**Time:** 6 minute video · 30 minute exercise
**Time:** 7 minute video · 30 minute exercise
**You'll need:** a green `tools/doctor.py` (Lesson 03)

This time you'll contribute like you would to a real Python project: on a
Expand Down Expand Up @@ -117,16 +117,17 @@ python -m pytest practice
```

```text
practice/tests/test_ada_lovelace.py . [ 14%]
practice/tests/test_all_greetings.py ... [ 57%]
practice/tests/test_textkit.py . [ 71%]
practice/tests/test_thejesh23.py .. [100%]
practice/tests/test_ada_lovelace.py . [ 12%]
practice/tests/test_all_greetings.py ... [ 50%]
practice/tests/test_textkit.py . [ 62%]
practice/tests/test_thejesh23.py ... [100%]

============================== 7 passed in 0.01s ===============================
============================== 8 passed in 0.01s ===============================
```

Each `.` is a passing test. `test_all_greetings.py` is the course's own test:
it checks every learner's `greet` follows the rules, including yours.
it checks every learner's `greet` follows the rules, including yours. Your
list is longer and your number is higher: every learner adds a test file.

## Step 6: Format and lint

Expand Down Expand Up @@ -190,6 +191,13 @@ One check runs on your PR: **Exercise 2 tests** (listed as `test`). It
runs `ruff format --check`, `ruff check` and `pytest` on your code, exactly
like Steps 5 and 6.

> **No checks yet?** GitHub doesn't run a newcomer's checks until a
> maintainer approves them. If your Lesson 02 pull request hasn't been
> merged yet, this check waits too: `gh pr checks` reports no checks, and
> the pull request page says a workflow is awaiting approval. You did
> nothing wrong. The check starts when a maintainer approves it, usually
> within a day. Run `gh pr checks --watch` again then.

When it finishes, a separate review bot checks your file names and that your
code only contains what it should. It doesn't appear in the checks list:
about a minute later it **comments** on your PR. If everything passed, a
Expand Down
1 change: 1 addition & 0 deletions lessons/05-second-pr-from-terminal/exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [ ] Commit only your two files, then `git push -u origin exercise-2`
- [ ] `gh pr create --fill` (after `gh repo set-default thejesh23/first-python-contribution`)
- [ ] `gh pr checks --watch` until the check is green, then wait for the bot's comment and the merge
(no checks yet? Your first run waits for a maintainer's approval until your Lesson 02 PR is merged)
- [ ] Tidy up: `git switch main`, `git pull upstream main`, `git branch -d exercise-2`

**Stretch 1:** add a second test, for example that `greet("")` still returns
Expand Down
17 changes: 11 additions & 6 deletions lessons/05-second-pr-from-terminal/script.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ notes:
code:
```
(.venv) $ python -m pytest practice
practice/tests/test_ada_lovelace.py . [ 14%]
practice/tests/test_all_greetings.py ... [ 57%]
practice/tests/test_textkit.py . [ 71%]
practice/tests/test_thejesh23.py .. [100%]
practice/tests/test_ada_lovelace.py . [ 12%]
practice/tests/test_all_greetings.py ... [ 50%]
practice/tests/test_textkit.py . [ 62%]
practice/tests/test_thejesh23.py ... [100%]

============================== 7 passed in 0.01s ===============================
============================== 8 passed in 0.01s ===============================
```

> Run the same command again.
Expand Down Expand Up @@ -328,10 +328,11 @@ code:

## Scene 15: Watch CI
visual: terminal
focus: 1 | 2 | 3
focus: 1 | 2 | 2 | 3
notes:
- Watch the check run, live
- The check runs `ruff format --check`, `ruff check` and `pytest`
- No checks yet? A maintainer approves a newcomer's first run. Just wait.
- Then the review bot comments, and a maintainer merges
code:
```
Expand All @@ -346,6 +347,10 @@ code:
> One check runs. It is called test. It runs ruff format, ruff check and
> {pytest|pie test} on your code. The same three commands you just ran.

> If it says no checks, don't worry. Until your first pull request is
> merged, GitHub waits for a maintainer to approve the run. Try again
> later.

> After it passes, a review bot looks at your file names and your code. About
> a minute later, it leaves a comment. If everything passed, a maintainer
> reviews and merges your pull request. Read the comment with {gh pr view --comments|g h, p r, view,
Expand Down
8 changes: 6 additions & 2 deletions lessons/10-making-the-change/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ ruff check practice
```

```text
9 passed in 0.01s
5 passed in 0.01s
10 passed in 0.01s
9 files left unchanged
All checks passed!
```

Narrow first (fast), then the whole suite and the linters, exactly as CI
will.
will. Your second number is higher: every learner's merged Exercise 2 adds
tests.

## Step 5: A changelog entry

Expand Down
7 changes: 4 additions & 3 deletions lessons/11-opening-the-pull-request/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ ready, click **Ready for review**, or run `gh pr ready`.
## Opening it

Write the description in a file, so you can read it over before anyone
else does:
else does. The title goes on the command line, so the file holds only the
description, without a title line:

```bash norun
gh pr create --title "Fix slugify for repeated spaces and punctuation" --body-file pr-description.md
gh pr create --draft --title "..." --body-file pr-description.md # not ready yet
gh pr create --title "Fix slugify for repeated spaces and punctuation" --body-file description.md
gh pr create --draft --title "..." --body-file description.md # not ready yet
```

Or in the browser: open your fork and click **Compare & pull request**, as
Expand Down
4 changes: 2 additions & 2 deletions lessons/15-capstone/script.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ bullets:
> That it was merged by someone else.

> And that it is in a real project you don't own. If everything checks out,
> it comments, merges, and you appear on the graduates wall. If not, its
> comment says exactly what's wrong.
> the bot says so. A maintainer merges it, and you appear on the graduates
> wall. If not, its comment says exactly what's wrong.

## Scene 8: Welcome
visual: slide
Expand Down
2 changes: 1 addition & 1 deletion publishing/udemy-landing.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Then you go out into the real world. You learn the house rules every project has

The course ends with a capstone: a merged pull request in a real project you choose. A bot verifies it on GitHub and adds you to the graduates wall.

Every lesson has a short video, a written lesson, a hands-on exercise and a quiz. All the materials, exercises and bots live in a free, open source GitHub repository, linked from every lecture.
Every lesson has a short video, a written lesson, a hands-on exercise and a quiz. All the materials, exercises and bots live in a free, open source GitHub repository: thejesh23/first-python-contribution. Every lecture links straight to its lesson there.

How this course is made: the lessons and video scripts were drafted with AI and reviewed by the instructor, and the narration uses a text-to-speech voice. Every command shown in the course is tested.

Expand Down
11 changes: 11 additions & 0 deletions tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ def test_bots_only_check_and_comment():
assert "gh pr comment" in text


def test_no_lesson_says_a_bot_merges():
"""The lessons and videos must say what the bots do: check and comment."""
root = WORKFLOWS.parent.parent
pages = [*root.glob("*.md"), *root.glob("lessons/*/*.md"), *root.glob("publishing/**/*.md")]
pages += [*root.glob("first-commits/README.md"), *root.glob("practice/README.md")]
claim = re.compile(r"bots? (?:check(?:s)? and )?merges?\b|it comments,? (?:and )?merges", re.IGNORECASE)
for page in pages:
text = " ".join(page.read_text(encoding="utf-8").replace(">", " ").split())
assert not claim.search(text), f"{page.relative_to(root)} says a bot merges; a maintainer does"


def test_every_action_is_pinned_to_a_commit():
for path in WORKFLOWS.glob("*.yml"):
for ref in re.findall(r"uses: \S+@(\S+)", path.read_text(encoding="utf-8")):
Expand Down
6 changes: 5 additions & 1 deletion tools/udemy_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ def bullets(items):
"## 3. Curriculum",
"",
"Create one section per heading below, then one lecture per row. Upload the video, add its",
"captions (English) and add the written lesson as an external resource link.",
"captions (English) and add the written lesson as an external resource link. Put the same",
'link in the lecture\'s description too: "Written lesson, exercise and quiz: LINK".',
"",
"Udemy allows no links on the landing page itself (only in the instructor bio), so the",
"description names the repository without a link.",
"",
]
for n, section in enumerate(sections, start=1):
Expand Down
Loading