Travis build pipeline

I've been working on the Travis build pipeline for cyber-dojo. The biggest gotcha I hit was that a failure in an after_success: section of a .travis.yml file does not fail the build. This was an issue because after successfully building and testing a docker image I wanted to do two things (and know if they failed):
  • push the docker image to dockerhub
  • trigger git repos dependent on the docker image so they in turn run their .travis.yml files.
I solved this by doing both steps at the end of the .travis.yml script: section.

... language: node_js script: - ... - curl -O https://raw.githubusercontent.com/cyber-dojo/ruby/master/push.sh - chmod +x push.sh - ./push.sh - npm install travis-ci - curl -O https://raw.githubusercontent.com/cyber-dojo/ruby/master/trigger-build.js - node trigger-build.js [DEPENDENT-REPO...]


push.sh looks like this:

#!/bin/bash set -e if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then BRANCH=${TRAVIS_BRANCH} else BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} fi if [ "${BRANCH}" == "master" ]; then docker login --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}" TAG_NAME=$(basename ${TRAVIS_REPO_SLUG}) docker push cyberdojo/${TAG_NAME} fi


trigger-build.js looks like this:

var Travis = require('travis-ci'); var travis = new Travis({ version: '2.0.0', headers: { 'User-Agent': 'Travis/1.0' } }); var exit = function(call,error,response) { console.error('ERROR:travis.' + call + 'function(error,response) { ...'); console.error(' error:' + error); console.error('response:' + JSON.stringify(response, null, '\t')); process.exit(1); }; travis.authenticate({ github_token: process.env.GITHUB_TOKEN }, function(error,response) { var repos = process.argv.slice(2); if (error) { exit('authenticate({...}, ', error, response); } repos.forEach(function(repo) { var parts = repo.split('/'); var name = parts[0]; var tag = parts[1]; travis.repos(name, tag).builds.get(function(error,response) { if (error) { exit('repos(' + name + ',' + tag + ').builds.get(', error, response); } travis.requests.post({ build_id: response.builds[0].id }, function(error,response) { if (error) { exit('requests.post({...}, ', error, response); } console.log(repo + ':' + response.flash[0].notice); }); }); }); });

Note the [set -e] in push.sh and the [process.exit(1)] in trigger-build.js
Hope this proves useful!

Python + behave

A big thank you to Millard Ellingsworth @millard3 who has added Python+behave to cyber-dojo.





Woohoo :-)

cyber-dojo Raspberry Pies in action



Liam Friel, who helps to run a CoderDojoBray (in Ireland) asked me for some Raspberry Pies which I was more than happy to give him, paid for from the donations lots of you generous people have made from cyber-dojo.

Liam sent me this wonderful photo of a CoderDojoBray session and writes:

Your Pies have been getting a lot of use... We've got 8 Pies in total. Got a reasonably steady turnout at the dojo, 75-85 kids turning up each week.

Awesome. If, like Liam, you would like some Raspberry Pies to help kids learn about coding, please email. Thanks

running your own cyber-dojo server on Windows

install Docker-Toolbox for Windows

From here.


open a Docker-Quickstart-Terminal



install the cyber-dojo shell script

In the Docker-Quickstart-Terminal, type:
$ curl -O https://raw.githubusercontent.com/cyber-dojo/commander/master/cyber-dojo $ chmod +x cyber-dojo


bring up your cyber-dojo server

In the Docker-Quickstart-Terminal, type:
$ ./cyber-dojo up
The first time you run this it will download the necessary docker images for your server.
This may take several minutes depending on your network connection.


access the server via a browser

To find your server's IP address, in the Docker-Quickstart-Terminal, type:
$ docker-machine ip default
Put your server's IP address (eg 192.168.99.100) into your browser's address bar.
That's it!
This works in Chrome, in Firefox, in Opera, and in Internet Explorer. Edge sometimes has problems.


pre-pull an individual language+test image?

