cyber-dojo start-points manifest.json entries explained

Example: the manifest.json file for Java/JUnit looks like this:

{ "image_name": "ghcr.io/cyber-dojo-languages/java_junit:7aa5992", "display_name": "Java 25.0.2, JUnit 6.0.3", "visible_filenames": [ "Hiker.java", "HikerTest.java", "cyber-dojo.sh" ], "rag_lambda": "red_amber_green.rb", "filename_extension": [ ".java" ], "max_seconds": 10, "tab_size": 4, "progress_regexs" : [ "Tests run\\: (\\d)+,(\\s)+Failures\\: (\\d)+", "OK \\((\\d)+ test(s)?\\)" ] }


Required entries


"image_name": string

The name of the docker image used to run a container in which cyber-dojo.sh is executed. Do not include any version numbers (eg of the compiler or test-framework). All packages/tools/libraries/files/etc used in cyber-dojo.sh (for example the java compiler) must be installed in this image. When cyber-dojo.sh runs inside this image it has no access to the internet.


"display_name": string

The name as it appears in the start-point setup pages. For example, "Java 25.0.2, JUnit 6.0.3" means that "Java 25.0.2, JUnit 6.0.3" will appear as a selectable entry when choosing your language + test-framework when setting up your practice session. A single string typically with the language name first, then a comma, then the test-framework name.


"visible_filenames": [ string, string, ... ]

Filenames that will be visible in the browser's editor when an animal initially enter's a cyber-dojo. Each of these files must be a plain text file and exist in the manifest.json's directory. Filenames can be in nested sub-directories, eg "tests/HikerTest.java". Must include "cyber-dojo.sh". This is because cyber-dojo.sh is the name of the shell file assumed by the runner to be the start point for running the tests. You can write any actions inside cyber-dojo.sh but clearly any programs it tries to run must be installed in the docker image_name. For example, if cyber-dojo.sh runs gcc to compile C files then gcc has to be installed. If cyber-dojo.sh runs javac to compile java files then javac has to be installed.


"rag_lambda": string

The filename containing a Ruby lambda returning a test's traffic-light colour (red, amber, or green) from the stdout, stderr, status of cyber-dojo.sh. For example, here's the one for Java-JUnit.

lambda { |stdout,stderr,status| output = stdout + stderr containers_pattern = Regexp.new('^\[\s+(\d+) containers failed\s+\]') if match = containers_pattern.match(output) if match[1] != '0' return :amber end end tests_pattern = Regexp.new('^\[\s+(\d+) tests failed\s+\]') if match = tests_pattern.match(output) if match[1] == '0' return :green else return :red end else return :amber end }


The lambda can return red, amber, or green as a :symbol or a string. It should return:
  • green if the tests all passed
  • red if a test assertion fails
  • amber if there is a "non-assertion" error, eg a syntax error. This is usually straightforward for statically typed languages such as C. For dynamically typed languages such as Python it can be less straightforward - do what seems sensible.



"filename_extension": [ string, string, ... ]

The extensions of source files. The first entry is also used when creating a new filename. Must be non-empty.


"tab_size": int

The number of spaces a tab character expands to in the editor. Must be an integer between 1 and 12.


Optional entries


"progress_regexs": [ string, string ]

Used on the dashboard to show the test output line (which often contains the number of passing and failing tests) of each animal's most recent red/green traffic light. Useful when your practice session starts from a large number of pre-written tests and you wish to monitor the progress of each animal.
An array of two strings used to create Ruby regexs. The first one to match a red traffic light's test output, and the second one to match a green traffic light's test output.
An example for Python, unittest.
Defaults to [ ].


"highlight_filenames": [ string, string, ... ]

Filenames whose appearance is highlighted in the browser. This can be useful if you have many "visible_filenames" and want to mark which files form the focus of the practice.
An array of strings. A strict subset of "visible_filenames".
Defaults to [ ].


"hidden_filenames": [ string, string, ... ]

cyber-dojo.sh may create extra files (eg profiling stats). All text-files created under /sandbox are returned to the browser unless their name matches any of these string regexs.
An array of strings used to create Ruby regexs, used by cyber-dojo, like this Regexp.new(string). For example, to hide files ending in .d you can use the following string ".*\\.d"
Defaults to [ ].
DEPRECATED. Instead, inside cyber-dojo.sh, use a trap handler to delete unwanted files. For example here's a trap handler for Ruby, Approval.


"max_seconds": int

The maximum number of seconds cyber-dojo.sh has to complete.
An integer between 1 and 20.
Defaults to 10.
DEPRECATED.

No comments:

Post a Comment