I’ve been using GitHub Classroom this year with all of my classes. It started out just testing it in my upper-level courses, but I ended up liking it so much that I’m using it with my intro classes as well. If you’re teaching programming, it’s definitely worth a look.
It’s a quick and easy way to hand out starter code and have students turn in their work. With a couple of clicks, I can download all the assignments.
But I also like unit testing, and with most of my classes that’s JUnit. I’m a big proponent of instant feedback and including unit tests with assignments lets students keep testing their code until it works. They don’t have to ask me if it’s right, which frees me up to help rather than spot check during class.
In playing around with GitHub Classroom I found that Travis-CI interacts with GitHub repos and can run JUnit tests as code is pushed. Seemed like a perfect tool.
Paid vs. Free
At least I thought so. Turns out if you’re a GitHub Education user you can apply to get a free Travis-CI.com account tied to your GitHub organization. The education tier only allows for one task to run at a time, but that’s plenty unless you’ve got a really big class.
Now I include a
.travis.yml file in each project and can tell immediately if it builds. And if I include unit tests it will run those as well.
Next step was to figure out a way to easily check build status. When a GitHub repo is linked with Travis a little green checkbox shows up next to commits that build successfully and a red x appears if it doesn’t build. But that was a little tedious to go through each commit.
Normally when you look at an assignment in GitHub classroom you have a student list with links to their repos. It looks like this.
Each of the buttons takes you to the repo for that student. If you could see more to the left on that image you’d see student names, but I cropped them out.
The buttons make it easier than going repo to repo in GitHub, but it still doesn’t tell you much about the status of the project.
I’ve known about Tapermonkey for a while but never had a reason to play around with it. A script to add build status badges seemed like the perfect excuse to play.
What the script does is go through each button and builds the HTML for the status badge for the repository and appends it below the View Repository button. After running it looks like this.
Now I can immediately tell if their code builds and passes any tests that I’ve thrown at them.
This is the Taper Monkey script that adds the badges.
Only thing you should have to do after adding this script to Tapermonkey is to add your Travis-CI token. Apparently you can’t get the badge for a private repo without a token.
If you’re using public repos you may be able to edit it so that it doesn’t need a token, but I haven’t tried since we use private repositories for everything. If you’re fully public you could also probably use the free Travis-CI.org instead of Travis-CI.com.
There is one minor issue, and it has to do with Ajax.
The pages in Classroom are built with Ajax calls which normally doesn’t trigger Tapermonkey. I added a dependency called waitForKeyElements which usually takes care of adding the buttons after Ajax does its thing, but it doesn’t always work. When it doesn’t work hitting refresh takes care of it.
Want to stay in touch and keep up to date with the latest posts @ CompSci.rocks?