It will be updated properly soon.
Meanwhile, follow step 0 below, and then look at these examples from the cyber-dojo-languages github organization:
- repo for a docker-image for a language
- repo for a docker-image for a test-framework
0. Install docker
1. Create a docker-image for just the language
Make this docker-image unit-test-framework agnostic.If you are adding a new unit-test-framework to an existing language skip this step.
For example, suppose you were building Lisp
-
Create a new folder for your language
eg.$ md lisp -
In your language's folder, create a file called Dockerfile
$ cd Lisp $ touch DockerfileIf you can, base your new image on Alpine-linux as this will help keep images small. To do this make the first line of Dockerfile as followsFROM cyberdojofoundation/language-baseHere's one based on Alpine-linux (217 MB: C#) Dockerfile
Here's one not based on Alpine (Ubuntu 1.26 GB: Python) Dockerfile -
Use the
Dockerfile
to build a docker-image for your language.
For example$ docker build -t cyberdojofoundation/lisp .which, if it completes, creates a new docker-image calledcyberdojofoundation/lisp
using theDockerfile
(and build context) in.
(the current folder).
2. Create a docker-image for the language and test-framework
Repeat the same process, buildingFROM
the docker-image
you created in the previous step.For example, suppose your Lisp unit-test framework is called lunit
-
Create a new folder underneath your language folder
$ cd lisp $ md lunit
-
In your new test folder, create a file called
Dockerfile
$ cd lunit $ touch DockerfileThe first line of this file must name the language docker-image you built in the previous step.
Add lines for all the commands needed to install your unit-test framework...FROM cyberdojofoundation/lisp RUN apt-get install -y lispy-lunit RUN apt-get install -y ... -
Create a file called red_amber_green.rb
$ touch red_amber_green.rb
- In red_amber_green.rb write a Ruby lambda accepting three arguments.
For example, here is the
C#-NUnit red_amber_green.rb:
lambda { |stdout,stderr,status| output = stdout + stderr return :red if /^Errors and Failures:/.match(output) return :green if /^Tests run: (\d+), Errors: 0, Failures: 0/.match(output) return :amber }cyber-dojo uses this to determine the test's traffic-light colour by passing it the stdout, stderr, and status outcomes of the test run.
-
The Dockerfile for your language+testFramework must COPY red_amber_green.rb
into the /usr/local/bin folder of your image. For example:
FROM cyberdojofoundation/lisp RUN apt-get install -y lispy-lunit RUN apt-get install -y ... COPY red_amber_green.rb /usr/local/binI usually start with a red_amber_green.rb that simply returns :red. Then, once I have a start-point using the language+testFramework docker-image, I use cyber-dojo to gather outputs which I use to build up a working red_amber_green.rb
-
Use the
Dockerfile
to try and build your language+testFramework docker-image.
The name of an image takes the form hub-name/image-name. Do not include a version number in the image-name. For example$ docker build -t cyberdojofoundation/lisp_lunit .which, if it completes, creates a new docker image calledcyberdojofoundation/lisp_lunit
using theDockerfile
in.
(the current folder).
No comments:
Post a Comment