Skip to content

Commit b4e17a8

Browse files
committed
Edit
1 parent 92548c7 commit b4e17a8

File tree

13 files changed

+539
-81
lines changed

13 files changed

+539
-81
lines changed

Gemfile

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,19 @@ source 'https://rubygems.org'
88
# This will help ensure the proper Jekyll version is running.
99
# Happy Jekylling!
1010
# gem 'jekyll', '~> 4.4.1'
11-
# This is the default theme for new Jekyll sites. You may change this to anything you like.
12-
gem 'just-the-docs'
13-
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
14-
# uncomment the line below. To upgrade, run `bundle update github-pages`.
1511
gem 'github-pages', group: :jekyll_plugins
16-
# If you have any plugins, put them here!
12+
gem 'just-the-docs'
1713
group :jekyll_plugins do
1814
gem 'jekyll-feed', '~> 0.12'
1915
end
2016

21-
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
22-
# and associated library.
2317
platforms :mingw, :x64_mingw, :mswin, :jruby do
2418
gem 'tzinfo', '>= 1', '< 3'
2519
gem 'tzinfo-data'
2620
end
2721

28-
# Performance-booster for watching directories on Windows
2922
gem 'wdm', '~> 0.1', platforms: %i[mingw x64_mingw mswin]
3023

31-
# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
32-
# do not have a Java counterpart.
3324
gem 'http_parser.rb', '~> 0.6.0', platforms: [:jruby]
25+
26+
gem 'webrick'

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ DEPENDENCIES
332332
tzinfo (>= 1, < 3)
333333
tzinfo-data
334334
wdm (~> 0.1)
335+
webrick
335336

336337
BUNDLED WITH
337338
2.7.1

_config.yml

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
1-
# Welcome to Jekyll!
2-
#
3-
# This config file is meant for settings that affect your whole blog, values
4-
# which you are expected to set up once and rarely edit after that. If you find
5-
# yourself editing this file very often, consider using Jekyll's data files
6-
# feature for the data you need to update frequently.
7-
#
8-
# For technical reasons, this file is *NOT* reloaded automatically when you use
9-
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.
10-
#
11-
# If you need help with YAML syntax, here are some quick references for you:
12-
# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
13-
# https://learnxinyminutes.com/docs/yaml/
14-
#
15-
# Site settings
16-
# These are used to personalize your new site. If you look in the HTML files,
17-
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
18-
# You can create any custom variable you would like, and they will be accessible
19-
# in the templates via {{ site.myvariable }}.
20-
211
title: Developers
222
23-
description: >- # this means to ignore newlines until "baseurl:"
3+
description: >-
244
Developer documentation about all things Git-Mastery
25-
baseurl: "/developers" # the subpath of your site, e.g. /blog
26-
url: "https://git-mastery.github.io" # the base hostname & protocol for your site, e.g. http://example.com
5+
baseurl: "/developers"
6+
url: "https://git-mastery.github.io"
7+
permalink: pretty
8+
9+
mermaid:
10+
version: "9.1.6"
2711

28-
# Build settings
2912
theme: just-the-docs
3013
plugins:
3114
- jekyll-feed

_posts/2025-08-26-welcome-to-jekyll.markdown

Lines changed: 0 additions & 29 deletions
This file was deleted.

