Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continuous integration for student assignments

Ok, so this might sound a bit weird but here it goes.

I am teaching a data structures and algorithms lab at my local university and want to give my students a every fluid and fun experience. Up until now, I used a simple git repository which every student forked, and whenever they completed an assignment, they made a push + pull request, I would review their code and if everything was OK, I would merge the pull request into the main repo. This works pretty well, but I want to do something more interesting.

The lab is being taught in C (not even C++) (and no, I don't want to enter any polemics on why another language would be better). What I want to do is have something like a Jenkins build run on every push a pupil makes which verifies some predefined tests for the task at hand.

For example, for week 2, I would give them a homework assignment with lists. I would like to write the tests for this homework myself and then automatically verify what they did using those tests.

What I have available:

  • 24/7 running CentOS machine which I can use to put anything on (I have Jenkins and Tomcat running on it atm)
  • enough time and willpower to try to make their experience in this lab well worth the while

++ a very nice 'add-on' to all this would be to use something like sonar as a code verifier AND check for duplicated code within their branches (as to see if anyone copied an answer from someone else)

Am I on the right track by going for a Jenkins server, thinking about sonar etc? Am I way off? I don't think this is impossible. It might be difficult, yes, but that makes it fun ^^

The 'flow' that I want is:

  • each student is part of a git organization + repo
  • they create a branch from the local master (I will impose a restriction like 'only use a subfolder with your name')
  • the master branch will contain the tests
  • they will work on their homework on their branch and then push it to Jenkins / Gerrit / whatever
  • the branch will somehow be tested and if all tests pass, it will be merged with the master.

On behalf of my dear students, thank you.

like image 321
Alexandr Avatar asked Feb 08 '15 04:02

Alexandr


1 Answers

TL;DR: yes, what you want to do it feasible, and you're already looking at the correct tools.


What you want seems totally feasible: install the Git plugin for Jenkins, configure it to track each branches of the repo, and it's already possible to launch a build after each push.

Since you can execute arbitrary scripts during a Jenkins build, you can give push permissions to the Jenkins user, and have it merge and push the code if all tests pass.

You can then also install a sonar server, and call it through the Sonar plugin, and your students will get this additional feedback.

On the other hand, Gerrit might be a little overkill for what you're looking for. Or rather: it's a valuable tool, but I believe you don't need it for the first iteration.

I can think of two types of difficulties:

  1. Scripting / Corner cases
  2. Whether you want to prevent student from gaming the system

For (1), I mean that you'll need to implement your rules (for example "only build the subfolder which belong to the last commiter" ; "don't build merge commits on master" ; ...). And you'll likely run into issues such that:

  • You don't want a new Jenkins run on a merge commit just pushed by a Jenkins job, so you'll have to take it into account in your build script
  • What if you want to allow several Jenkins run at the same time, and two runs tries to merge and push at the same time

I guess you'll just need to fix those glitches as you'll discover them. Just think about creating backups of your Jenkins config (you might as well store them in an ad hoc git repo).

For (2), I mean that you might want to take into account, for example, the case where a student would delete from the repo the tests his implementation can't pass. Or the case of the student who would directly push on master.

I believe you could add lot of checks to prevent this kind of cheating, however, rather than entering into a "technological conflict", I guess it would be more healthy to just tell them you trust them.

like image 99
gturri Avatar answered Oct 13 '22 04:10

gturri