- Before contributing
- Create a new exercise
- Download setup
- Verification setup
- Submitting the exercise for review
- Example
Before contributing
If you are proposing a new exercise (i.e., not implementing an already approved exercise proposal) make sure that you have done the following:
- Create an exercise discussion
- Obtain approval on the exercise
- File a remote repository request
Create a new exercise
Use the provided new.sh
script to generate the scaffolding for a new exercise:
./new.sh
The script will first prompt if you want to create a hands-on or exercise:
Enter exercise
or e
to create a new exercise.
Then, the script will prompt you for:
- The name of the exercise – likely to be specified in the corresponding exercise discussion (you should be using kebab case for the exercise name)
- The exercise tags (split by space) – likely to be specified in the corresponding exercise discussion
- The exercise configuration (read the exercise configuration section for more info on this)
Refer to the exercise structure document for more information about the folder structure generated.
Download setup
The download.py
contains the instructions to setup the local repository.
For more information about how Git-Mastery downloads exercises, refer to the Download Workflow
exercises
comes with a set of utility functions in theexercise_utils
module that are made available during the download flow. They provide simple wrappers around common functionality such asexercise_utils.cli.run_command
to invoke any command andexercise_utils.file.create_or_update_file
to create or update a given file.For the full list of utility functions, refer here.
These are some references for download setups for other exercises:
Download conventions
- Any operations should use OS agnostic options (e.g. opting to use
shutil.rmtree
overrun_command(["rm"])
) - If you need to compare the states before and after the student has started to add commits, use the given “start tag” as
git-autograder
is designed to read that if necessary - For any commands that require
gh
(Github CLI), make sure that therequires_github
configuration is set totrue
so that the app will automatically check that the student has correctly setup Github CLI
Testing downloads
To test that your download script works, we have provided a script to simulate the download process in this repository for you to verify.
./test-download.sh <your exercise folder>
You can find the downloaded repository under the test-downloads/
folder.
Verification setup
The verification process is controlled by the verify.py
.
For more information about how Git-Mastery verifies exercise attempts, refer to the Verification Workflow
The git-autograder
is built as a wrapper around GitPython
. As a result, if you are writing any verification scripts and there is no available helper function with git-autograder
, you can fall back to the underlying Repo
object:
def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
# Access the underlying GitPython repo:
exercise.repo.repo
return exercise.to_output([], GitAutograderStatus.SUCCESSFUL)
Refer to existing verify.py
scripts to understand what are the available helper functions to streamline the grading. Open an issue if there is something that is not yet supported or if you have a question.
Some examples of verifications:
Verification conventions
- Store the comments of the verification as constants so that they can be imported and used reliably in unit tests
- For any remote behavior to verify, provide a mock to substitute the behavior in the unit tests
Testing verification
To test the verification, we rely on repo-smith
to simulate exercise states and write unit tests to verify the verification script’s behavior. You don’t need to simulate the entire flow, just the end states that you require for your verification script.
Refer to existing test_verify.py
to see examples of unit testing the verification script.
You can run the unit tests of your exercise via:
./test.sh <your exercise folder>
Submitting the exercise for review
Create a pull request from your fork using the provided pull request template.
Fill in all of the details necessary.
Example
- Exercise discussion: https://github.com/git-mastery/exercises/issues/24
- Remote repository request: https://github.com/git-mastery/exercises/issues/25
- Exercise PR: https://github.com/git-mastery/exercises/pull/26