|
| 1 | +import os |
| 2 | + |
| 3 | +from github import Github |
| 4 | + |
| 5 | +GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN") |
| 6 | +PR_NUMBER = os.environ.get("PR_NUMBER") |
| 7 | +COMMIT_AUTHOR = os.environ.get("COMMIT_AUTHOR") |
| 8 | +FORK_AUTHOR = os.environ.get("FORK_AUTHOR") |
| 9 | +FORK_REPO = os.environ.get("FORK_REPO") |
| 10 | +FORK_BRANCH = os.environ.get("FORK_BRANCH") |
| 11 | + |
| 12 | +if not all( |
| 13 | + [GITHUB_TOKEN, PR_NUMBER, COMMIT_AUTHOR, FORK_AUTHOR, FORK_REPO, FORK_BRANCH] |
| 14 | +): |
| 15 | + raise ValueError("Missing required environment variables") |
| 16 | + |
| 17 | +assert PR_NUMBER is not None |
| 18 | +PR_NUMBER_INT = int(PR_NUMBER) |
| 19 | + |
| 20 | +gh = Github(GITHUB_TOKEN) |
| 21 | +repo = gh.get_repo("git-mastery/exercises") |
| 22 | +pr = repo.get_pull(PR_NUMBER_INT) |
| 23 | + |
| 24 | +comment = f""" |
| 25 | +Hi @{COMMIT_AUTHOR}, thank you for your contribution! 🎉 |
| 26 | +
|
| 27 | +This PR comes from your fork `{FORK_AUTHOR}/{FORK_REPO}` on branch `{FORK_BRANCH}`. |
| 28 | +
|
| 29 | +Before you request for a review, please ensure that you have tested your changes locally! |
| 30 | +
|
| 31 | +> [!IMPORTANT] |
| 32 | +> The previously recommended way of using `./test-download.py` is no longer the best way to test your changes locally. |
| 33 | +> |
| 34 | +> Please read the following instructions for the latest instructions. |
| 35 | +
|
| 36 | +### Prerequisites |
| 37 | +
|
| 38 | +Ensure that you have the `gitmastery` app installed locally ([instructions](https://git-mastery.github.io/companion-app/index.html)) |
| 39 | +
|
| 40 | +### Testing steps |
| 41 | +
|
| 42 | +If you already have a local Git-Mastery root to test, you can skip the following step. |
| 43 | +
|
| 44 | +Create a Git-Mastery root locally: |
| 45 | +
|
| 46 | +```bash |
| 47 | +gitmastery setup |
| 48 | +``` |
| 49 | +
|
| 50 | +Navigate into the Git-Mastery root (defaults to `gitmastery-exercises/`): |
| 51 | +
|
| 52 | +```bash |
| 53 | +cd gitmastery-exercises/ |
| 54 | +``` |
| 55 | +
|
| 56 | +Edit the `.gitmastery.json` configuration file. You need to set the following values under the `exercises_source` key. |
| 57 | +
|
| 58 | +```json |
| 59 | +{{ |
| 60 | + # other fields... |
| 61 | + "exercises_source": {{ |
| 62 | + "username": "{FORK_AUTHOR}", |
| 63 | + "repository": "{FORK_REPO}", |
| 64 | + "branch": "{FORK_BRANCH}", |
| 65 | + }} |
| 66 | +}} |
| 67 | +``` |
| 68 | +
|
| 69 | +Then, you can use the `gitmastery` app to download and verify your changes locally. |
| 70 | +
|
| 71 | +```bash |
| 72 | +gitmastery download <your new change> |
| 73 | +gitmastery verify |
| 74 | +``` |
| 75 | +
|
| 76 | +### Checklist |
| 77 | +
|
| 78 | +- [ ] (For exercises and hands-ons) I have verified that the downloading behavior works |
| 79 | +- [ ] (For exercises only) I have verified that the verification behavior is accurate |
| 80 | +
|
| 81 | +> [!IMPORTANT] |
| 82 | +> To any reviewers of this pull request, please use the same instructions above to test the changes. |
| 83 | +""".lstrip() |
| 84 | + |
| 85 | +pr.create_issue_comment(comment) |
0 commit comments