Continuous integration for student assignments
Asked Answered
W

2

10

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.

Winded answered 8/2, 2015 at 4:10 Comment(5)
I wish I had teachers like that...Kenweigh
You are on right track for jenkins. About duplication checking, I am not sure if you can do that with Sonar.Kenweigh
Thumbs up on initiative! The chosen tools are right for this. Flow is also good.Indus
How about also taking a look at Travis CI instead of Jenkins? It has the advantage of being somewhat easier to tie in to GitHub, but the downside that you don't have as much granular control over the settings compared to a self-hosted Jenkins install.Barker
Thank you Serban, the problem is not tying it with GitHub. I already managed to do that with Jenkins, no problemoWinded
C
3

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.

Commingle answered 8/2, 2015 at 9:6 Comment(1)
Thank you for this. I have gone through the "github education classroom guide" ( education.github.com/guide ) and what surprised me is that it's exactly what I did last semester (main repo, fork, pull request etc) I found something cute meanwhile, some plugin for Jenkins which makes it intercept git pull requests. I will investigate this as it solves the problem with "don't push on master!"Winded
P
0

Take a look at https://classroom.github.com/ Automate your course and focus on teaching

Perusal answered 10/5, 2020 at 10:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.