Script to test students' solutions with manytask integration
Key features:
- git changes detection
- extension for different languages
- sandbox execution
- manytask integration
Please refer to the manytask documentation first to understand the drill
The checker
lib is a relatively small cli script aiming to run tests in gitlab runner and push results to manytask
.
The full checker
and manytask
setup roughly looks as follows
- self-hosted
gitlab
instance - storing repos with assignments and students' repo- private repo - a repository with tasks, public and private tests, gold solutions, ect.
- public repo - a repository available to students with tasks and solution templates
- students' group - the group where
manytask
will create repositories for students
each students' repo - fork from public repo
gitlab runners
- place where students' solutions likely to be testedchecker
script - some script to test students' solutions and push scores/grades to themanytask
manytask
instance - web application managing students' grades (in google sheet) and deadlines (web page)
The flow for checking students' solution looks like:
- Student push his solution to a gitlab repo
- gitlab-ci runs separate docker in gitlab-runner
- gitlab-ci runs this script with some parameters
- the script detect the latest changes (via git) and select tasks to check
- the tasks forwarded to
tester
and it returns obtained scores - the script push student scores to the manytask
(additionally script can check ground-truth solutions, export new tasks etc)
- manytask web app Currently, this lib is integrated with manytask only, so you need it to be set up first, see installation instructions in manytask repo.
- gitlab with access to greate groups, users and add runners
This pre-requirement for manytask; See manytask installation instructions for more info - Created and tested tester for your course/language
Obtain service keys for this script to operate
- manytask tester token you set up when run it
- gitlab service user to operate with your repositories
(better to create a new one)
Create gitlab repositories layout
- Create private repository with tasks, public and private tests and ground-truth solution;
Choose one of the suitable layouts (see driver.py)
Grant access to your service account - Create public empty repository
Grant access to your service account - Create private (!) group for students repositories
(You have already done it if you set up manytask)
Grant access to your service account
Edit config files in repository
.course.yml
- main endpoints config
(see .course.yml example).deadlines.yml
- task deadlines (see .deadlines.yml example).gitlab-ci.yml
- set up gitlab ci pipeline to test students tasks.releaser-ci.yml
- set up gitlab ci pipeline to test new added tasks and build dockers
Setup dockers with env ready for testing, it's convenient to have 2 dockers:
base.docker
- base docker to build and test students solutions, install lib heretestenv.docker
- docker on top of base docker, to save tasks and tests
-
CourseConfig
Manage course configuration. Wrapper around.course.yml
file. -
CourseSchedule
Manage course deadlines. Wrapper around.deadlines.yml
file. -
CourseDriver
Manage mapping of the Course to the Filesystem. (e.g. map Task to folders with tests and source files)
Available layouts are (see driver.py):flat
- all tasks in root folder of the repogroups
- each group has its own folder
-
Executor is object to run commands with some isolation level.
Available modes are:sandbox
- separate process (clean env variables, nouser/nogroup, disabled network)docker
- TODO
-
Tester is object which can test single task: copy files, build, test it, cleanup.
Tester is extendable for each course/language. Now available:python
Create venv
python -m venv .venv
source .venv/bin/activate
Install lib in dev mode
(.venv)$ pip install -U --editable .[test] # .\[test\] in zsh
pytest . --cpp --python
ruff checker
mypy checker
isort --check .
In order to add a new language to the test system you need to make a pull request.
- Add a new tester in checker/testers
(see python.py as example) - Update tester.py
create
method to run your tester - Write tests for a new tester in ./tests/testers