Skip to content

Commit 1ee42b3

Browse files
committed
Sync run-in-docker.sh from generic-test-runner; move run-in-docker scripts into bin/
1 parent cd9730d commit 1ee42b3

4 files changed

Lines changed: 48 additions & 40 deletions

File tree

‎Dockerfile‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
FROM node:22-bookworm-slim@sha256:d415caac2f1f77b98caaf9415c5f807e14bc8d7bdea62561ea2fef4fbd08a73c AS runner
2-
# Node.js 22 (curently LTS)
3-
# Debian bookwork
1+
FROM node:lts-slim@sha256:cb4e8f7c443347358b7875e717c29e27bf9befc8f5a26cf18af3c3dec80e58c5 AS runner
2+
# lts-slim == 24.18.0-bookworm-slim
43

54
# fetch latest security updates
65
RUN set -ex; \
File renamed without changes.

‎bin/run-in-docker.sh‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env sh
2+
3+
# Synopsis:
4+
# Run the test runner on a solution using the test runner Docker image.
5+
# The test runner Docker image is built automatically.
6+
7+
# Arguments:
8+
# $1: exercise slug
9+
# $2: path to solution folder
10+
# $3: path to output directory
11+
12+
# Output:
13+
# Writes the test results to a results.json file in the passed-in output directory.
14+
# The test results are formatted according to the specifications at https://github.com/exercism/docs/blob/main/building/tooling/test-runners/interface.md
15+
16+
# Example:
17+
# ./bin/run-in-docker.sh two-fer path/to/solution/folder/ path/to/output/directory/
18+
19+
# Stop executing when a command returns a non-zero return code
20+
set -e
21+
22+
# If any required arguments is missing, print the usage and exit
23+
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
24+
echo "usage: ./bin/run-in-docker.sh exercise-slug path/to/solution/folder/ path/to/output/directory/"
25+
exit 1
26+
fi
27+
28+
slug="$1"
29+
solution_dir=$(realpath "${2%/}")
30+
output_dir=$(realpath "${3%/}")
31+
32+
# Create the output directory if it doesn't exist
33+
mkdir -p "${output_dir}"
34+
35+
# Build the Docker image
36+
docker build --rm -t exercism/javascript-test-runner .
37+
38+
# Run the Docker image using the settings mimicking the production environment
39+
docker run \
40+
--rm \
41+
--network none \
42+
--read-only \
43+
--mount type=bind,src="${solution_dir}",dst=/solution \
44+
--mount type=bind,src="${output_dir}",dst=/output \
45+
--mount type=tmpfs,dst=/tmp \
46+
exercism/javascript-test-runner "${slug}" /solution /output

‎run-in-docker.sh‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)