diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f0a314..41452f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/lessons/05-second-pr-from-terminal/README.md b/lessons/05-second-pr-from-terminal/README.md index 6eba17b..2b443a3 100644 --- a/lessons/05-second-pr-from-terminal/README.md +++ b/lessons/05-second-pr-from-terminal/README.md @@ -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 @@ -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 @@ -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 diff --git a/lessons/05-second-pr-from-terminal/exercise.md b/lessons/05-second-pr-from-terminal/exercise.md index fbed97e..2915c5a 100644 --- a/lessons/05-second-pr-from-terminal/exercise.md +++ b/lessons/05-second-pr-from-terminal/exercise.md @@ -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 diff --git a/lessons/05-second-pr-from-terminal/script.md b/lessons/05-second-pr-from-terminal/script.md index 331fe08..c7f25c9 100644 --- a/lessons/05-second-pr-from-terminal/script.md +++ b/lessons/05-second-pr-from-terminal/script.md @@ -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. @@ -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: ``` @@ -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, diff --git a/lessons/10-making-the-change/README.md b/lessons/10-making-the-change/README.md index e18c178..d5b1b41 100644 --- a/lessons/10-making-the-change/README.md +++ b/lessons/10-making-the-change/README.md @@ -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 diff --git a/lessons/11-opening-the-pull-request/README.md b/lessons/11-opening-the-pull-request/README.md index 5ebd850..1522eaf 100644 --- a/lessons/11-opening-the-pull-request/README.md +++ b/lessons/11-opening-the-pull-request/README.md @@ -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 diff --git a/lessons/15-capstone/script.md b/lessons/15-capstone/script.md index 0ef6e12..002261d 100644 --- a/lessons/15-capstone/script.md +++ b/lessons/15-capstone/script.md @@ -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 diff --git a/publishing/udemy-landing.md b/publishing/udemy-landing.md index b13be80..8a762dd 100644 --- a/publishing/udemy-landing.md +++ b/publishing/udemy-landing.md @@ -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. diff --git a/tests/test_workflows.py b/tests/test_workflows.py index ff6c44a..d738de0 100644 --- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -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")): diff --git a/tools/udemy_package.py b/tools/udemy_package.py index e29f3ba..05102f9 100644 --- a/tools/udemy_package.py +++ b/tools/udemy_package.py @@ -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):