-
-
Notifications
You must be signed in to change notification settings - Fork 9
Port to spago from bower/pulp #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| .git/ | ||
| .github/ | ||
| tests/ | ||
| # These directories are created during the install/build step inside the | ||
| # container (see Dockerfile). We don't want to copy any leftovers from the | ||
| # local file-system here. | ||
| pre-compiled/.spago | ||
| pre-compiled/node_modules | ||
| pre-compiled/output | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,3 @@ | ||
| *~ | ||
| .*.swp | ||
| *.cabal | ||
| stack.yaml | ||
| tests/*/node_modules | ||
| tests/*/bower_components | ||
| tests/*/.pulp-cache/ | ||
| tests/*/output/ | ||
| tests/*/results.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,21 @@ | ||
| FROM node:16-buster-slim | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get install -y git jq libncurses5 && \ | ||
| apt-get purge --auto-remove -y && \ | ||
| apt-get clean && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends \ | ||
| ca-certificates=20200601~deb10u2 \ | ||
| git=1:2.20.1-2+deb10u3 \ | ||
| jq=1.5+dfsg-2+b1 \ | ||
| libncurses5=6.1+20181013-2+deb10u2 \ | ||
| && apt-get purge --auto-remove -y \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /opt/test-runner | ||
| # Pre-compile exercise dependencies | ||
| WORKDIR /opt/test-runner/pre-compiled | ||
| COPY pre-compiled . | ||
| RUN npm install && npx spago install && npx spago build --deps-only | ||
|
|
||
| ENV PATH="/opt/test-runner/node_modules/.bin:$PATH" | ||
|
|
||
| COPY pre-compiled/package.json pre-compiled/package-lock.json ./ | ||
| RUN npm install | ||
|
|
||
| COPY pre-compiled/bower.json . | ||
| RUN bower install --allow-root | ||
|
|
||
| COPY pre-compiled/ . | ||
| RUN pulp build | ||
|
|
||
| COPY . . | ||
| ENTRYPOINT ["/opt/test-runner/bin/run.sh"] | ||
| # Setup bin directory | ||
| WORKDIR /opt/test-runner/bin | ||
| COPY bin/run.sh bin/run-tests.sh ./ | ||
| ENTRYPOINT ["/opt/test-runner/bin/run.sh"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| The Docker image for automatically run tests on PureScript solutions submitted | ||
| to [exercism][web-exercism]. | ||
|
|
||
| This repository contains the Java test runner, which implements the | ||
| This repository contains the PureScript test runner, which implements the | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops! |
||
| [test runner interface][test-runner-interface]. | ||
|
|
||
|
|
||
|
|
@@ -15,3 +15,22 @@ To run a solution's test in the Docker container, do the following: | |
|
|
||
| [test-runner-interface]: https://github.com/exercism/automated-tests/blob/master/docs/interface.md | ||
| [web-exercism]: https://exercism.io/ | ||
|
|
||
|
|
||
| ## Design Goal and Implementation | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great to have this explanation! |
||
|
|
||
| Due to the sandboxed environment we need to prepare everything we need in | ||
| advance. All the PureScript packages that may be used for a solution are | ||
| downloaded and pre-compiled. To make this happen we've setup a basic spago | ||
| project under `./pre-compiled`. Note that the package-set set in | ||
| `packages.dhall` must correspond with the one used by in the exercises | ||
| repository (exercism/purescript). This directory is copied into the Docker | ||
| image and from there all dependencies are installed and compiled. All the | ||
| necessary bits are then available to be used by `bin/run.sh` to setup a spago | ||
| project to build the submitted solution. | ||
|
|
||
| The `bin/run.sh` script will piece together a spago project to build and test | ||
| the submitted solution. The project is built under `/tmp/build` which is | ||
| mounted as a `tmpfs` which is required for write-access. A `tmpfs` is also | ||
| speedier than reading from or writing to a `bind` mount. See `docs/spago.md` | ||
| for more details on running spago in a sandbox. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/usr/bin/env sh | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Synopsis: | ||
| # Run the test runner on a solution using the test runner Docker image. | ||
|
|
@@ -11,20 +11,24 @@ | |
|
|
||
| # Output: | ||
| # Writes the test results to a results.json file in the passed-in output directory. | ||
| # The test results are formatted according to the specifications at https://github.com/exercism/docs/blob/main/building/tooling/test-runners/interface.md | ||
| # The test results are formatted according to the specifications at | ||
| # https://github.com/exercism/docs/blob/main/building/tooling/test-runners/interface.md | ||
|
|
||
| # Example: | ||
| # ./bin/run-in-docker.sh two-fer /absolute/path/to/two-fer/solution/folder/ /absolute/path/to/output/directory/ | ||
|
|
||
| set -o pipefail | ||
| set -u | ||
|
|
||
| # If any required arguments is missing, print the usage and exit | ||
| if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then | ||
| if [ $# != 3 ]; then | ||
| echo "usage: ./bin/run-in-docker.sh exercise-slug /absolute/path/to/solution/folder/ /absolute/path/to/output/directory/" | ||
| exit 1 | ||
| fi | ||
|
|
||
| slug="$1" | ||
| input_dir="${2%/}" | ||
| output_dir="${3%/}" | ||
| slug=${1} | ||
| input_dir=${2} | ||
| output_dir=${3} | ||
|
|
||
| # Create the output directory if it doesn't exist | ||
| mkdir -p "${output_dir}" | ||
|
|
@@ -36,7 +40,7 @@ docker build --rm -t exercism/test-runner . | |
| docker run \ | ||
| --read-only \ | ||
| --network none \ | ||
| --mount type=bind,src="${input_dir}",dst=/solution \ | ||
| --mount type=bind,src="${output_dir}",dst=/output \ | ||
| --mount type=tmpfs,dst=/tmp \ | ||
| exercism/test-runner "${slug}" /solution /output | ||
| --mount type=bind,source="${input_dir}",destination=/solution \ | ||
| --mount type=bind,source="${output_dir}",destination=/output \ | ||
| --mount type=tmpfs,destination=/tmp \ | ||
|
Comment on lines
+43
to
+45
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the added explicitness! |
||
| exercism/test-runner "${slug}" /solution /output | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Synopsis: | ||
| # Test the test runner Docker image by running it against a predefined set of | ||
| # solutions with an expected output. | ||
| # The test runner Docker image is built automatically. | ||
|
|
||
| # Output: | ||
| # Outputs the diff of the expected test results against the actual test results | ||
| # generated by the test runner Docker image. | ||
|
|
||
| # Example: | ||
| # ./bin/run-tests-in-docker.sh | ||
|
|
||
| set -o pipefail | ||
| set -u | ||
|
|
||
| if [ $# != 1 ]; then | ||
| echo "Usage ${BASH_SOURCE[0]} /path/to/exercises" | ||
| exit 1 | ||
| fi | ||
|
|
||
| base_dir=$(builtin cd "${BASH_SOURCE%/*}/.." || exit; pwd) | ||
| exercises_dir="${1%/}" | ||
|
|
||
| # Build the Docker image | ||
| docker build --rm -t exercism/test-runner "${base_dir}" | ||
|
|
||
| for config in "${exercises_dir}"/*/*/.solution.dhall; do | ||
| exercise_dir=$(dirname "${config}") | ||
| slug=$(basename "${exercise_dir}") | ||
|
|
||
| echo "Working in ${exercise_dir}..." | ||
|
|
||
| "${base_dir}/bin/run-in-docker.sh" "${slug}" "${exercise_dir}" /tmp | ||
| done |
Uh oh!
There was an error while loading. Please reload this page.