diff --git a/.envrc b/.envrc deleted file mode 100644 index 17d6464..0000000 --- a/.envrc +++ /dev/null @@ -1 +0,0 @@ -use_nix \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/language-request.md b/.github/ISSUE_TEMPLATE/language-request.md deleted file mode 100644 index 5ae2661..0000000 --- a/.github/ISSUE_TEMPLATE/language-request.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Language Request -about: Template for requesting language support -title: Add [insert language name here] -labels: package -assignees: '' - ---- - -Provide links to different compilers/interpreters that could be used to implement this language, and discuss pros/cons of each. diff --git a/.github/PULL_REQUEST_TEMPLATE/package.md b/.github/PULL_REQUEST_TEMPLATE/package.md deleted file mode 100644 index 6cd3c98..0000000 --- a/.github/PULL_REQUEST_TEMPLATE/package.md +++ /dev/null @@ -1,10 +0,0 @@ -Checklist: -* [ ] The package builds locally with `./piston build-pkg [package] [version]` -* [ ] The package installs with `./piston ppman install [package]=[version]` -* [ ] The package runs the test code with `./piston run [package] -l [version] packages/[package]/[version]/test.*` -* [ ] Package files are placed in the correct directory -* [ ] No old package versions are removed -* [ ] All source files are deleted in the `build.sh` script -* [ ] `metadata.json`'s `language` and `version` fields match the directory path -* [ ] Any extensions the language may use are set as aliases -* [ ] Any alternative names the language is referred to are set as aliases. diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml index bb264a3..b3027ec 100644 --- a/.github/workflows/package-pr.yaml +++ b/.github/workflows/package-pr.yaml @@ -55,9 +55,7 @@ jobs: run: | PACKAGES=$(jq '.[]' -r ${HOME}/files.json | awk -F/ '{ print $2 "-" $3 }' | sort -u) echo "Packages: $PACKAGES" - docker pull docker.pkg.github.com/engineer-man/piston/repo-builder:latest - docker build -t repo-builder repo - docker run -v "${{ github.workspace }}:/piston" repo-builder --no-server $PACKAGES + docker run -v "${{ github.workspace }}:/piston" docker.pkg.github.com/engineer-man/piston/repo-builder:latest --no-server $PACKAGES ls -la packages - name: Upload package as artifact @@ -91,9 +89,7 @@ jobs: run: | 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 pull docker.pkg.github.com/engineer-man/piston/api - docker build -t piston-api api - docker run --network container:repo -v $(pwd)'/data:/piston' -e PISTON_LOG_LEVEL=DEBUG -e 'PISTON_REPO_URL=http://localhost:8000/index' -d --name api piston-api + docker run --network container:repo -v $(pwd)'/data:/piston' -e PISTON_LOG_LEVEL=DEBUG -e 'PISTON_REPO_URL=http://localhost:8000/index' -d --name api docker.pkg.github.com/engineer-man/piston/api echo Waiting for API to start.. docker run --network container:api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:2000/api/v2/runtimes diff --git a/.github/workflows/package-push.yaml b/.github/workflows/package-push.yaml index bbb44af..ad33f3e 100644 --- a/.github/workflows/package-push.yaml +++ b/.github/workflows/package-push.yaml @@ -33,9 +33,7 @@ jobs: run: | PACKAGES=$(jq '.[]' -r ${HOME}/files.json | awk -F/ '{ print $2 "-" $3 }' | sort -u) echo "Packages: $PACKAGES" - docker pull docker.pkg.github.com/engineer-man/piston/repo-builder:latest - docker build -t repo-builder repo - docker run -v "${{ github.workspace }}:/piston" repo-builder --no-server $PACKAGES + docker run -v "${{ github.workspace }}:/piston" docker.pkg.github.com/engineer-man/piston/repo-builder:latest --no-server $PACKAGES ls -la packages - name: Upload Packages @@ -75,4 +73,4 @@ jobs: file: index tag: pkgs overwrite: true - file_glob: true + file_glob: true \ No newline at end of file diff --git a/.readthedocs.yaml b/.readthedocs.yaml deleted file mode 100644 index e651ad5..0000000 --- a/.readthedocs.yaml +++ /dev/null @@ -1,8 +0,0 @@ -version: 2 -mkdocs: - configuration: mkdocs.yml - -python: - version: 3.7 - install: - - requirements: docs/requirements.txt diff --git a/api/Dockerfile b/api/Dockerfile index ec0d2a8..668c54a 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get update && \ libncurses6 libncurses5 libedit-dev libseccomp-dev rename procps python3 \ libreadline-dev libblas-dev liblapack-dev libpcre3-dev libarpack2-dev \ libfftw3-dev libglpk-dev libqhull-dev libqrupdate-dev libsuitesparse-dev \ - libsundials-dev libpcre2-dev && \ + libsundials-dev && \ rm -rf /var/lib/apt/lists/* RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen diff --git a/api/src/job.js b/api/src/job.js index 683cda6..d213bbc 100644 --- a/api/src/job.js +++ b/api/src/job.js @@ -59,13 +59,6 @@ class Job { for (const file of this.files) { let file_path = path.join(this.dir, file.name); - const rel = path.relative(this.dir, file_path); - - if(rel.startsWith("..")) - throw Error(`File path "${file.name}" tries to escape parent directory: ${rel}`) - - await fs.mkdir(path.dirname(file_path), {recursive: true, mode: 0o700}) - await fs.chown(path.dirname(file_path), this.uid, this.gid); await fs.write_file(file_path, file.content); await fs.chown(file_path, this.uid, this.gid); @@ -162,7 +155,7 @@ class Job { proc.on('exit', (code, signal) => { exit_cleanup(); - resolve({stdout, stderr, code, signal, output }); + resolve({ stdout, stderr, code, signal, output }); }); proc.on('error', err => { @@ -339,8 +332,10 @@ class Job { async cleanup() { logger.info(`Cleaning up job uuid=${this.uuid}`); - await this.cleanup_processes(); - await this.cleanup_filesystem(); + await Promise.all([ + this.cleanup_processes(), + this.cleanup_filesystem(), + ]); } } diff --git a/cli/package-lock.json b/cli/package-lock.json index f7c2771..76a2cc6 100644 --- a/cli/package-lock.json +++ b/cli/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "axios": "^0.21.2", + "axios": "^0.21.1", "chalk": "^4.1.0", "minimatch": "^3.0.4", "nocamel": "^1.0.2", @@ -38,11 +38,11 @@ } }, "node_modules/axios": { - "version": "0.21.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.2.tgz", - "integrity": "sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", "dependencies": { - "follow-redirects": "^1.14.0" + "follow-redirects": "^1.10.0" } }, "node_modules/balanced-match": { @@ -116,22 +116,11 @@ } }, "node_modules/follow-redirects": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.3.tgz", - "integrity": "sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz", + "integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==", "engines": { "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } } }, "node_modules/get-caller-file": { @@ -329,11 +318,11 @@ } }, "axios": { - "version": "0.21.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.2.tgz", - "integrity": "sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", "requires": { - "follow-redirects": "^1.14.0" + "follow-redirects": "^1.10.0" } }, "balanced-match": { @@ -398,9 +387,9 @@ "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" }, "follow-redirects": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.3.tgz", - "integrity": "sha512-3MkHxknWMUtb23apkgz/83fDoe+y+qr0TdgacGIA7bew+QLBo3vdgEN2xEsuXNivpFy4CyDhBBZnNZOtalmenw==" + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz", + "integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==" }, "get-caller-file": { "version": "2.0.5", diff --git a/cli/package.json b/cli/package.json index ef1103e..90e3e12 100644 --- a/cli/package.json +++ b/cli/package.json @@ -5,7 +5,7 @@ "main": "index.js", "license": "MIT", "dependencies": { - "axios": "^0.21.2", + "axios": "^0.21.1", "chalk": "^4.1.0", "minimatch": "^3.0.4", "nocamel": "^1.0.2", diff --git a/docs/api-v2.md b/docs/api-v2.md deleted file mode 100644 index 111b514..0000000 --- a/docs/api-v2.md +++ /dev/null @@ -1,234 +0,0 @@ -# API - -Piston exposes an API for managing packages and executing user-defined code. - -The API is broken in to 2 main sections - packages and jobs. - -The API is exposed from the container, by default on port 2000, at `/api/v2/`. - -All inputs are validated, and if an error occurs, a 4xx or 5xx status code is returned. -In this case, a JSON payload is sent back containing the error message as `message` - -## Runtimes - -### `GET /api/v2/runtimes` - -Returns a list of available languages, including the version, runtime and aliases. - -#### Response - -- `[].language`: Name of the language -- `[].version`: Version of the runtime -- `[].aliases`: List of alternative names that can be used for the language -- `[].runtime` (_optional_): Name of the runtime used to run the langage, only provided if alternative runtimes exist for the language - -#### Example - -``` -GET /api/v2/runtimes -``` - -```json -HTTP/1.1 200 OK -Content-Type: application/json - -[ - { - "language": "bash", - "version": "5.1.0", - "aliases": ["sh"] - }, - { - "language": "javascript", - "version": "15.10.0", - "aliases": ["node-javascript", "node-js", "javascript", "js"], - "runtime": "node" - } -] -``` - -## Execute - -### `POST /api/v2/execute` - -Runs the given code, using the given runtime and arguments, returning the result. - -#### Request - -- `language`: Name or alias of a language listed in [runtimes](#runtimes) -- `version`: SemVer version selector of a language listed in [runtimes](#runtimes) -- `files`: An array of files which should be uploaded into the job context -- `files[].name` (_optional_): Name of file to be written, if none a random name is picked -- `files[].content`: Content of file to be written -- `stdin` (_optional_): Text to pass into stdin of the program. Defaults to blank string. -- `args` (_optional_): Arguments to pass to the program. Defaults to none -- `run_timeout` (_optional_): The maximum allowed time in milliseconds for the compile stage to finish before bailing out. Must be a number, less than or equal to the configured maximum timeout. -- `compile_timeout` (_optional_): The maximum allowed time in milliseconds for the run stage to finish before bailing out. Must be a number, less than or equal to the configured maximum timeout. Defaults to maximum. -- `compile_memory_limit` (_optional_): The maximum amount of memory the compile stage is allowed to use in bytes. Must be a number, less than or equal to the configured maximum. Defaults to maximum, or `-1` (no limit) if none is configured. -- `run_memory_limit` (_optional_): The maximum amount of memory the run stage is allowed to use in bytes. Must be a number, less than or equal to the configured maximum. Defaults to maximum, or `-1` (no limit) if none is configured. - -#### Response - -- `language`: Name (not alias) of the runtime used -- `version`: Version of the used runtime -- `run`: Results from the run stage -- `run.stdout`: stdout from run stage process -- `run.stderr`: stderr from run stage process -- `run.output`: stdout and stderr combined in order of data from run stage process -- `run.code`: Exit code from run process, or null if signal is not null -- `run.signal`: Signal from run process, or null if code is not null -- `compile` (_optional_): Results from the compile stage, only provided if the runtime has a compile stage -- `compile.stdout`: stdout from compile stage process -- `compile.stderr`: stderr from compile stage process -- `compile.output`: stdout and stderr combined in order of data from compile stage process -- `compile.code`: Exit code from compile process, or null if signal is not null -- `compile.signal`: Signal from compile process, or null if code is not null - -#### Example - -```json -POST /api/v2/execute -Content-Type: application/json - -{ - "language": "js", - "version": "15.10.0", - "files": [ - { - "name": "my_cool_code.js", - "content": "console.log(process.argv)" - } - ], - "stdin": "", - "args": ["1", "2", "3"], - "compile_timeout": 10000, - "run_timeout": 3000, - "compile_memory_limit": -1, - "run_memory_limit": -1 -} -``` - -```json -HTTP/1.1 200 OK -Content-Type: application/json - -{ - "run": { - "stdout": "[\n '/piston/packages/node/15.10.0/bin/node',\n '/piston/jobs/e87afa0d-6c2a-40b8-a824-ffb9c5c6cb64/my_cool_code.js',\n '1',\n '2',\n '3'\n]\n", - "stderr": "", - "code": 0, - "signal": null, - "output": "[\n '/piston/packages/node/15.10.0/bin/node',\n '/piston/jobs/e87afa0d-6c2a-40b8-a824-ffb9c5c6cb64/my_cool_code.js',\n '1',\n '2',\n '3'\n]\n" - }, - "language": "javascript", - "version": "15.10.0" -} -``` - -## Packages - -### `GET /api/v2/packages` - -Returns a list of all possible packages, and whether their installation status. - -#### Response - -- `[].language`: Name of the contained runtime -- `[].language_version`: Version of the contained runtime -- `[].installed`: Status on the package being installed - -#### Example - -``` -GET /api/v2/packages -``` - -```json -HTTP/1.1 200 OK -Content-Type: application/json - -[ - { - "language": "node", - "language_version": "15.10.0", - "installed": true - }, - { - "language": "bash", - "language_version": "5.1.0", - "installed": true - } -] -``` - -### `POST /api/v2/packages` - -Install the given package. - -#### Request - -- `language`: Name of package from [package list](#get-apiv2packages) -- `version`: SemVer version selector for package from [package list](#get-apiv2packages) - -#### Response - -- `language`: Name of package installed -- `version`: Version of package installed - -#### Example - -```json -POST /api/v2/packages -Content-Type: application/json - -{ - "language": "bash", - "version": "5.x" -} -``` - -```json -HTTP/1.1 200 OK -Content-Type: application/json - -{ - "language": "bash", - "version": "5.1.0" -} -``` - -### `DELETE /api/v2/packages` - -Uninstall the given package. - -#### Request - -- `language`: Name of package from [package list](#get-apiv2packages) -- `version`: SemVer version selector for package from [package list](#get-apiv2packages) - -#### Response - -- `language`: Name of package uninstalled -- `version`: Version of package uninstalled - -#### Example - -```json -DELETE /api/v2/packages -Content-Type: application/json - -{ - "language": "bash", - "version": "5.x" -} -``` - -```json -HTTP/1.1 200 OK -Content-Type: application/json - -{ - "language": "bash", - "version": "5.1.0" -} -``` diff --git a/docs/configuration.md b/docs/configuration.md deleted file mode 100644 index 1388e9d..0000000 --- a/docs/configuration.md +++ /dev/null @@ -1,147 +0,0 @@ -# Configuration - -Piston provides many different configuration options to tweak Piston to meet your needs. - -Configuration is specified through environment variables, prefixed with `PISTON_`. - -## Log Level - -```yaml -key: PISTON_LOG_LEVEL -default: INFO -``` - -Level of log output to provide. - -One of `DEBUG`, `INFO`, `WARN`, `ERROR` or `NONE` - -## Bind Address - -```yaml -key: PISTON_BIND_ADDRESS -default: 0.0.0.0:2000 -``` - -Port and IP address to bind the Piston API to. - - -!!! warning - Changing this value is not recommended. - - This changes the bind address inside the container, and thus serves no purpose when running in a container - -## Data Directory - -```yaml -key: PISTON_DATA_DIRECTORY -default: /piston -``` - -Absolute path to piston related data, including packages and job contexts. - - -!!! warning - Changing this value is not recommended. - - Some packages require absolute paths on disk at build time. - Due to this, some packages may break when changing this parameter. - -## Runner GID/UID range - -```yaml -key: - - PISTON_RUNNER_UID_MIN - - PISTON_RUNNER_UID_MAX - - PISTON_RUNNER_GID_MIN - - PISTON_RUNNER_GID_MAX -default: - - 1001 - - 1500 - - 1001 - - 1500 -``` - -UID and GID ranges to use when executing jobs. - - -!!! warning - Changing this value is not recommended. - - The piston container creates 500 users and groups by default, and reserves user/group 1000 for running the API. - Any processes run by these users will be killed when cleaning up a job. - -## Disable Networking - -```yaml -key: PISTON_DISABLE_NETWORKING -default: true -``` - -Disallows access to `socket` syscalls, effectively disabling networking for jobs run by piston. - -## Max Process Count - -```yaml -key: PISTON_MAX_PROCESS_COUNT -default: 64 -``` - -Maximum number of processess allowed to to have open for a job. - -Resists against exhausting the process table, causing a full system lockup. - -## Output Max Side - -```yaml -key: PISTON_OUTPUT_MAX_SIZE -default: 1024 -``` - -Maximum size of stdio buffers for each job. - -Resist against run-away output which could lead to memory exhaustion. - -## Max Open Files - -```yaml -key: PISTON_MAX_OPEN_FILES -default: 64 -``` - -Maximum number of open files at a given time by a job. - -Resists against writing many smaller files to exhaust inodes. - -## Max File Size - -```yaml -key: PISTON_MAX_FILE_SIZE -default: 10000000 #10MB -``` - -Maximum size for a singular file written to disk. - -Resists against large file writes to exhaust disk space. - -## Compile/Run memory limits - -```yaml -key: - - PISTON_COMPILE_MEMORY_LIMIT - - PISTON_RUN_MEMORY_LIMIT -default: -1 -``` - -Maximum memory allowed by a stage in bytes. -Use -1 for unlimited memory usage. - -Useful for running memory-limited contests. - -## Repository URL - -```yaml -key: PISTON_REPO_URL -default: https://github.com/engineer-man/piston/releases/download/pkgs/index -``` - -URL for repository index, where packages will be downloaded from. diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index a8e5891..0000000 --- a/docs/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# Piston - -These docs are a WIP diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 53dbf05..0000000 --- a/docs/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -mkdocs==1.1.2 \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml deleted file mode 100644 index 148ba91..0000000 --- a/mkdocs.yml +++ /dev/null @@ -1,15 +0,0 @@ -site_name: Piston -nav: - - Home: index.md - - Configuration: configuration.md - - API: api-v2.md - -theme: - name: readthedocs - highlightjs: true - hljs_languages: - - yaml - - json - -markdown_extensions: - - admonition diff --git a/packages/cow/1.0.0/build.sh b/packages/cow/1.0.0/build.sh index 4753cae..3bf5938 100755 --- a/packages/cow/1.0.0/build.sh +++ b/packages/cow/1.0.0/build.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Grab the latest cow source from github -git clone -q https://github.com/Hydrazer/COW.git cow +git clone -q https://github.com/BigZaphod/COW.git cow # Generate the cow binary into bin mkdir -p bin diff --git a/packages/go/1.16.2/run b/packages/go/1.16.2/run index 65c9a4f..da31af3 100644 --- a/packages/go/1.16.2/run +++ b/packages/go/1.16.2/run @@ -1,7 +1,6 @@ #!/usr/bin/env bash mv $1 $1.go -#filename=$1.go -filename=*.go +filename=$1.go shift GOCACHE=$PWD go run $filename "$@" diff --git a/packages/julia/1.6.1/build.sh b/packages/julia/1.6.1/build.sh deleted file mode 100755 index b2772ae..0000000 --- a/packages/julia/1.6.1/build.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -# Install location -PREFIX=$(realpath $(dirname $0)) - -mkdir -p build -cd build - -# Download and extract Julia source -curl -L "https://github.com/JuliaLang/julia/releases/download/v1.6.1/julia-1.6.1.tar.gz" -o julia.tar.gz -tar xzf julia.tar.gz --strip-components=1 - -# Build -echo "JULIA_CPU_TARGET=generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1) -prefix=$PREFIX" > Make.user -make -j$(nproc) -make install -j$(nproc) - -# Cleanup -cd .. -rm -rf build diff --git a/packages/julia/1.6.1/environment b/packages/julia/1.6.1/environment deleted file mode 100644 index e7d0c97..0000000 --- a/packages/julia/1.6.1/environment +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# Add Julia binary to path -export PATH=$PWD/bin:$PATH diff --git a/packages/julia/1.6.1/metadata.json b/packages/julia/1.6.1/metadata.json deleted file mode 100644 index be2fdea..0000000 --- a/packages/julia/1.6.1/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "julia", - "version": "1.6.1", - "aliases": ["jl"] -} diff --git a/packages/julia/1.6.1/run b/packages/julia/1.6.1/run deleted file mode 100755 index 6badf1c..0000000 --- a/packages/julia/1.6.1/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# Run without startup or history file -julia --startup-file=no --history-file=no "$@" diff --git a/packages/julia/1.6.1/test.jl b/packages/julia/1.6.1/test.jl deleted file mode 100644 index dc98a27..0000000 --- a/packages/julia/1.6.1/test.jl +++ /dev/null @@ -1 +0,0 @@ -println("OK") diff --git a/packages/mono/6.12.0/build.sh b/packages/mono/6.12.0/build.sh index 7bb4b63..2cecc07 100755 --- a/packages/mono/6.12.0/build.sh +++ b/packages/mono/6.12.0/build.sh @@ -2,31 +2,19 @@ PREFIX=$(realpath $(dirname $0)) -mkdir -p build/mono build/mono-basic +mkdir -p build/mono cd build curl "https://download.mono-project.com/sources/mono/mono-6.12.0.122.tar.xz" -o mono.tar.xz -curl -L "https://github.com/mono/mono-basic/archive/refs/tags/4.7.tar.gz" -o mono-basic.tar.gz tar xf mono.tar.xz --strip-components=1 -C mono -tar xf mono-basic.tar.gz --strip-components=1 -C mono-basic -# Compiling Mono cd mono ./configure --prefix "$PREFIX" -make -j$(nproc) +make -j$(nproc) make install -j$(nproc) -export PATH="$PREFIX/bin:$PATH" # To be able to use mono commands - -# Compiling mono-basic -cd ../mono-basic -./configure --prefix="$PREFIX" - -make -j$(nproc) PLATFORM="linux" # Avoids conflict with the $PLATFORM variable we have -make install -j$(nproc) PLATFORM="linux" - -# Remove redundant files cd ../../ rm -rf build + diff --git a/packages/mono/6.12.0/compile b/packages/mono/6.12.0/compile index e3ae230..8728714 100644 --- a/packages/mono/6.12.0/compile +++ b/packages/mono/6.12.0/compile @@ -1,23 +1,4 @@ #!/bin/bash -check_errors () { - grep -q 'error [A-Z]\+[0-9]\+:' check.txt && cat check.txt 1>&2 || cat check.txt - rm check.txt -} - -case "${PISTON_LANGUAGE}" in - csharp) - rename 's/$/\.cs/' "$@" # Add .cs extension - csc -out:out *.cs > check.txt - check_errors - ;; - basic) - rename 's/$/\.vb/' "$@" # Add .vb extension - vbnc -out:out *.vb > check.txt - check_errors - ;; - *) - echo "How did you get here? (${PISTON_LANGUAGE})" - exit 1 - ;; -esac +rename 's/$/\.cs/' "$@" # Add .cs extension +csc -out:out *.cs diff --git a/packages/mono/6.12.0/environment b/packages/mono/6.12.0/environment index 977a5e8..bd0ff98 100644 --- a/packages/mono/6.12.0/environment +++ b/packages/mono/6.12.0/environment @@ -1 +1 @@ -export PATH=$PWD/bin:$PATH +export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/mono/6.12.0/metadata.json b/packages/mono/6.12.0/metadata.json index 4d09ae7..a053884 100644 --- a/packages/mono/6.12.0/metadata.json +++ b/packages/mono/6.12.0/metadata.json @@ -5,10 +5,6 @@ { "language": "csharp", "aliases": ["mono", "mono-csharp", "mono-c#", "mono-cs", "c#", "cs"] - }, - { - "language": "basic", - "aliases": ["vb", "mono-vb", "mono-basic", "visual-basic", "visual basic"] } ] } diff --git a/packages/mono/6.12.0/test.vb b/packages/mono/6.12.0/test.vb deleted file mode 100644 index 291042e..0000000 --- a/packages/mono/6.12.0/test.vb +++ /dev/null @@ -1,9 +0,0 @@ -Imports System - -Module Module1 - - Sub Main() - Console.WriteLine("OK") - End Sub - -End Module diff --git a/packages/node/16.3.0/build.sh b/packages/node/16.3.0/build.sh deleted file mode 100755 index bbc19db..0000000 --- a/packages/node/16.3.0/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -curl "https://nodejs.org/dist/v16.3.0/node-v16.3.0-linux-x64.tar.xz" -o node.tar.xz -tar xf node.tar.xz --strip-components=1 -rm node.tar.xz diff --git a/packages/node/16.3.0/environment b/packages/node/16.3.0/environment deleted file mode 100644 index 977a5e8..0000000 --- a/packages/node/16.3.0/environment +++ /dev/null @@ -1 +0,0 @@ -export PATH=$PWD/bin:$PATH diff --git a/packages/node/16.3.0/metadata.json b/packages/node/16.3.0/metadata.json deleted file mode 100644 index ccd146a..0000000 --- a/packages/node/16.3.0/metadata.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "language": "node", - "version": "16.3.0", - "provides": [ - { - "language": "javascript", - "aliases": ["node-javascript", "node-js", "javascript", "js"] - } - ] -} diff --git a/packages/node/16.3.0/run b/packages/node/16.3.0/run deleted file mode 100644 index 6d1fdee..0000000 --- a/packages/node/16.3.0/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -node "$@" \ No newline at end of file diff --git a/packages/node/16.3.0/test.js b/packages/node/16.3.0/test.js deleted file mode 100644 index 56ed4a0..0000000 --- a/packages/node/16.3.0/test.js +++ /dev/null @@ -1 +0,0 @@ -console.log("OK") \ No newline at end of file diff --git a/packages/pwsh/7.1.4/build.sh b/packages/pwsh/7.1.4/build.sh deleted file mode 100755 index 3f4b070..0000000 --- a/packages/pwsh/7.1.4/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/powershell-7.1.4-linux-x64.tar.gz -o powershell.tar.gz -tar zxf powershell.tar.gz -rm powershell.tar.gz - -chmod +x pwsh diff --git a/packages/pwsh/7.1.4/environment b/packages/pwsh/7.1.4/environment deleted file mode 100644 index 42644cd..0000000 --- a/packages/pwsh/7.1.4/environment +++ /dev/null @@ -1 +0,0 @@ -export PATH=$PWD:$PATH diff --git a/packages/pwsh/7.1.4/metadata.json b/packages/pwsh/7.1.4/metadata.json deleted file mode 100644 index da90f76..0000000 --- a/packages/pwsh/7.1.4/metadata.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "language": "pwsh", - "version": "7.1.4", - "provides": [ - { - "language": "powershell", - "aliases": ["ps", "pwsh", "ps1"] - } - ] -} diff --git a/packages/pwsh/7.1.4/run b/packages/pwsh/7.1.4/run deleted file mode 100644 index 02a0be7..0000000 --- a/packages/pwsh/7.1.4/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -pwsh "$@" diff --git a/packages/pwsh/7.1.4/test.ps1 b/packages/pwsh/7.1.4/test.ps1 deleted file mode 100644 index f0a4be3..0000000 --- a/packages/pwsh/7.1.4/test.ps1 +++ /dev/null @@ -1 +0,0 @@ -echo "OK" diff --git a/packages/rscript/4.1.1/build.sh b/packages/rscript/4.1.1/build.sh deleted file mode 100755 index 9837c22..0000000 --- a/packages/rscript/4.1.1/build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -PREFIX=$(realpath $(dirname $0)) - -mkdir build -cd build - -curl https://cloud.r-project.org/src/base/R-4/R-4.1.1.tar.gz -o R.tar.gz -tar xzf R.tar.gz --strip-components 1 - -./configure --prefix="$PREFIX" --with-x=no -make -j$(nproc) -make install -j$(nproc) - -cd ../ -rm -rf build diff --git a/packages/rscript/4.1.1/environment b/packages/rscript/4.1.1/environment deleted file mode 100644 index 977a5e8..0000000 --- a/packages/rscript/4.1.1/environment +++ /dev/null @@ -1 +0,0 @@ -export PATH=$PWD/bin:$PATH diff --git a/packages/rscript/4.1.1/metadata.json b/packages/rscript/4.1.1/metadata.json deleted file mode 100644 index db16a76..0000000 --- a/packages/rscript/4.1.1/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "rscript", - "version": "4.1.1", - "aliases": ["r"] -} diff --git a/packages/rscript/4.1.1/run b/packages/rscript/4.1.1/run deleted file mode 100644 index d122eb8..0000000 --- a/packages/rscript/4.1.1/run +++ /dev/null @@ -1,2 +0,0 @@ -#/bin/bash -Rscript "$@" diff --git a/packages/rscript/4.1.1/test.r b/packages/rscript/4.1.1/test.r deleted file mode 100644 index 9273f27..0000000 --- a/packages/rscript/4.1.1/test.r +++ /dev/null @@ -1 +0,0 @@ -cat('OK') diff --git a/packages/vlang/0.1.13/run b/packages/vlang/0.1.13/run index c999cca..18b6c05 100644 --- a/packages/vlang/0.1.13/run +++ b/packages/vlang/0.1.13/run @@ -6,9 +6,8 @@ export TMPDIR="$PWD" # Put instructions to run the runtime -filename=$1 - -rename 's/$/\.v/' $filename # Add .v extension +rename 's/$/\.v/' "$@" # Add .v extension +filename=$1.v shift -v run $filename.v "$@" +v run $filename "$@" \ No newline at end of file diff --git a/piston b/piston index 28e18db..7e3a469 100755 --- a/piston +++ b/piston @@ -23,23 +23,22 @@ case $1 in echo " start Starts piston" echo " stop Stops piston" echo " restart Restarts piston" - echo " bash Opens a bash shell for the piston_api container" echo echo " update Fetches and applies latest updates" echo echo " Passthrough to piston cli tool" - echo + echo echo "Development Commands:" - + if [ $PISTON_ENV == dev ]; then - + echo " clean-pkgs Clean any package build artifacts on disk" echo " clean-repo Remove all packages from local repo" echo " build-pkg Build a package" echo " rebuild Build and restart the docker container" else - + echo " Switch to developement environment for more info" echo " > piston select dev" @@ -53,7 +52,6 @@ case $1 in restart) docker_compose restart ;; start) docker_compose up -d ;; stop) docker_compose down ;; - bash) docker_compose exec api /bin/bash ;; rebuild) docker_compose build && docker_compose up -d ;; @@ -79,4 +77,4 @@ case $1 in cd ../ node cli/index.js "$@" ;; -esac +esac \ No newline at end of file diff --git a/readme.md b/readme.md index f43f70a..1a0f846 100644 --- a/readme.md +++ b/readme.md @@ -33,8 +33,7 @@ Supported LanguagesPrinciplesSecurity • - License • - Documentation + License --- @@ -66,9 +65,6 @@ The following are approved and endorsed extensions/utilities to the core Piston - [I Run Code](https://github.com/engineer-man/piston-bot), a Discord bot used in 4100+ servers to handle arbitrary code evaluation in Discord. To get this bot in your own server, go here: https://emkc.org/run. - [Piston CLI](https://github.com/Shivansh-007/piston-cli), a universal shell supporting code highlighting, files, and interpretation without the need to download a language. -- [Node Piston Client](https://github.com/dthree/node-piston), a Node.js wrapper for accessing the Piston API. -- [Piston4J](https://github.com/the-codeboy/Piston4J), a Java wrapper for accessing the Piston API. -- [Pyston](https://github.com/ffaanngg/pyston), a Python wrapper for accessing the Piston API.
@@ -88,9 +84,7 @@ POST https://emkc.org/api/v2/piston/execute > Important Note: The Piston API is rate limited to 5 requests per second. If you have a need for more requests than that > and it's for a good cause, please reach out to me (EngineerMan#0001) on [Discord](https://discord.gg/engineerman) -> so we can discuss potentially getting you an unlimited key. What is and isn't a good cause is up to me, but, in general -> if your project is a) open source, b) helping people at no cost to them, and c) not likely to use tons of resources -> thereby impairing another's ability to enjoy Piston, you'll likely be granted a key. +> so we can discuss potentially getting you an unlimited key.
@@ -102,7 +96,7 @@ POST https://emkc.org/api/v2/piston/execute - Docker - Docker Compose -- Node JS (>= 13, preferably >= 15) +- Node JS ### After system dependencies are installed, clone this repository: @@ -141,22 +135,6 @@ docker run \ ghcr.io/engineer-man/piston ``` -## Piston for testing packages locally - -### Host System Package Dependencies - -- Same as [All In One](#All-In-One) - -### Installation - -```sh -# Build the Docker containers -./piston start - -# For more help -./piston help -``` -
# Usage @@ -348,7 +326,6 @@ Content-Type: application/json `perl`, `php`, `ponylang`, -`powershell`, `prolog`, `pure`, `pyth`, @@ -356,13 +333,11 @@ Content-Type: application/json `python2`, `raku`, `rockstar`, -`rscript`, `ruby`, `rust`, `scala`, `swift`, `typescript`, -`basic`, `vlang`, `yeethon`, `zig`, diff --git a/repo/Dockerfile b/repo/Dockerfile index 56ca59d..106fef4 100644 --- a/repo/Dockerfile +++ b/repo/Dockerfile @@ -8,8 +8,7 @@ RUN apt-get update && apt-get install -y unzip autoconf build-essential libssl-d util-linux pciutils usbutils coreutils binutils findutils grep libncurses5-dev \ libncursesw5-dev python3-pip libgmp-dev libmpfr-dev python2 libffi-dev gfortran\ libreadline-dev libblas-dev liblapack-dev libpcre3-dev libarpack2-dev libfftw3-dev \ - libglpk-dev libqhull-dev libqrupdate-dev libsuitesparse-dev libsundials-dev \ - libbz2-dev liblzma-dev libpcre2-dev && \ + libglpk-dev libqhull-dev libqrupdate-dev libsuitesparse-dev libsundials-dev && \ ln -sf /bin/bash /bin/sh && \ rm -rf /var/lib/apt/lists/* && \ update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2 @@ -18,3 +17,4 @@ ADD entrypoint.sh mkindex.sh / ENTRYPOINT ["bash","/entrypoint.sh"] CMD ["--no-build"] + diff --git a/shell.nix b/shell.nix index 339bead..47b2d12 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,5 @@ { pkgs ? import {} }: pkgs.mkShell { # nativeBuildInputs is usually what you want -- tools you need to run - nativeBuildInputs = with pkgs; [ nodejs-15_x jq mkdocs ]; + nativeBuildInputs = with pkgs; [ nodejs-15_x jq ]; }