You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contributing/exercise.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ nav_order: 2
12
12
If you are proposing a new exercise (i.e., not implementing an [already approved exercise proposal](https://github.com/git-mastery/exercises/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22exercise%20discussion%22%20label%3A%22help%20wanted%22)) make sure that you have done the following:
13
13
14
14
-[ ] Create an [exercise discussion](https://github.com/git-mastery/exercises/issues/new?template=exercise_discussion.yaml)
15
-
-[ ]Obtained approval on the exercise
15
+
-[ ]Obtain approval on the exercise
16
16
-[ ] File a [remote repository request](https://github.com/git-mastery/exercises/issues/new?template=request_exercise_repository.yaml)
If you are proposing a new exercise (i.e., not implementing an [already approved exercise proposal](https://github.com/git-mastery/exercises/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22exercise%20discussion%22%20label%3A%22help%20wanted%22)) make sure that you have done the following:
12
-
-[ ] Create an [exercise discussion](https://github.com/git-mastery/exercises/issues/new?template=exercise_discussion.yaml)
13
-
-[ ] Obtained approval on the exercise
14
-
-[ ] File a [remote repository request](https://github.com/git-mastery/exercises/issues/new?template=request_exercise_repository.yaml)
15
-
16
-
## Prerequisites
17
-
18
-
- Bash environment
19
-
- Python 3.13
20
-
- Github CLI [installed and authenticated](https://github.com/cli/cli#installation) for testing the download script
21
-
22
-
## Setup
23
-
24
-
1. Fork this repository
25
-
2. Clone the fork
26
-
27
-
```bash
28
-
git clone https://github.com/<username>/exercises
29
-
```
30
-
31
-
3. Setup a virtual environment
32
-
33
-
```bash
34
-
python -m venv venv
35
-
```
36
-
37
-
4. Activate the virtual environment
38
-
39
-
```bash
40
-
source venv/bin/activate
41
-
```
42
-
43
-
If you are using Windows, you should run the following instead:
44
-
45
-
```bash
46
-
source venv/Scripts/activate
47
-
```
12
+
If you are proposing a new hands-on (i.e., not implementing an [already approved hands-on proposal](https://github.com/git-mastery/exercises/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22hands-on%20discussion%22%20label%3A%22help%20wanted%22)) make sure that you have done the following:
48
13
49
-
5. Install all dependencies
50
-
51
-
```bash
52
-
pip install -r requirements.txt
53
-
```
14
+
-[ ] Create an [hands-on discussion](https://github.com/git-mastery/exercises/issues/new?template=hands_on_discussion.yaml)
15
+
-[ ] Obtain approval on the hands-on
16
+
-[ ] File a [remote repository request](https://github.com/git-mastery/exercises/issues/new?template=request_exercise_repository.yaml)
54
17
55
-
## Create a new exercise
18
+
## Create a new hands-on
56
19
57
20
Use the provided `new.sh` script to generate the scaffolding for a new exercise:
58
21
59
22
```bash
60
23
./new.sh
61
24
```
62
25
63
-
This script will prompt you for:
64
-
65
-
1. The name of the exercise -- likely to be specified in the corresponding exercise discussion
66
-
2. The exercise tags (split by space) -- likely to be specified in the corresponding exercise discussion
67
-
3. The exercise configuration (read the [`.gitmastery-exercise.json` configuration](#gitmastery-exercisejson-configuration) section for more info on this)
68
-
69
-
> [!TIP]
70
-
> You should use kebab casefor the exercise name.
71
-
72
-
It then generates the following directory structure:
73
-
74
-
```text
75
-
<exercise name>
76
-
├── .gitmastery-exercise.json
77
-
├── README.md
78
-
├── __init__.py
79
-
├── download.py
80
-
├── res
81
-
│ └── ...
82
-
├── tests
83
-
│ ├── specs
84
-
│ │ └── base.yml
85
-
│ └── test_verify.py
86
-
└── verify.py
87
-
```
26
+
The script will first prompt if you want to create a hands-on or exercise:
88
27
89
-
- `.gitmastery-exercise.json`: contains the exercise configuration
90
-
- `README.md`: contains the instructions for the exercise for the students to attempt
91
-
- `download.py`: contains the download instructions to setup the student's exercise
92
-
- `verify.py`: contains the verification script for the exercise attempt
93
-
- `res/`: contains resources that are available to students (see this section about [types of resources](#types-of-resources))
94
-
- `tests/specs/`: contains specification files written using [`repo-smith`](https://github.com/git-mastery/git-autograder)
95
-
- `tests/test_verify.py`: contains unit tests for verification script
28
+
Enter `hands-on` or `h` to create a new hands-on.
96
29
97
-
### `.gitmastery-exercise.json` configuration
30
+
Then, the script will prompt you for:
98
31
99
-
The `.gitmastery-exercise.json` is used to tell the [Git-Mastery app](https://git-mastery.github.io/app) how to setup the student's exercise.
32
+
1. The name of the hands-on -- likely to be specified in the corresponding hands-on discussion (you should be using kebab case for the hands-on name)
33
+
2. Does the exercise require Git?
34
+
3. Does the exercise require Github?
100
35
101
-
The `new.sh` script should have already generated one for you, but you may change your mind with the configuration and modify the file directly:
36
+
{: .reference }
102
37
103
-
- `exercise_name`: raw exercise name that will be indexed; recommended to use [kebab case](https://developer.mozilla.org/en-US/docs/Glossary/Kebab_case)
104
-
- `tags`: used during indexing on the [exercise directory](https://git-mastery.github.io/exercises)
105
-
- `requires_git`: performs a check to ensure that Git is installed and the user has already configured their `user.name` and `user.email`
106
-
- `requires_github`: performs a check to ensure that Github CLI is installed and the user has already authenticated themselves
107
-
- `base_files`: specifies the files from `res/` to be downloaded into the exercise root; typically used for the `answers.txt` (more about grading types [here]())
108
-
- `exercise_repo`: controls the sub-folder that is generated; this is where students work on the exercise
109
-
- `repo_type`: `local` or `remote`;if`remote`, then the sub-folder is generated from a remote repository
110
-
- `repo_name`: name of the sub-folder; required for both `repo_type`
111
-
- `init`: determines if`git init` is run for the sub-folder; required only for`local`
112
-
- `create_fork`: determines if a fork is created on the user's Github account; required only for `remote`
113
-
- `repo_title`: name of the remote repository to fork + clone; required only for `remote`
38
+
Refer to the [hands-on structure document](/developers/docs/architecture/hands-on-structure) for more information about the folder structure generated.
114
39
115
-
## Designing download process
40
+
## Download setup
116
41
117
42
The `download.py` contains the instructions to setup the local repository.
118
43
119
-
This is the sequence in which the Git-Mastery app downloads an exercise for a student:
e -- local --> f[Create local repo folder with repo_name]
128
-
e -- remote --> g[Fork repository if toggled]
129
-
g --> h[Clone repository with repo_name]
130
-
f --> i[Download resources]
131
-
h --> i
132
-
i --> j[Create initial commit if init toggled]
133
-
j --> k[Execute download function]
134
-
```
135
-
136
-
As a result, the `download` function is the last step after you have already setup the folder structures and downloaded the base files and resources.
137
-
138
-
The default download script comes with a helper function to `run_command` to run local commands.
139
-
140
-
> [!NOTE]
141
-
> You should be using OS-agnostic commands in the download script
142
-
143
-
The initial download script also includes a command to attach a tag as the "start tag". This is only useful if you want to iterate through the user's commits in your verification script. Otherwise, this can be removed.
144
-
145
-
Refer to existing `download.py`for reference on how to setup the download script.
146
-
147
-
### What students see
148
-
149
-
When a student downloads an exercise, they will see the following folder structure:
44
+
{: .reference }
150
45
151
-
```text
152
-
<exercise name>
153
-
├── .gitmastery-exercise.json
154
-
├── README.md
155
-
└── <sub folder name>
156
-
├── .git
157
-
└── ...
158
-
```
159
-
160
-
The root of the exercise will contain the `README.md` and `.gitmastery-exercise.json` configured from your template.
161
-
162
-
It also contains the sub-folder configured in`.gitmastery-exercise.json`, which is where students will attempt the exercise.
46
+
For more information about how Git-Mastery downloads exercises, refer to the [Download Workflow](/developers/docs/architecture/download-workflow)
163
47
164
-
### Types of resources
48
+
The default download script comes with a helper function to `run_command` to run local command, and a command to attach a tag as the "start tag". This is only useful if you want to iterate through the user's commits in your verification script. Otherwise, this can be removed.
165
49
166
-
There are two distinct types of resources:
50
+
These are some references for download setups for other exercises:
167
51
168
-
1. Base files: configured through the `base_files` property in`.gitmastery-exercise.json`in your template; files located in`res/` are downloaded to the root of the exercise folder
2. Resources: configured through the `__resources__` field in`download.py`; supporting files forthe exercise with files locatedin`res/` downloaded into the sub folder
181
-
182
-
```text
183
-
<exercise name>
184
-
├── .gitmastery-exercise.json
185
-
├── README.md
186
-
├── <base files>
187
-
└── <sub folder name>
188
-
├── .git
189
-
└── <resources><-- here
190
-
```
57
+
1. Any operations should use OS agnostic options (e.g. opting to use `shutil.rmtree` over `run_command(["rm"])`)
58
+
2. 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
59
+
3. For any commands that require `gh` (Github CLI), make sure that the `requires_github` configuration is set to `true` so that the app will automatically check that the student has correctly setup Github CLI
191
60
192
61
### Testing downloads
193
62
@@ -199,47 +68,15 @@ To test that your download script works, we have provided a script to simulate t
199
68
200
69
You can find the downloaded repository under the `test-downloads/` folder.
201
70
202
-
> [!NOTE]
203
-
> If you wish to support a remote repository and require the Git-Mastery team to create a new repository, create an issue and we will assess the request accordingly
204
-
205
-
206
-
## Designing verification process
71
+
## Submitting the hands-on for review
207
72
208
-
The verification process is controlled by the `verify.py`:
209
-
210
-
```mermaid
211
-
flowchart
212
-
a[Verify exercise] --> b["Check if in exercise (using .gitmastery-exercise.json)"]
213
-
b -- not in exercise --> c[Cancel]
214
-
b -- in exercise --> d[Execute verification script on exercise folder]
215
-
```
216
-
217
-
The [`git-autograder`](https://github.com/git-mastery/git-autograder) is built as a wrapper around [`GitPython`](https://github.com/gitpython-developers/GitPython). As a result, if you are writing any verification scripts and there is no available helper functionwith`git-autograder`, you can fall back to the underlying `Repo` object:
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.
228
-
229
-
### Testing verification
230
-
231
-
To test the verification, we rely on [`repo-smith`](https://github.com/git-mastery/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.
232
-
233
-
Refer to existing `test_verify.py` to see examples of unit testing the verification script.
234
-
235
-
You can run the unit tests of your exercise via:
73
+
Create a pull request from your fork using the provided pull request template.
236
74
237
-
```bash
238
-
./test.sh <your exercise folder>
239
-
```
75
+
Fill in all of the details necessary.
240
76
241
-
## Submitting the exercise for review
77
+
## Example
242
78
243
-
Create a pull request from your fork using the provided pull request template.
Copy file name to clipboardExpand all lines: index.markdown
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,4 +13,3 @@ Developer documentation about all things Git-Mastery.
13
13
14
14
Git-Mastery is a Git education tool developed by the National University of Singapore School of Computing to help students master Git through hands-on, guided tours with real-world scenario exercises.
0 commit comments