Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/NewLanguage.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ environment variables, they are not and simple find and replace is performed
before the command is executed.
- `${SOURCE_FILE}` - Path to a source file which contains the users code from
the payload. The file is not in current PWD and is read-only.
- ${SOURCE_ARGS}` - Command line arguments to the users code.
- `${SOURCE_ARGS}` - Command line arguments to the users code.
- `${EXECUTOR}` - The executor in the payload.
- `${EXECUTOR_ARGS}` - Arguments to the executor (for example to run `python3`
with some additional flag).
- `${COMPILER}` and ${COMPILER_ARGS} - Same meaning as executor, but for
- `${COMPILER}` and `${COMPILER_ARGS}` - Same meaning as executor, but for
`compiler`.

Configs are located in `/evaluator/config/config.yaml`.
Expand Down
1 change: 1 addition & 0 deletions evaluator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ RUN apt-get install -y \
ghc \
build-essential \
python3 \
nodejs \
racket

COPY --from=builder /rust/app/target/release/evaluator bin/evaluator
Expand Down
7 changes: 7 additions & 0 deletions evaluator/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
- rm source.c
- ./a.out

- name: js
executors:
- name: nodejs-bookworm
path: /usr/bin/node
commands:
- "${EXECUTOR} ${EXECUTOR_ARGS} ${SOURCE_FILE} ${SOURCE_ARGS}"

- name: lua
executors:
- name: lua5.4.6
Expand Down
2 changes: 1 addition & 1 deletion evaluator/infra/languages/lua/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ setup_lua_version() {
pushd lua-${LUA_VERSION}
make linux
mkdir -p /opt/evaluator/compilers/lua/
cp src/lua /opt/evaluator/compilers/lua/lua${LUA_VERSION}
cp src/lua "/opt/evaluator/compilers/lua/lua${LUA_VERSION}"
popd
}

Expand Down
16 changes: 16 additions & 0 deletions integration_tests/evaluator_tests/test_js.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import requests

EVALUATOR_ADDRESS = "http://evaluator:7800/api/v1/evaluate"

def generate_python(code: str):
return {"language": "js", "code": code, "executor": "nodejs-bookworm"}

def test_simple_python():
payload = generate_python("""
console.log("Hello, World!");
""")
response = requests.post(EVALUATOR_ADDRESS, json=payload)
assert response.status_code == 200
values = response.json()
assert values["stdout"] == "Hello, World!\n"
assert values["stderr"] == ""
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "website",
"version": "0.0.1",
"private": true,
"packageManager": "pnpm@9.15.9",
"scripts": {
"dev": "vite dev",
"build": "vite build",
Expand Down
7 changes: 7 additions & 0 deletions website/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ export const languages: { [key in LangKey]: ILanguage } = {
text: 'Lua',
executors: ['lua5.4.6', 'lua5.3.6', 'lua5.2.4', 'lua5.1.5']
},
js: {
name: 'js',
server_name: 'js',
editor_name: 'javascript',
text: 'Javascript',
executors: ['nodejs-bookworm']
},
python3: {
name: 'python3',
server_name: 'python3',
Expand Down
11 changes: 11 additions & 0 deletions website/src/lib/defaultPrograms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ export const defaultPrograms: IPrograms = {
'',
'print(fact(5))'
].join('\n'),
javascript: [
'function fact(n) {',
' if (n === 0) {',
' return 1;',
' } else {',
' return n * fact(n - 1);',
' }',
'}',
'',
'console.log(fact(5));'
].join('\n'),
scheme: [
'#lang racket',
'',
Expand Down
1 change: 1 addition & 0 deletions website/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type LinkData = {

export type LangKey =
| 'lua'
| 'js'
| 'python3'
| 'racket'
| 'bash'
Expand Down