Merge pull request #476 from Brikaa/fix-v2-endpoint

Fix runtime finding in v2 endpoint
This commit is contained in:
Thomas Hobson 2022-06-08 11:27:41 +12:00 committed by GitHub
commit c7bcc7f0b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 5 deletions

View File

@ -50,6 +50,7 @@ const SIGNALS = [
function get_job(job_info, available_runtimes) {
let {
language,
version,
args,
stdin,
files,
@ -79,8 +80,10 @@ function get_job(job_info, available_runtimes) {
}
}
const rt = available_runtimes.find(rt =>
[...rt.aliases, rt.language].includes(rt.language)
const rt = available_runtimes.find(
rt =>
[...rt.aliases, rt.language].includes(language) &&
(version === rt.version || version === '*')
);
if (rt === undefined) {

View File

@ -43,7 +43,22 @@ expressWs(app);
`nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames`
)
.toString();
const runtime_names = JSON.parse(runtimes_data);
const runtime_names_unordered = JSON.parse(runtimes_data);
const mainstream_runtimes_data = cp
.execSync(
`nix eval --json ${config.flake_path}#pistonMainstreamRuntimes`
)
.toString();
const mainstream_runtimes = JSON.parse(mainstream_runtimes_data).filter(runtime =>
runtime_names_unordered.includes(runtime)
);
const runtime_names = [
...mainstream_runtimes,
...runtime_names_unordered.filter(
runtime => !mainstream_runtimes.includes(runtime)
),
];
logger.info('Loading the runtimes from the flakes');
const runtimes = runtime_names.map(runtime_name => {

View File

@ -65,6 +65,13 @@
"bash-only" = runtimeList ["bash"];
"none" = { };
};
pistonMainstreamRuntimes = [
"mono-csharp"
"python3"
"node-javascript"
"node-typescript"
"mono-basic"
];
legacyPackages."${system}" = rec {
nosocket = (import ./nosocket { inherit pkgs; }).package;

View File

@ -7,6 +7,8 @@ in piston.mkRuntime {
aliases = [
"py2"
"python"
"py"
];
run = ''
@ -22,4 +24,4 @@ in piston.mkRuntime {
};
})
];
}
}

View File

@ -8,6 +8,7 @@ in piston.mkRuntime {
aliases = [
"py3"
"py"
"python"
];
run = ''
@ -23,4 +24,4 @@ in piston.mkRuntime {
};
})
];
}
}