libc-rs/ci/run-docker.sh

43 lines
940 B
Bash
Raw Normal View History

2018-11-19 15:49:56 +01:00
#!/usr/bin/env sh
# Small script to run tests for a target (or all targets) inside all the
# respective docker images.
set -ex
run() {
2018-11-19 15:49:56 +01:00
echo "Building docker container for target ${1}"
# use -f so we can use ci/ as build context
2018-11-19 15:49:56 +01:00
docker build -t libc -f "ci/docker/${1}/Dockerfile" ci/
mkdir -p target
if [ -w /dev/kvm ]; then
2018-11-19 15:49:56 +01:00
kvm="--volume /dev/kvm:/dev/kvm"
else
kvm=""
fi
2018-11-19 15:49:56 +01:00
docker run \
2018-11-19 15:49:56 +01:00
--user "$(id -u)":"$(id -g)" \
--rm \
2017-08-22 07:48:18 +02:00
--init \
2018-11-19 15:49:56 +01:00
--volume "${HOME}/.cargo":/cargo \
$kvm \
--env CARGO_HOME=/cargo \
2018-11-19 15:49:56 +01:00
--volume "$(rustc --print sysroot)":/rust:ro \
--volume "$(pwd)":/checkout:ro \
--volume "$(pwd)"/target:/checkout/target \
--env CARGO_TARGET_DIR=/checkout/target \
--workdir /checkout \
libc \
2018-11-19 15:49:56 +01:00
ci/run.sh "${1}"
}
2018-11-19 15:49:56 +01:00
if [ -z "${1}" ]; then
for d in ci/docker/*; do
run "${d}"
done
else
2018-11-19 15:49:56 +01:00
run "${1}"
fi