The first time you setup a practice-session for a given language and test framework (eg C#, NUnit) the server will pull its docker image. This can take a few minutes depending on your network connection. You can pre-pull images to avoid this delay.
To display all the language+test image names, in the Docker-Quickstart-Terminal, type:
$ ./cyber-dojo start-point inspect languages
For example:
MAJOR_NAME MINOR_NAME IMAGE_NAME PULLED? Asm assert cyberdojofoundation/nasm_assert no BCPL all_tests_passed cyberdojofoundation/bcpl_all_tests_passed no Bash bash_unit cyberdojofoundation/bash_unit no Bash shunit2 cyberdojofoundation/bash_shunit2 no C (clang) Cgreen cyberdojofoundation/clang_cgreen no C (clang) assert cyberdojofoundation/clang_assert no C (gcc) Cgreen cyberdojofoundation/gcc_cgreen no C (gcc) CppUTest cyberdojofoundation/gcc_cpputest no C (gcc) Unity cyberdojofoundation/gcc_unity no C (gcc) assert cyberdojofoundation/gcc_assert no C# Moq cyberdojofoundation/csharp_moq no C# NUnit cyberdojofoundation/csharp_nunit no C# SpecFlow cyberdojofoundation/csharp_specflow no C++ (clang++) Cgreen cyberdojofoundation/clangpp_cgreen no C++ (clang++) GoogleMock cyberdojofoundation/clangpp_googlemock no C++ (clang++) GoogleTest cyberdojofoundation/clangpp_googletest no ...
Then pull your chosen image name. For example, in the Docker-Quickstart-Terminal, type:
$ docker pull cyberdojofoundation/csharp_nunit


pre-pull all the language+test images?

This will take a while. In the Docker-Quickstart-Terminal, type:
$ ./cyber-dojo start-point pull languages


bring down your cyber-dojo server

In the Docker-Quickstart-Terminal, type:
$ ./cyber-dojo down


running your own cyber-dojo server on a Mac

install Docker-Toolbox for Mac

From here.


open a Docker-Quickstart-Terminal



install the cyber-dojo shell script

In the Docker-Quickstart-Terminal, type:
$ curl -O https://raw.githubusercontent.com/cyber-dojo/commander/master/cyber-dojo $ chmod +x cyber-dojo


bring up your cyber-dojo server

In the Docker-Quickstart-Terminal, type:
$ ./cyber-dojo up
The first time you run this it will download the necessary docker images for your server.
This may take several minutes depending on your network connection.


access the server via a browser

To find your server's IP address, in the Docker-Quickstart-Terminal, type:
$ docker-machine ip default
Put your server's IP address (eg 192.168.99.100) into your browser's address bar.
That's it!



pre-pull an individual language+test image?

The first time you setup a practice-session for a given language and test framework (eg C#, NUnit) the server will pull its docker image. This can take a few minutes depending on your network connection. You can pre-pull images to avoid this delay.
To display all the language+test image names, in the Docker-Quickstart-Terminal, type:
$ ./cyber-dojo start-point inspect languages
For example:
MAJOR_NAME MINOR_NAME IMAGE_NAME PULLED? Asm assert cyberdojofoundation/nasm_assert no BCPL all_tests_passed cyberdojofoundation/bcpl_all_tests_passed no Bash bash_unit cyberdojofoundation/bash_unit no Bash shunit2 cyberdojofoundation/bash_shunit2 no C (clang) Cgreen cyberdojofoundation/clang_cgreen no C (clang) assert cyberdojofoundation/clang_assert no C (gcc) Cgreen cyberdojofoundation/gcc_cgreen no C (gcc) CppUTest cyberdojofoundation/gcc_cpputest no C (gcc) Unity cyberdojofoundation/gcc_unity no C (gcc) assert cyberdojofoundation/gcc_assert no C# Moq cyberdojofoundation/csharp_moq no C# NUnit cyberdojofoundation/csharp_nunit no C# SpecFlow cyberdojofoundation/csharp_specflow no C++ (clang++) Cgreen cyberdojofoundation/clangpp_cgreen no C++ (clang++) GoogleMock cyberdojofoundation/clangpp_googlemock no C++ (clang++) GoogleTest cyberdojofoundation/clangpp_googletest no ...
Then pull your chosen image name. For example, in the Docker-Quickstart-Terminal, type:
$ docker pull cyberdojofoundation/csharp_nunit


pre-pull all the language+test images?

This will take a while. In the Docker-Quickstart-Terminal, type:
$ ./cyber-dojo start-point pull languages


bring down your cyber-dojo server

In the Docker-Quickstart-Terminal, type:
$ ./cyber-dojo down


running your own cyber-dojo server on Linux

install docker

There are two ways to do this:
  • Follow the instructions on the docker website.
  • Either curl or wget the quick-and-easy install script at https://get.docker.com
    $ curl -sSL https://get.docker.com/ | sh $ wget -qO- https://get.docker.com/ | sh
Be sure to add your user to the docker group.


install the cyber-dojo shell script

In a terminal, type:
$ curl -O https://raw.githubusercontent.com/cyber-dojo/commander/master/cyber-dojo $ chmod +x cyber-dojo


bring up your cyber-dojo server

In a terminal, type:
$ ./cyber-dojo up
The first time you run this it will download the necessary docker images for your server.
Put your server's IP address into your browser.
That's it!



pre-pull an individual language+test image?

The first time you setup a practice-session for a given language and test framework (eg C#, NUnit) the server will pull its docker image. This can take a few minutes depending on your network connection. You can pre-pull images to avoid this delay.
To display all the language+test image names, in a terminal, type:
$ ./cyber-dojo start-point inspect languages
For example:
MAJOR_NAME MINOR_NAME IMAGE_NAME PULLED? Asm assert cyberdojofoundation/nasm_assert no BCPL all_tests_passed cyberdojofoundation/bcpl_all_tests_passed no Bash bash_unit cyberdojofoundation/bash_unit no Bash shunit2 cyberdojofoundation/bash_shunit2 no C (clang) Cgreen cyberdojofoundation/clang_cgreen no C (clang) assert cyberdojofoundation/clang_assert no C (gcc) Cgreen cyberdojofoundation/gcc_cgreen no C (gcc) CppUTest cyberdojofoundation/gcc_cpputest no C (gcc) Unity cyberdojofoundation/gcc_unity no C (gcc) assert cyberdojofoundation/gcc_assert no C# Moq cyberdojofoundation/csharp_moq no C# NUnit cyberdojofoundation/csharp_nunit no C# SpecFlow cyberdojofoundation/csharp_specflow no C++ (clang++) Cgreen cyberdojofoundation/clangpp_cgreen no C++ (clang++) GoogleMock cyberdojofoundation/clangpp_googlemock no C++ (clang++) GoogleTest cyberdojofoundation/clangpp_googletest no ...
Then pull your chosen image name. For example, in a terminal, type:
$ docker pull cyberdojofoundation/csharp_nunit


pre-pull all the language+test images?

This will take a while. In a terminal, type:
$ ./cyber-dojo start-point pull languages


bring down your cyber-dojo server

In a terminal, type:
$ ./cyber-dojo down


tar-piping a dir in/out of a docker container

The bottom of the docker cp web page has some examples of tar-piping into and out of a running container. I couldn't get them to work. I guess there are different varieties of tar. The following is what worked for me. It assumes
  • ${container} is the name of the container
  • ${src_dir} is the source dir
  • ${dst_dir} is the destination dir

copying a dir out of a running container

sudo docker exec ${container} tar -c -f - -C $(dirname ${src_dir}) $(basename ${src_dir}) | tar -x -f - -C ${dst_dir}

copying a dir into a running container

tar -c -f - -C $(dirname ${src_dir}) $(basename ${src_dir}) | sudo docker exec -i ${container} tar -x -f - -C ${dst_dir}

Hope this proves useful!