Skip to content

Commit c7bcc7f

Browse files
authored
Merge pull request #476 from Brikaa/fix-v2-endpoint
Fix runtime finding in v2 endpoint
2 parents e767a6e + a664cd4 commit c7bcc7f

5 files changed

Lines changed: 33 additions & 5 deletions

File tree

api/src/api/v2.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const SIGNALS = [
5050
function get_job(job_info, available_runtimes) {
5151
let {
5252
language,
53+
version,
5354
args,
5455
stdin,
5556
files,
@@ -79,8 +80,10 @@ function get_job(job_info, available_runtimes) {
7980
}
8081
}
8182

82-
const rt = available_runtimes.find(rt =>
83-
[...rt.aliases, rt.language].includes(rt.language)
83+
const rt = available_runtimes.find(
84+
rt =>
85+
[...rt.aliases, rt.language].includes(language) &&
86+
(version === rt.version || version === '*')
8487
);
8588

8689
if (rt === undefined) {

api/src/bin/pistond.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,22 @@ expressWs(app);
4343
`nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames`
4444
)
4545
.toString();
46-
const runtime_names = JSON.parse(runtimes_data);
46+
const runtime_names_unordered = JSON.parse(runtimes_data);
47+
48+
const mainstream_runtimes_data = cp
49+
.execSync(
50+
`nix eval --json ${config.flake_path}#pistonMainstreamRuntimes`
51+
)
52+
.toString();
53+
const mainstream_runtimes = JSON.parse(mainstream_runtimes_data).filter(runtime =>
54+
runtime_names_unordered.includes(runtime)
55+
);
56+
const runtime_names = [
57+
...mainstream_runtimes,
58+
...runtime_names_unordered.filter(
59+
runtime => !mainstream_runtimes.includes(runtime)
60+
),
61+
];
4762

4863
logger.info('Loading the runtimes from the flakes');
4964
const runtimes = runtime_names.map(runtime_name => {

flake.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
"bash-only" = runtimeList ["bash"];
6666
"none" = { };
6767
};
68+
pistonMainstreamRuntimes = [
69+
"mono-csharp"
70+
"python3"
71+
"node-javascript"
72+
"node-typescript"
73+
"mono-basic"
74+
];
6875

6976
legacyPackages."${system}" = rec {
7077
nosocket = (import ./nosocket { inherit pkgs; }).package;

runtimes/python2.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ in piston.mkRuntime {
77

88
aliases = [
99
"py2"
10+
"python"
11+
"py"
1012
];
1113

1214
run = ''
@@ -22,4 +24,4 @@ in piston.mkRuntime {
2224
};
2325
})
2426
];
25-
}
27+
}

runtimes/python3.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ in piston.mkRuntime {
88
aliases = [
99
"py3"
1010
"py"
11+
"python"
1112
];
1213

1314
run = ''
@@ -23,4 +24,4 @@ in piston.mkRuntime {
2324
};
2425
})
2526
];
26-
}
27+
}

0 commit comments

Comments
 (0)