-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrun-in-docker.sh
executable file
·37 lines (30 loc) · 1.25 KB
/
run-in-docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# Synopsis:
# Test runner for run.sh in a docker container
# Takes the same arguments as run.sh (EXCEPT THAT SOLUTION AND OUTPUT PATH ARE RELATIVE)
# Builds the Dockerfile
# Runs the docker image passing along the initial arguments
# Arguments:
# $1: exercise slug
# $2: **RELATIVE** path to solution folder (without trailing slash)
# $3: **RELATIVE** path to output directory (without trailing slash)
# Output:
# Writes the tests output to the output directory
# Example:
# ./run-in-docker.sh two-fer ./relative/path/to/two-fer/solution/folder/ ./relative/path/to/output-directory/
# ./run-in-docker.sh two-fer ./test/fixtures/two-fer/pass ./test/fixtures/two-fer/pass
# If arguments not provided, print usage and exit
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "usage: ./run-in-docker.sh two-fer ./relative/path/to/two-fer/solution/folder/ ./relative/path/to/output-directory/"
fi
# build docker image
docker build -t javascript-test-runner .
# run image passing the arguments
# --mount type=tmpfs,dst=/tmp \
docker run \
--network none \
--read-only \
--mount type=bind,src=$PWD/$2,dst=/solution/ \
--mount type=bind,src=$PWD/$3,dst=/output/ \
--tmpfs /tmp:exec \
javascript-test-runner $1 /solution/ /output/