Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions bin/run-tests-in-docker.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env sh

# Synopsis:
# Test the analyzer Docker image by running it against a predefined set of
# Test the analyzer Docker image by running it against a predefined set of
# solutions with an expected output.
# The analyzer Docker image is built automatically.

Expand All @@ -15,16 +15,34 @@
# Stop executing when a command returns a non-zero return code
set -e

mnt_opt=""
run_opt=""
if ! command -v docker > /dev/null ; then
if ! command -v podman > /dev/null ; then
echo "Docker or Podman must be installed to run the tests in a container."
exit 1
fi
# Docker is unavailable, use Podman
docker() {
podman "$@"
}
# for SELinux systems, permit container access to mounted directories
mnt_opt=",Z"
# use same user ID for container, avoids file ownership problems
run_opt="--userns=keep-id"
fi
Comment thread
senekor marked this conversation as resolved.

# Build the Docker image
docker build --rm -t exercism/rust-analyzer .

# Run the Docker image using the settings mimicking the production environment
docker run \
--rm \
--network none \
--mount type=bind,src="${PWD}/snippets",dst=/opt/analyzer/snippets \
--mount type=bind,src="${PWD}/snippets,dst=/opt/analyzer/snippets$mnt_opt" \
--mount type=tmpfs,dst=/tmp \
--volume "${PWD}/bin/run-tests.sh:/opt/analyzer/bin/run-tests.sh" \
--mount type=bind,src="${PWD}/bin/run-tests.sh,dst=/opt/analyzer/bin/run-tests.sh$mnt_opt" \
$run_opt \
--workdir /opt/analyzer \
--entrypoint /opt/analyzer/bin/run-tests.sh \
exercism/rust-analyzer
Loading