about.markdown

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Download Workflow
3+
parent: Architecture
4+
---
5+
6+
# Download workflow
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Exercise configuration structure
3+
parent: Architecture
4+
---
5+
6+
### `.gitmastery-exercise.json` configuration
7+
8+
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.
9+
10+
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:
11+
12+
- `exercise_name`: raw exercise name that will be indexed; recommended to use [kebab case](https://developer.mozilla.org/en-US/docs/Glossary/Kebab_case)
13+
- `tags`: used during indexing on the [exercise directory](https://git-mastery.github.io/exercises)
14+
- `requires_git`: performs a check to ensure that Git is installed and the user has already configured their `user.name` and `user.email`
15+
- `requires_github`: performs a check to ensure that Github CLI is installed and the user has already authenticated themselves
16+
- `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]())
17+
- `exercise_repo`: controls the sub-folder that is generated; this is where students work on the exercise
18+
- `repo_type`: `local` or `remote`; if `remote`, then the sub-folder is generated from a remote repository
19+
- `repo_name`: name of the sub-folder; required for both `repo_type`
20+
- `init`: determines if `git init` is run for the sub-folder; required only for `local`
21+
- `create_fork`: determines if a fork is created on the user's Github account; required only for `remote`
22+
- `repo_title`: name of the remote repository to fork + clone; required only for `remote`

docs/architecture/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Architecture
3+
nav_order: 4
4+
---

docs/contributing/exercise.md

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
title: Exercise
3+
parent: Contributing
4+
nav_order: 2
5+
---
6+
7+
# Contributing an exercise
8+
9+
## Before contributing
10+
11+
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+
17+
## Create a new exercise
18+
19+
Use the provided `new.sh` script to generate the scaffolding for a new exercise:
20+
21+
```bash
22+
./new.sh
23+
```
24+
25+
This script will prompt you for:
26+
27+
1. The name of the exercise -- likely to be specified in the corresponding exercise discussion
28+
2. The exercise tags (split by space) -- likely to be specified in the corresponding exercise discussion
29+
3. The exercise configuration (read the [`.gitmastery-exercise.json` configuration](#gitmastery-exercisejson-configuration) section for more info on this)
30+
31+
{: .note }
32+
33+
You should use kebab case for the exercise name.
34+
35+
It then generates the following directory structure:
36+
37+
```text
38+
<exercise name>
39+
├── .gitmastery-exercise.json
40+
├── README.md
41+
├── __init__.py
42+
├── download.py
43+
├── res
44+
│ └── ...
45+
├── tests
46+
│ ├── specs
47+
│ │ └── base.yml
48+
│ └── test_verify.py
49+
└── verify.py
50+
```
51+
52+
- `.gitmastery-exercise.json`: contains the exercise configuration; refer [here](/developers/docs/architecture/gitmastery-exercise-configuration/) for information about the configuration structure
53+
- `README.md`: contains the instructions for the exercise for the students to attempt
54+
- `download.py`: contains the download instructions to setup the student's exercise
55+
- `verify.py`: contains the verification script for the exercise attempt
56+
- `res/`: contains resources that are available to students (see this section about [types of resources](#types-of-resources))
57+
- `tests/specs/`: contains specification files written using [`repo-smith`](https://github.com/git-mastery/git-autograder)
58+
- `tests/test_verify.py`: contains unit tests for verification script
59+
60+
## Designing download process
61+
62+
The `download.py` contains the instructions to setup the local repository.
63+
64+
This is the sequence in which the Git-Mastery app downloads an exercise for a student:
65+
66+
```mermaid
67+
flowchart
68+
a[Download exercise] --> b[Create exercise folder]
69+
b --> c[Download base files to exercise root]
70+
c --> d[Check Git if toggled]
71+
d --> e[Check Github if toggled]
72+
e -- local --> f[Create local repo folder with repo_name]
73+
e -- remote --> g[Fork repository if toggled]
74+
g --> h[Clone repository with repo_name]
75+
f --> i[Download resources]
76+
h --> i
77+
i --> j[Create initial commit if init toggled]
78+
j --> k[Execute download function]
79+
```
80+
81+
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.
82+
83+
The default download script comes with a helper function to `run_command` to run local commands.
84+
85+
> [!NOTE]
86+
> You should be using OS-agnostic commands in the download script
87+
88+
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.
89+
90+
Refer to existing `download.py` for reference on how to setup the download script.
91+
92+
### What students see
93+
94+
When a student downloads an exercise, they will see the following folder structure:
95+
96+
```text
97+
<exercise name>
98+
├── .gitmastery-exercise.json
99+
├── README.md
100+
└── <sub folder name>
101+
├── .git
102+
└── ...
103+
```
104+
105+
The root of the exercise will contain the `README.md` and `.gitmastery-exercise.json` configured from your template.
106+
107+
It also contains the sub-folder configured in `.gitmastery-exercise.json`, which is where students will attempt the exercise.
108+
109+
### Types of resources
110+
111+
There are two distinct types of resources:
112+
113+
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
114+
115+
```text
116+
<exercise name>
117+
├── .gitmastery-exercise.json
118+
├── README.md
119+
├── <base files> <-- here
120+
└── <sub folder name>
121+
├── .git
122+
└── ...
123+
```
124+
125+
2. Resources: configured through the `__resources__` field in `download.py`; supporting files for the exercise with files located in `res/` downloaded into the sub folder
126+
127+
```text
128+
<exercise name>
129+
├── .gitmastery-exercise.json
130+
├── README.md
131+
├── <base files>
132+
└── <sub folder name>
133+
├── .git
134+
└── <resources> <-- here
135+
```
136+
137+
### Testing downloads
138+
139+
To test that your download script works, we have provided a script to simulate the download process in this repository for you to verify.
140+
141+
```bash
142+
./test-download.sh <your exercise folder>
143+
```
144+
145+
You can find the downloaded repository under the `test-downloads/` folder.
146+
147+
> [!NOTE]
148+
> 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
149+
150+
151+
## Designing verification process
152+
153+
The verification process is controlled by the `verify.py`:
154+
155+
```mermaid
156+
flowchart
157+
a[Verify exercise] --> b["Check if in exercise (using .gitmastery-exercise.json)"]
158+
b -- not in exercise --> c[Cancel]
159+
b -- in exercise --> d[Execute verification script on exercise folder]
160+
```
161+
162+
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 function with `git-autograder`, you can fall back to the underlying `Repo` object:
163+
164+
```python
165+
def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
166+
# Access the underlying GitPython repo:
167+
exercise.repo.repo
168+
169+
return exercise.to_output([], GitAutograderStatus.SUCCESSFUL)
170+
```
171+
172+
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.
173+
174+
### Testing verification
175+
176+
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.
177+
178+
Refer to existing `test_verify.py` to see examples of unit testing the verification script.
179+
180+
You can run the unit tests of your exercise via:
181+
182+
```bash
183+
./test.sh <your exercise folder>
184+
```
185+
186+
## Submitting the exercise for review
187+
188+
Create a pull request from your fork using the provided pull request template.
189+
190+
Fill in all of the details necessary.

0 commit comments

Comments
 (0)