{"id":13858936,"url":"https://github.com/replit/polygott","last_synced_at":"2025-07-14T01:32:19.706Z","repository":{"id":35714639,"uuid":"151494178","full_name":"replit/polygott","owner":"replit","description":"Base Docker image for the Repl.it evaluation server","archived":true,"fork":false,"pushed_at":"2022-05-03T21:25:01.000Z","size":3274,"stargazers_count":390,"open_issues_count":45,"forks_count":104,"subscribers_count":51,"default_branch":"master","last_synced_at":"2024-08-06T03:06:07.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://replit.com","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/replit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-03T23:34:20.000Z","updated_at":"2024-07-28T12:34:10.000Z","dependencies_parsed_at":"2022-08-08T10:30:41.403Z","dependency_job_id":null,"html_url":"https://github.com/replit/polygott","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fpolygott","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fpolygott/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fpolygott/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Fpolygott/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/replit","download_url":"https://codeload.github.com/replit/polygott/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225938723,"owners_count":17548541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-05T03:02:26.834Z","updated_at":"2024-11-22T17:30:32.480Z","avatar_url":"https://github.com/replit.png","language":"Shell","readme":"# Polygott\n\n**Warning**: This repository is now obsolete. Replit is no longer developing\nPolygott and is fully betting on [nix](https://blog.replit.com/nix) to expose\ntools and languages on Repls. This repository will still exist for archiving\nand historical purposes.\n\n---\n\n## Overview\n\n[Replit.com] allows you to quickly get started with any programming language\nonline. In order to provide this capability, our evaluation server uses\n[Docker](https://www.docker.com/) with the\n[`buildx`](https://github.com/docker/buildx#installing) CLI plugin to ensure\nthat all these languages are installed with the appropriate environment set up.\n\nWe previously used a separate Docker image for each language, but\nconcluded that it was both simpler and more efficient to use a single\nimage which contains all supported languages simultaneously. The code\nnecessary to build this combined image, **Polygott**, resides in this\nrepository.  If you're lost and need some reference, we have\n[a blog](https://blog.replit.com/elisp) where we added elisp.\n\nBecause of the fact that building a monolithic image is unwieldy and takes too\nmuch time, the build itself is made of a directed graph of intermediate nodes,\nwhere each language is a node, and they all get stitched together at the end to\nbuild the final combined image.\n\n## Build and run\n\nYou can build either the entire image, a version that has a bundle of\nlanguages, and a version that is limited to a single language. The second one\nis used for CI, and the latter is recommended when you are adding or modifying\nsupport for a particular language, since building the entire image takes an\nextremely long time. Makefile targets are provided for each of these cases:\n\n    % make help\n    usage:\n      make image         Build Docker image with all languages\n      make image-ci      Build Docker image with all languages needed for CI\n      make image-LANG    Build Docker image with single language LANG\n      make run           Build and run image with all languages\n      make run-LANG      Build and run image with single language LANG\n      make test          Build and test all languages\n      make test-LANG     Build and test single language LANG\n      make changed-test  Build and test only changed/added languages\n      make help          Show this message\n\nAs you can see, there is a facility for testing that languages have\nbeen installed and configured correctly. This involves running\ncommands which are specified in the languages' configuration files,\nand checking that the output is as expected. To debug, you can also\nuse the `make run` and `make run-LANG` targets to launch shells within\nthe images.\n\nYou may want to bypass Docker's cache temporarily, for example to\ndebug an intermittent network error while building one of the\nlanguages. To do this, identify the `docker build` command which is\nrun by the Makefile, and run it yourself with the `--no-cache` flag.\n\nThe CI requires having up-to-date generated artifacts (the files in `out/`)\ncommitted to ensure a consistent Docker build environment. These will be\nrefreshed by running the tests, or by running `make -B build/stamps/out`).\n\n## Language configuration\n\nEach supported language has a\n[TOML](https://github.com/toml-lang/toml) file [in the `languages`\nsubdirectory](languages). The meaningful keys are as follows:\n\n### Mandatory\n\n* `entrypoint`: The name of the file which will be executed on\n  [Replit.com] when you press the Run button. This is used in the\n  `detect-language` script built into the Polygott image: if a file\n  exists with this name, then the project is detected to have this\n  language. (Ties are resolved by `popularity`.) It is also used by\n  the `run-project` script in order to identify the main file of the\n  project.\n* `extensions`: List of file extensions (use `\"py\"`, not `\".py\"`)\n  which files of this language may have. This is used in the\n  `detect-language` script built into the Polygott image: if a file\n  exists with one of these extensions, then the project is detected to\n  have this language. (Ties are resolved by `popularity`.)\n* `name`: The name of the language. The TOML file should then be named\n  `\u003cname\u003e.toml`. This is also what you pass to the Makefile's\n  `image-LANG` and `test-LANG` targets.\n\n### Optional\n\n* `aliases`: List of strings indicating alternate names for the\n  language, in addition to `name`. This is used to allow the\n  `run-language-server` script to accept `-l c++` in addition to `-l\n  cpp`, among other things.\n* `aptKeys`: List of PGP key IDs that must be passed to `apt-key` in\n  order for the custom `aptRepos` configured to be trusted. For\n  example, `\"09617FD37CC06B54\"`.\n* `aptRepos`: List of repository strings that must be passed to\n  `add-apt-repository` in order for the custom `packages` configured\n  to be available. For example, `\"deb\n  https://dist.crystal-lang.org/apt crystal main\"`.\n* `compile`\n  * `command`: The full command to compile the `entrypoint` file, as a\n    list, including the filename. This is run before the `run`\n    command.\n* `languageServer`\n  * `command`: Command to start an [LSP](https://langserver.org/)\n    language server, as a list. This is used in the\n    `run-language-server` script built into the Polygott image.\n* `packages`: List of additional Ubuntu packages to install for this\n  language. (Packages which are required by all or many languages\n  should be placed instead [in `packages.txt`](packages.txt).) [Check\n  the Ubuntu Bionic package\n  listing](https://packages.ubuntu.com/bionic/) to see what your\n  options are.\n* `popularity`: Floating-point number indicating how popular the\n  language is. Defaults to `2.0`. This is used in the\n  `detect-language` script built into the Polygott image: if a project\n  is detected as more than one language, the winner is chosen by\n  comparing popularity scores.\n* `run`: Required, unless you provide no `tests` or you have asked to\n  `skip` all of them.\n  * `command`: The full command to run the `entrypoint` file, as a\n    list, including the filename. It is run *after* the `compile`\n    command, if one is provided. This is used to run tests.\n* `runtimeSetup`: List of shell commands to be run by the\n  `polygott-lang-setup` script built into the Polygott image.\n* `setup`: List of shell commands to be run [in phase 2 of the build\n  process](gen/phase2.ejs), as post-install steps.\n* `tests`\n  * `TESTNAME`\n    * `code`: String to write to the `entrypoint` file before invoking\n      the `run` command.\n    * `output`: String expected to be written to stdout (**not**\n      stderr) by running the code.\n    * `skip`: Boolean, optional. If true, then the test is skipped.\n      This allows you to easily \"comment out\" a test if there is\n      something wrong with the infrastructure.\n* `versionCommand`: A command to output the version of the language,\n  as a list of strings. For example, `[\"kotlin\", \"-version\"]`. This is\n  used in the `polygott-survey` command built into the Polygott image.\n  (If `versionCommand` is omitted, some heuristics are used to guess\n  it.)\n\n## Build process\n\n* [The language configuration files](languages) are validated against\n  a [JSON Schema](https://json-schema.org/) specification located [in\n  `schema.json`](gen/schema.json).\n* [The `.ejs` files in the `gen` directory](gen) are transformed into\n  shell scripts using the language configuration via the\n  [EJS](https://ejs.co/) templating system. This is done by [a Node.js\n  script](gen/index.js) inside the Docker image.\n* The multi-stage [`Dockerfile`](gen/Dockerfile.ejs) is created from the\n  language configuration files.\n* Languages are installed in several phases. [In phase 0](gen/phase0.ejs),\n  shared packages [in `packages.txt`](packages.txt) are installed, as well as\n  APT keys and repositories are configured. In phase 1.0, `apt-get update -y`\n  is run, which can be reused in later phases. In phase 1.5, language-specific\n  packages are installed. [In phase 2](gen/phase2-per-lang.ejs),\n  language-specific `setup` commands are run.\n\n## Usage\n\nAside from all the language executables (`python3`, `ruby`, `rust`,\netc.), there are several additional scripts available within the\nDocker image. They are documented below.\n\n    polygott-self-test\n\nRun the tests defined in each language's configuration file, as in\n`make test` or `make test-LANG`. Always run all the tests, but if one\nof them fails, exit with a non-zero return code.\n\n    polygott-survey\n\nRun the `versionCommand` specified for every language, and output the\nresults in tabular format to stdout.\n\n    polygott-lang-setup [-l LANG]\n\nCopy the contents of `/opt/homes/LANG/` to `/home/runner/`, and run\nthe `runtimeSetup` commands for it, if any were provided. `LANG`\ndefaults to the output of `detect-language`.\n\n    detect-language\n\nTry to identify the language used by the project in the current\ndirectory. This first checks if the `entrypoint` file exists for any\nlanguage, and then checks if a file with any of the registered\n`extensions` exists for a language. If multiple languages match in\neither of those two phases, then the `popularity` of the two languages\nis used to resolve ties.\n\nOutput the language name to `stdout` if one is detected, otherwise do\nnothing.\n\n    run-project [-s] [-b] [-l LANG]\n\nExecute the `compile` and `run` commands on the `entrypoint` file in\nthe current directory. `LANG` defaults to the output of\n`detect-language`. If `-s` is passed, then the `entrypoint` file is\nwritten with the contents of stdin. If `-b` is passed, then some\nspecial logic is used instead of the `compile` and `run` commands;\n[see the source for details](gen/run-project.ejs).\n\n    run-language-server [-l LANG]\n\nRun the `languageServer` command configured in the language's\nconfiguration file. `LANG` defaults to the output of\n`detect-language`.\n\n## Deployment\n\nWhen a commit is merged to `master`, [CircleCI](https://circleci.com/)\nautomatically builds Polygott and pushes the image to [Docker\nHub](https://hub.docker.com/r/replco/polygott). A Replit\nengineer has to then push the new Polygott to production.\n\n[replit.com]: https://replit.com/\n","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Fpolygott","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freplit%2Fpolygott","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Fpolygott/lists"}