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

View File

@ -43,7 +43,22 @@ expressWs(app);
`nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames` `nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames`
) )
.toString(); .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'); logger.info('Loading the runtimes from the flakes');
const runtimes = runtime_names.map(runtime_name => { const runtimes = runtime_names.map(runtime_name => {

View File

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

View File

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

View File

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