Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Link the exercise discussion issue

- [ ] If you require a new remote repository on the `Git-Mastery` organization, have you [created a request](https://github.com/git-mastery/exercises/issues/new?template=request_exercise_repository.md) for it?
- [ ] Have you written unit tests using [`repo-smith`](https://github.com/git-mastery/repo-smith) to validate the exercise grading scheme?
- [ ] Have you tested the download script using `test-download.sh`?
- [ ] Have you tested your changes using the instructions posted?
- [ ] Have you verified that this exercise does not already exist or is not currently in review?
- [ ] Did you introduce a new grading mechanism that should belong to [`git-autograder`](https://github.com/git-mastery/git-autograder)?
- [ ] Did you introduce a new dependency that should belong to [`app`](https://github.com/git-mastery/app)?
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Run validation script
run: |
python validate-exercise-config.py
python scripts/validate-exercise-config.py

unit_tests:
runs-on: ubuntu-latest
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/contribution-message.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Post contribution message in pull request
on:
pull_request:
types: [opened]

jobs:
post_contribution_message:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install dependencies
run: |
pip install requests PyGithub

- name: Run post contribution message script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
COMMIT_AUTHOR: ${{ github.event.pull_request.user.login }}
FORK_AUTHOR: ${{ github.event.pull_request.head.repo.owner.login }}
FORK_REPO: ${{ github.event.pull_request.head.repo.name }}
FORK_BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
python scripts/post-contribution-message.py
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Generate exercise-directory.md
run: |
python create-exercise-directory.py
python scripts/create-exercise-directory.py
mv exercise-directory.md index.md

- name: Deploy to gh-pages
Expand Down
4 changes: 2 additions & 2 deletions new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ read choice

case "$choice" in
"hands-on" | "h" | "H")
python new-hands-on.py
python scripts/new-hands-on.py
;;
"exercise" | "e" | "E")
python new-exercise.py
python scripts/new-exercise.py
;;
*)
echo "Invalid choice. Please enter 'hands-on' (h) or 'exercise' (e)."
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ repo-smith
# Developer tooling dependencies
ruff
mypy
PyGithub
requests
types-requests
File renamed without changes.
File renamed without changes.
File renamed without changes.
85 changes: 85 additions & 0 deletions scripts/post-contribution-message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import os

from github import Github

GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN")
PR_NUMBER = os.environ.get("PR_NUMBER")
COMMIT_AUTHOR = os.environ.get("COMMIT_AUTHOR")
FORK_AUTHOR = os.environ.get("FORK_AUTHOR")
FORK_REPO = os.environ.get("FORK_REPO")
FORK_BRANCH = os.environ.get("FORK_BRANCH")

if not all(
[GITHUB_TOKEN, PR_NUMBER, COMMIT_AUTHOR, FORK_AUTHOR, FORK_REPO, FORK_BRANCH]
):
raise ValueError("Missing required environment variables")

assert PR_NUMBER is not None
PR_NUMBER_INT = int(PR_NUMBER)

gh = Github(GITHUB_TOKEN)
repo = gh.get_repo("git-mastery/exercises")
pr = repo.get_pull(PR_NUMBER_INT)

comment = f"""
Hi @{COMMIT_AUTHOR}, thank you for your contribution! 🎉

This PR comes from your fork `{FORK_AUTHOR}/{FORK_REPO}` on branch `{FORK_BRANCH}`.

Before you request for a review, please ensure that you have tested your changes locally!

> [!IMPORTANT]
> The previously recommended way of using `./test-download.py` is no longer the best way to test your changes locally.
>
> Please read the following instructions for the latest instructions.

### Prerequisites

Ensure that you have the `gitmastery` app installed locally ([instructions](https://git-mastery.github.io/companion-app/index.html))

### Testing steps

If you already have a local Git-Mastery root to test, you can skip the following step.

Create a Git-Mastery root locally:

```bash
gitmastery setup
```

Navigate into the Git-Mastery root (defaults to `gitmastery-exercises/`):

```bash
cd gitmastery-exercises/
```

Edit the `.gitmastery.json` configuration file. You need to set the following values under the `exercises_source` key.

```json
{
# other fields...
"exercises_source": {
"username": "{FORK_AUTHOR}",
"repository": "{FORK_REPO}",
"branch": "{FORK_BRANCH}",
}
}
```

Then, you can use the `gitmastery` app to download and verify your changes locally.

```bash
gitmastery download <your new change>
gitmastery verify
```

### Checklist

- [ ] (For exercises and hands-ons) I have verified that the downloading behavior works
- [ ] (For exercises only) I have verified that the verification behavior is accurate

> [!IMPORTANT]
> To any reviewers of this pull request, please use the same instructions above to test the changes.
""".lstrip()

pr.create_issue_comment(comment)
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test-download.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

python test-download.py $1
python scripts/test-download.py $1
Loading