Compare commits
No commits in common. "5f97005a9ae6539163ef41c137bf8b040f0f2f17" and "f0cbbadb2770f3e06a435b1aa0062567ab0062a4" have entirely different histories.
5f97005a9a
...
f0cbbadb27
|
@ -88,16 +88,16 @@ jobs:
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
ls -la
|
ls -la
|
||||||
docker run -v $(pwd)'/repo:/piston/repo' -v $(pwd)'/packages:/piston/packages' -d --name repo docker.pkg.github.com/engineer-man/piston/repo-builder --no-build
|
docker run -v $(pwd)'/repo:/piston/repo' -v $(pwd)'/packages:/piston/packages' -d --name piston_fs_repo docker.pkg.github.com/engineer-man/piston/repo-builder --no-build
|
||||||
docker run --network container:repo -v $(pwd)'/data:/piston' -d --name api docker.pkg.github.com/engineer-man/piston/api
|
docker run --network container:piston_fs_repo -v $(pwd)'/data:/piston' -d --name api docker.pkg.github.com/engineer-man/piston/api
|
||||||
echo Waiting for API to start..
|
echo Waiting for API to start..
|
||||||
docker run --network container:api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:2000/runtimes
|
docker run --network container:api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:2000/runtimes
|
||||||
|
|
||||||
echo Waiting for Index to start..
|
echo Waiting for Index to start..
|
||||||
docker run --network container:repo appropriate/curl -s --retry 999 --retry-max-time 0 --retry-connrefused http://localhost:8000/index
|
docker run --network container:piston_fs_repo appropriate/curl -s --retry 999 --retry-max-time 0 --retry-connrefused http://localhost:8000/index
|
||||||
|
|
||||||
echo Adjusting index
|
echo Adjusting index
|
||||||
sed -i 's/repo/localhost/g' repo/index
|
sed -i 's/piston_fs_repo/localhost/g' repo/index
|
||||||
|
|
||||||
echo Listing Packages
|
echo Listing Packages
|
||||||
PACKAGES_JSON=$(docker run --network container:api appropriate/curl -s http://localhost:2000/packages)
|
PACKAGES_JSON=$(docker run --network container:api appropriate/curl -s http://localhost:2000/packages)
|
||||||
|
|
|
@ -17,7 +17,7 @@ let gid = 0;
|
||||||
|
|
||||||
class Job {
|
class Job {
|
||||||
|
|
||||||
constructor({ runtime, files, args, stdin, timeouts }) {
|
constructor({ runtime, files, args, stdin, timeouts, alias }) {
|
||||||
this.uuid = uuidv4();
|
this.uuid = uuidv4();
|
||||||
this.runtime = runtime;
|
this.runtime = runtime;
|
||||||
this.files = files.map((file,i) => ({
|
this.files = files.map((file,i) => ({
|
||||||
|
@ -28,6 +28,7 @@ class Job {
|
||||||
this.args = args;
|
this.args = args;
|
||||||
this.stdin = stdin;
|
this.stdin = stdin;
|
||||||
this.timeouts = timeouts;
|
this.timeouts = timeouts;
|
||||||
|
this.alias = alias;
|
||||||
|
|
||||||
this.uid = config.runner_uid_min + uid;
|
this.uid = config.runner_uid_min + uid;
|
||||||
this.gid = config.runner_gid_min + gid;
|
this.gid = config.runner_gid_min + gid;
|
||||||
|
@ -89,7 +90,7 @@ class Job {
|
||||||
const proc = cp.spawn(proc_call[0], proc_call.splice(1) ,{
|
const proc = cp.spawn(proc_call[0], proc_call.splice(1) ,{
|
||||||
env: {
|
env: {
|
||||||
...this.runtime.env_vars,
|
...this.runtime.env_vars,
|
||||||
PISTON_LANGUAGE: this.runtime.language
|
PISTON_ALIAS: this.alias
|
||||||
},
|
},
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
||||||
cwd: this.dir,
|
cwd: this.dir,
|
||||||
|
|
|
@ -50,7 +50,7 @@ const app = express();
|
||||||
.flat()
|
.flat()
|
||||||
.filter(pkg => fss.exists_sync(path.join(pkg, globals.pkg_installed_file)));
|
.filter(pkg => fss.exists_sync(path.join(pkg, globals.pkg_installed_file)));
|
||||||
|
|
||||||
installed_languages.forEach(pkg => runtime.load_package(pkg));
|
installed_languages.forEach(pkg => new runtime.Runtime(pkg));
|
||||||
|
|
||||||
logger.info('Starting API Server');
|
logger.info('Starting API Server');
|
||||||
logger.debug('Constructing Express App');
|
logger.debug('Constructing Express App');
|
||||||
|
@ -100,8 +100,7 @@ const app = express();
|
||||||
return {
|
return {
|
||||||
language: rt.language,
|
language: rt.language,
|
||||||
version: rt.version.raw,
|
version: rt.version.raw,
|
||||||
aliases: rt.aliases,
|
aliases: rt.aliases
|
||||||
runtime: rt.runtime
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,22 +24,6 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add 32 bit and 64 bit architectures to seccomp filter
|
|
||||||
int rc;
|
|
||||||
uint32_t arch[] = {SCMP_ARCH_X86_64, SCMP_ARCH_X86, SCMP_ARCH_X32};
|
|
||||||
// We first remove the existing arch, otherwise our subsequent call to add
|
|
||||||
// it will fail
|
|
||||||
seccomp_arch_remove(ctx, seccomp_arch_native());
|
|
||||||
for (int i = 0; i < sizeof(arch) / sizeof(arch[0]); i++)
|
|
||||||
{
|
|
||||||
rc = seccomp_arch_add(ctx, arch[i]);
|
|
||||||
if (rc != 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Unable to add arch: %d\n", arch[i]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a seccomp rule to the syscall blacklist - blacklist the socket syscall
|
// Add a seccomp rule to the syscall blacklist - blacklist the socket syscall
|
||||||
if (seccomp_rule_add(ctx, SCMP_ACT_ERRNO(EACCES), SCMP_SYS(socket), 0) < 0)
|
if (seccomp_rule_add(ctx, SCMP_ACT_ERRNO(EACCES), SCMP_SYS(socket), 0) < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,7 +85,7 @@ class Package {
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug('Registering runtime');
|
logger.debug('Registering runtime');
|
||||||
runtime.load_package(this.install_path);
|
new runtime.Runtime(this.install_path);
|
||||||
|
|
||||||
logger.debug('Caching environment');
|
logger.debug('Caching environment');
|
||||||
const get_env_command = `cd ${this.install_path}; source environment; env`;
|
const get_env_command = `cd ${this.install_path}; source environment; env`;
|
||||||
|
@ -136,7 +136,7 @@ class Package {
|
||||||
logger.info(`Uninstalling ${this.language}-${this.version.raw}`);
|
logger.info(`Uninstalling ${this.language}-${this.version.raw}`);
|
||||||
|
|
||||||
logger.debug("Finding runtime")
|
logger.debug("Finding runtime")
|
||||||
const found_runtime = runtime.get_runtime_by_name_and_version(this.language, this.version.raw);
|
const found_runtime = runtime.get_latest_runtime_matching_language_version(this.language, this.version.raw);
|
||||||
|
|
||||||
if(!found_runtime){
|
if(!found_runtime){
|
||||||
logger.error(`Uninstalling ${this.language}-${this.version.raw} failed: Not installed`)
|
logger.error(`Uninstalling ${this.language}-${this.version.raw} failed: Not installed`)
|
||||||
|
|
|
@ -9,21 +9,17 @@ const runtimes = [];
|
||||||
|
|
||||||
class Runtime {
|
class Runtime {
|
||||||
|
|
||||||
constructor({language, version, aliases, pkgdir, runtime}){
|
constructor(package_dir){
|
||||||
this.language = language;
|
|
||||||
this.version = version;
|
|
||||||
this.aliases = aliases || [];
|
|
||||||
this.pkgdir = pkgdir;
|
|
||||||
this.runtime = runtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
static load_package(package_dir){
|
|
||||||
let info = JSON.parse(
|
let info = JSON.parse(
|
||||||
fss.read_file_sync(path.join(package_dir, 'pkg-info.json'))
|
fss.read_file_sync(path.join(package_dir, 'pkg-info.json'))
|
||||||
);
|
);
|
||||||
|
|
||||||
let { language, version, build_platform, aliases, provides } = info;
|
const { language, version, build_platform, aliases } = info;
|
||||||
version = semver.parse(version);
|
|
||||||
|
this.pkgdir = package_dir;
|
||||||
|
this.language = language;
|
||||||
|
this.version = semver.parse(version);
|
||||||
|
this.aliases = aliases;
|
||||||
|
|
||||||
if (build_platform !== globals.platform) {
|
if (build_platform !== globals.platform) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
@ -32,29 +28,9 @@ class Runtime {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(provides){
|
|
||||||
// Multiple languages in 1 package
|
|
||||||
provides.forEach(lang => {
|
|
||||||
runtimes.push(new Runtime({
|
|
||||||
language: lang.language,
|
|
||||||
aliases: lang.aliases,
|
|
||||||
version,
|
|
||||||
pkgdir: package_dir,
|
|
||||||
runtime: language
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
runtimes.push(new Runtime({
|
|
||||||
language,
|
|
||||||
version,
|
|
||||||
aliases,
|
|
||||||
pkgdir: package_dir
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug(`Package ${language}-${version} was loaded`);
|
logger.debug(`Package ${language}-${version} was loaded`);
|
||||||
|
|
||||||
|
runtimes.push(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
get compiled() {
|
get compiled() {
|
||||||
|
@ -103,9 +79,3 @@ module.exports.get_latest_runtime_matching_language_version = function(lang, ver
|
||||||
return module.exports.get_runtimes_matching_language_version(lang, ver)
|
return module.exports.get_runtimes_matching_language_version(lang, ver)
|
||||||
.sort((a,b) => semver.rcompare(a.version, b.version))[0];
|
.sort((a,b) => semver.rcompare(a.version, b.version))[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.get_runtime_by_name_and_version = function(runtime, ver){
|
|
||||||
return runtimes.find(rt => (rt.runtime == runtime || (rt.runtime === undefined && rt.language == runtime)) && semver.satisfies(rt.version, ver));
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.load_package = Runtime.load_package;
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Put instructions to compile source code, remove this file if the language does not require this stage
|
|
@ -1,10 +1,5 @@
|
||||||
{
|
{
|
||||||
"language": "gawk",
|
"language": "gawk",
|
||||||
"version": "5.1.0",
|
"version": "5.1.0",
|
||||||
"provides": [
|
"aliases": ["awk"]
|
||||||
{
|
|
||||||
"language": "awk",
|
|
||||||
"aliases": ["gawk"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,21 +3,21 @@
|
||||||
# Put instructions to compile source code, remove this file if the language does not require this stage
|
# Put instructions to compile source code, remove this file if the language does not require this stage
|
||||||
|
|
||||||
|
|
||||||
case "${PISTON_LANGUAGE}" in
|
case "${PISTON_ALIAS}" in
|
||||||
c)
|
gcc | c)
|
||||||
rename 's/$/\.c/' "$@" # Add .c extension
|
rename 's/$/\.c/' "$@" # Add .c extension
|
||||||
gcc -std=c11 *.c -lm
|
gcc -std=c11 *.c -lm
|
||||||
;;
|
;;
|
||||||
c++)
|
g++ | c++ | cpp)
|
||||||
rename 's/$/\.cpp/' "$@" # Add .cpp extension
|
rename 's/$/\.cpp/' "$@" # Add .cpp extension
|
||||||
g++ -std=c++17 *.cpp
|
g++ -std=c++17 *.cpp
|
||||||
;;
|
;;
|
||||||
d)
|
gdc | d)
|
||||||
rename 's/.code$/\.d/' "$@" # Add .d extension
|
rename 's/$/\.d/' "$@" # Add .d extension
|
||||||
gdc *.d
|
gdc *.d
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "How did you get here? (${PISTON_LANGUAGE})"
|
echo "How did you get here? (${PISTON_ALIAS})"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -1,18 +1,5 @@
|
||||||
{
|
{
|
||||||
"language": "gcc",
|
"language": "gcc",
|
||||||
"version": "10.2.0",
|
"version": "10.2.0",
|
||||||
"provides": [
|
"aliases": ["c", "g++", "c++", "cpp", "gdc", "d"]
|
||||||
{
|
|
||||||
"language":"c",
|
|
||||||
"aliases": ["gcc"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"language": "c++",
|
|
||||||
"aliases": ["cpp", "g++"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"language": "d",
|
|
||||||
"aliases": ["gdc"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
mv $1 $1.go
|
GOCACHE=$PWD go run "$@"
|
||||||
filename=$1.go
|
|
||||||
shift
|
|
||||||
GOCACHE=$PWD go run $filename "$@"
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
rename 's/$/\.cs/' "$@" # Add .cs extension
|
csc "$@"
|
||||||
csc -out:out *.cs
|
|
|
@ -1 +1 @@
|
||||||
export PATH=$PWD/bin:$PATH
|
export PATH=$PWD/mono-6.12.0:$PATH
|
|
@ -1,10 +1,5 @@
|
||||||
{
|
{
|
||||||
"language": "mono",
|
"language": "mono",
|
||||||
"version": "6.12.0",
|
"version": "6.12.0",
|
||||||
"provides": [
|
"aliases": ["csharp", "cs"]
|
||||||
{
|
|
||||||
"language": "csharp",
|
|
||||||
"aliases": ["mono", "mono-csharp", "mono-c#", "mono-cs", "c#", "cs"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
CODE=${1/cs/exe}
|
||||||
shift
|
shift
|
||||||
mono out "$@"
|
mono $CODE "$@"
|
|
@ -3,7 +3,7 @@
|
||||||
# Put instructions to compile source code, remove this file if the language does not require this stage
|
# Put instructions to compile source code, remove this file if the language does not require this stage
|
||||||
|
|
||||||
|
|
||||||
case "${PISTON_LANGUAGE}" in
|
case "${PISTON_ALIAS}" in
|
||||||
nasm)
|
nasm)
|
||||||
nasm -f elf32 -o binary.o "$@"
|
nasm -f elf32 -o binary.o "$@"
|
||||||
ld -m elf_i386 binary.o -o binary
|
ld -m elf_i386 binary.o -o binary
|
||||||
|
@ -13,7 +13,7 @@ case "${PISTON_LANGUAGE}" in
|
||||||
ld -m elf_x86_64 binary.o -o binary
|
ld -m elf_x86_64 binary.o -o binary
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "How did you get here? (${PISTON_LANGUAGE})"
|
echo "How did you get here? (${PISTON_ALIAS})"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
{
|
{
|
||||||
"language": "nasm",
|
"language": "nasm",
|
||||||
"version": "2.15.5",
|
"version": "2.15.5",
|
||||||
"provides": [
|
"aliases": ["nasm64"]
|
||||||
{
|
|
||||||
"language": "nasm",
|
|
||||||
"aliases": ["asm", "nasm32"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"language": "nasm64",
|
|
||||||
"aliases": ["asm64"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
{
|
{
|
||||||
"language": "node",
|
"language": "node",
|
||||||
"version": "15.10.0",
|
"version": "15.10.0",
|
||||||
"provides": [
|
"aliases": ["node-javascript", "node-js", "javascript", "js"]
|
||||||
{
|
|
||||||
"language": "javascript",
|
|
||||||
"aliases": ["node-javascript", "node-js", "javascript", "js"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Compile pony file(s)
|
# Compile pony file(s)
|
||||||
rename 's/$/\.pony/' "$@" # Add .pony extension
|
rename 's/$/\.pong/' "$@" # Add .pony extension
|
||||||
ponyc -b out
|
ponyc -b out
|
|
@ -1,7 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Put instructions to run the runtime
|
# Put instructions to run the runtime
|
||||||
mv $1 $1.scala
|
scala "$@"
|
||||||
filename=$1.scala
|
|
||||||
shift
|
|
||||||
scala $filename "$@"
|
|
||||||
|
|
|
@ -5,8 +5,7 @@ AUTH_HEADER="Authorization: $API_KEY"
|
||||||
for test_file in */*/test.*
|
for test_file in */*/test.*
|
||||||
do
|
do
|
||||||
IFS='/' read -ra test_parts <<< "$test_file"
|
IFS='/' read -ra test_parts <<< "$test_file"
|
||||||
IFS='.' read -ra file_parts <<< "$(basename $test_file)"
|
language=${test_parts[0]}
|
||||||
language=${file_parts[1]}
|
|
||||||
lang_ver=${test_parts[1]}
|
lang_ver=${test_parts[1]}
|
||||||
|
|
||||||
test_src=$(python3 -c "import json; print(json.dumps(open('$test_file').read()))")
|
test_src=$(python3 -c "import json; print(json.dumps(open('$test_file').read()))")
|
||||||
|
|
23
piston
23
piston
|
@ -1,23 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
dev)
|
|
||||||
shift
|
|
||||||
docker-compose -f docker-compose.dev.yaml "$@"
|
|
||||||
;;
|
|
||||||
prod)
|
|
||||||
shift
|
|
||||||
docker-compose -f docker-compose.yaml "$@"
|
|
||||||
;;
|
|
||||||
update)
|
|
||||||
git pull
|
|
||||||
docker-compose pull api
|
|
||||||
docker-compose up -d api
|
|
||||||
;;
|
|
||||||
clean-pkgs)
|
|
||||||
git clean -fqXd packages
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
node cli/index.js "$@"
|
|
||||||
;;
|
|
||||||
esac
|
|
|
@ -1,4 +1,4 @@
|
||||||
BASEURL=http://repo:8000/
|
BASEURL=http://piston_fs_repo:8000/
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue