Configuring Basalt
The configuration of basalt is written using toml.
This configuration is used by the basalt-cli and the basalt-server
to host a competition.
The configuration is broken up into four main sections:
Example
Section titled “Example”An example configuration is shown below.
# Host competition on port 1234port = 1234
# Setup configuration[setup]# Install `opam` packageinstall = '''apt-get install opam'''
# Initialise opam so we can run ocamlinit = '''opam init -yeval $(opam env)'''
# Language configuration[languages]# Enable python3 defaultpython3 = "*"# Enable built-in Java 21java = "21"# Add custom `ocaml` language type[languges.ocaml]build = "ocamlc -o out solution.ml"run = "./out"source_file = "solution.ml"
# Account configurations[[accounts.admins]]name = "Host"password = "HostP@ssword1"
[[accounts.competitors]]name = "Team1"password = "Team1P@ssword"
[[accounts.competitors]]name = "Team2"password = "Team2P@ssword"
# packet configuration[packet]title = "Example Packet"preamble = '''This packet includes problems of a difficulty *vastly*surpassing the capabilities of the average computerscience student. Be wary as these problems willcertainly give you great intellectual trouble. Thereis little hope for anyone without a Ph.D in computerscience.
If you decide to attempt these problems anyways, goodluck. You will be rewarded for swiftness in your answers.'''
# Add a problem to this packet that requires the competitor to reverse a# string[[packet.problems]]title = "Reversing a string"description = '''Reversing a string is one of the most _basic_ algorithmicproblems for a beginner computer science student to solve.
Solve it.'''
# Simple "hello" -> "olleh" test# Since this is the first test that is visible, it will be shown as the# example to the user.[[packet.problems.tests]]input = "hello"output = "olleh"visible = true
[[packet.problems.tests]]input = "world"output = "dlrow"visible = true
# Test that is not visible, and thus will not show the input or expected# output to the competitor.# This test is still used for scoring the competitor's solution.[[packet.problems.tests]]input = ""output = ""
[[packet.problems.tests]]input = "aa"output = "aa"
[[packet.problems.tests]]input = "racecar"output = "racecar"Imports
Section titled “Imports”Because these configuration files can easily become out of hand, we
offer the ability to import sections of the file using import.
This example shows many sections broken into their own files. Of course, if only want to take certain sections out, you may.
# In config.toml
port = 1234 # Host competition on port 1234
setup = { import = "./setup.toml" }languages = { import = "./languages.toml" }accounts = { import = "./accounts.toml" }packet = { import = "./packet.toml" }# In setup.toml
# Install `opam` packageinstall = '''dnf install -y opam'''
# Initialise opam so we can run ocamlinit = '''opam init -yeval $(opam env)'''# In languages.toml
python3 = "*" # Enable python3 defaultjava = "21" # Enable built-in Java 21
[ocaml] # Add custom `ocaml` language typebuild = "ocamlc -o out {{SOURCEFILE}}"run = "./out"# In accounts.toml[[admins]]name = "Host"password = "HostP@ssword1"
[[competitors]]name = "Team1"password = "Team1P@ssword"
[[competitors]]name = "Team2"password = "Team2P@ssword"# In packet.tomltitle = "Example Packet"preamble = '''This packet includes problems of a difficulty *vastly*surpassing the capabilities of the average computerscience student. Be wary as these problems willcertainly give you great intellectual trouble. Thereis little hope for anyone without a Ph.D in computerscience.
If you decide to attempt these problems anyways, goodluck. You will be rewarded for swiftness in your answers.'''
problems = [{ import = "./problem1.toml" }]# In problem1.tomltitle = "Reversing a string"description = '''Reversing a string is one of the most _basic_ algorithmicproblems for a beginner computer science student to solve.
Solve it.'''
# Simple "hello" -> "olleh" test# Since this is the first test that is visible, it will be shown as the# example to the user.[[tests]]input = "hello"output = "olleh"visible = true
[[tests]]input = "world"output = "dlrow"visible = true
# Test that is not visible, and thus will not show the input or expected# output to the competitor.# This test is still used for scoring the competitor's solution.[[tests]]input = ""output = ""
[[tests]]input = "aa"output = "aa"
[[tests]]input = "racecar"output = "racecar"