Merge pull request #37 from japaric/docker

CI: run all Linux targets inside docker
This commit is contained in:
Jorge Aparicio 2016-08-13 18:53:08 -05:00 committed by GitHub
commit f300480aa9
4 changed files with 45 additions and 202 deletions

View File

@ -1,111 +1,44 @@
dist: trusty
language: generic language: generic
sudo: false services: docker
sudo: required
matrix: matrix:
include: include:
- env: TARGET=thumbv6m-none-eabi
os: linux
dist: trusty
sudo: required
- env: TARGET=thumbv7m-none-eabi
os: linux
dist: trusty
sudo: required
- env: TARGET=thumbv7em-none-eabi
os: linux
dist: trusty
sudo: required
- env: TARGET=i586-unknown-linux-gnu
os: linux
services: docker
sudo: required
- env: TARGET=aarch64-unknown-linux-gnu - env: TARGET=aarch64-unknown-linux-gnu
os: linux os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- binfmt-support
- qemu-user-static
- env: TARGET=arm-unknown-linux-gnueabi - env: TARGET=arm-unknown-linux-gnueabi
os: linux os: linux
sudo: required
addons:
apt:
packages:
- binfmt-support
- gcc-arm-linux-gnueabi
- libc6-armel-cross
- libc6-dev-armel-cross
- qemu-user-static
- env: TARGET=arm-unknown-linux-gnueabihf - env: TARGET=arm-unknown-linux-gnueabihf
os: linux os: linux
sudo: required
addons:
apt:
packages: &armhf
- binfmt-support
- gcc-arm-linux-gnueabihf
- libc6-armhf-cross
- libc6-dev-armhf-cross
- qemu-user-static
- env: TARGET=armv7-unknown-linux-gnueabihf - env: TARGET=armv7-unknown-linux-gnueabihf
os: linux os: linux
sudo: required - env: TARGET=i586-unknown-linux-gnu
addons: os: linux
apt:
packages: *armhf
- env: TARGET=i686-apple-darwin - env: TARGET=i686-apple-darwin
os: osx os: osx
- env: TARGET=i686-unknown-linux-gnu - env: TARGET=i686-unknown-linux-gnu
os: linux os: linux
addons:
apt:
packages:
- gcc-multilib
- env: TARGET=mips-unknown-linux-gnu - env: TARGET=mips-unknown-linux-gnu
os: linux os: linux
services: docker
sudo: required
- env: TARGET=mipsel-unknown-linux-gnu - env: TARGET=mipsel-unknown-linux-gnu
os: linux os: linux
services: docker
sudo: required
- env: TARGET=powerpc-unknown-linux-gnu - env: TARGET=powerpc-unknown-linux-gnu
os: linux os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- binfmt-support
- gcc-powerpc-linux-gnu
- libc6-powerpc-cross
- libc6-dev-powerpc-cross
- qemu-user-static
- env: TARGET=powerpc64-unknown-linux-gnu - env: TARGET=powerpc64-unknown-linux-gnu
os: linux os: linux
services: docker
sudo: required
- env: TARGET=powerpc64le-unknown-linux-gnu - env: TARGET=powerpc64le-unknown-linux-gnu
os: linux os: linux
services: docker - env: TARGET=thumbv6m-none-eabi
sudo: required os: linux
- env: TARGET=thumbv7em-none-eabi
os: linux
- env: TARGET=thumbv7m-none-eabi
os: linux
- env: TARGET=x86_64-apple-darwin - env: TARGET=x86_64-apple-darwin
os: osx os: osx
- env: TARGET=x86_64-unknown-linux-gnu - env: TARGET=x86_64-unknown-linux-gnu
os: linux os: linux
allow_failures:
# Issue #2. Flaky test
- env: TARGET=arm-unknown-linux-gnueabi
os: linux
# Issue #2. Flaky test
- env: TARGET=arm-unknown-linux-gnueabihf
os: linux
# Issue #2. Flaky test
- env: TARGET=armv7-unknown-linux-gnueabihf
os: linux
before_install: before_install:
- export PATH="$PATH:$HOME/.cargo/bin" - export PATH="$PATH:$HOME/.cargo/bin"

View File

@ -28,26 +28,12 @@ case $TARGET in
export PREFIX=arm-linux-gnueabihf- export PREFIX=arm-linux-gnueabihf-
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf
;; ;;
i586-unknown-linux-gnu)
# NOTE $DOCKER values: 'y' (yes, call docker), 'i' (inside a docker container) or 'n' ("no)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
;;
mips-unknown-linux-gnu) mips-unknown-linux-gnu)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
export PREFIX=mips-linux-gnu- export PREFIX=mips-linux-gnu-
export QEMU=qemu-mips
export QEMU_LD_PREFIX=/usr/mips-linux-gnu export QEMU_LD_PREFIX=/usr/mips-linux-gnu
;; ;;
mipsel-unknown-linux-gnu) mipsel-unknown-linux-gnu)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
export PREFIX=mipsel-linux-gnu- export PREFIX=mipsel-linux-gnu-
export QEMU=qemu-mipsel
export QEMU_LD_PREFIX=/usr/mipsel-linux-gnu export QEMU_LD_PREFIX=/usr/mipsel-linux-gnu
;; ;;
powerpc-unknown-linux-gnu) powerpc-unknown-linux-gnu)
@ -55,21 +41,12 @@ case $TARGET in
export QEMU_LD_PREFIX=/usr/powerpc-linux-gnu export QEMU_LD_PREFIX=/usr/powerpc-linux-gnu
;; ;;
powerpc64-unknown-linux-gnu) powerpc64-unknown-linux-gnu)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
export PREFIX=powerpc64-linux-gnu- export PREFIX=powerpc64-linux-gnu-
export QEMU=qemu-ppc64
export QEMU_LD_PREFIX=/usr/powerpc64-linux-gnu export QEMU_LD_PREFIX=/usr/powerpc64-linux-gnu
;; ;;
powerpc64le-unknown-linux-gnu) powerpc64le-unknown-linux-gnu)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
export PREFIX=powerpc64le-linux-gnu- export PREFIX=powerpc64le-linux-gnu-
export QEMU=qemu-ppc64le
export QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu export QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu
# Issue #2. QEMU doesn't work
export RUN_TESTS=n export RUN_TESTS=n
;; ;;
thumbv*-none-eabi) thumbv*-none-eabi)

View File

@ -2,77 +2,33 @@ set -ex
. $(dirname $0)/env.sh . $(dirname $0)/env.sh
install_deps() {
if [[ ${DOCKER} == "i" ]]; then
apt-get update
apt-get install -y --no-install-recommends \
ca-certificates curl
fi
}
install_qemu() { install_qemu() {
case $TARGET in case ${QEMU_ARCH:-$TRAVIS_OS_NAME} in
mipsel-unknown-linux-gnu | \ i386)
powerpc64le-unknown-linux-gnu) dpkg --add-architecture $QEMU_ARCH
apt-get install -y --no-install-recommends \ apt-get install -y --no-install-recommends \
qemu-user binfmt-support qemu-user-static:$QEMU_ARCH
;; ;;
mips-unknown-linux-gnu | \ linux)
powerpc64-unknown-linux-gnu)
dpkg --add-architecture i386
apt-get update apt-get update
apt-get install -y --no-install-recommends \ apt-get install -y --no-install-recommends \
qemu-user:i386 binfmt-support qemu-user-static
;; ;;
esac esac
} }
install_binutils() { install_binutils() {
case $TRAVIS_OS_NAME in if [[ $TRAVIS_OS_NAME == "osx" ]]; then
osx)
brew install binutils brew install binutils
;; fi
esac
case $TARGET in
thumbv*-none-eabi)
sudo apt-get install -y --no-install-recommends \
gcc-arm-none-eabi
;;
esac
}
install_c_toolchain() {
case $TARGET in
aarch64-unknown-linux-gnu)
sudo apt-get install -y --no-install-recommends \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross
;;
i586-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc libc6-dev-i386 lib32gcc-5-dev
;;
mips-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc gcc-mips-linux-gnu libc6-dev libc6-dev-mips-cross
;;
mipsel-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc gcc-mipsel-linux-gnu libc6-dev libc6-dev-mipsel-cross
;;
powerpc64-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc gcc-powerpc64-linux-gnu libc6-dev libc6-dev-ppc64-cross
;;
powerpc64le-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc gcc-powerpc64le-linux-gnu libc6-dev libc6-dev-ppc64el-cross
;;
esac
} }
install_rust() { install_rust() {
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=nightly curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=nightly
else
rustup default nightly
fi
rustc -V rustc -V
cargo -V cargo -V
@ -86,35 +42,18 @@ add_rustup_target() {
install_xargo() { install_xargo() {
if [[ $CARGO == "xargo" ]]; then if [[ $CARGO == "xargo" ]]; then
sudo apt-get install -y --no-install-recommends \
libssh2-1
curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \ curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \
bash -s -- --from japaric/xargo --at $HOME/.cargo/bin bash -s -- --from japaric/xargo --at /root/.cargo/bin
fi
}
configure_cargo() {
if [[ $PREFIX ]]; then
${PREFIX}gcc -v
mkdir -p .cargo
cat >>.cargo/config <<EOF
[target.$TARGET]
linker = "${PREFIX}gcc"
EOF
fi fi
} }
main() { main() {
if [[ ${DOCKER:-n} != "y" ]]; then if [[ $TRAVIS_OS_NAME == "osx" || ${IN_DOCKER_CONTAINER:-n} == "y" ]]; then
install_deps
install_qemu install_qemu
install_binutils install_binutils
install_c_toolchain
install_rust install_rust
add_rustup_target add_rustup_target
install_xargo install_xargo
configure_cargo
fi fi
} }

View File

@ -7,26 +7,6 @@ build() {
${CARGO:-cargo} build --target $TARGET --release ${CARGO:-cargo} build --target $TARGET --release
} }
run_tests() {
if [[ $QEMU_LD_PREFIX ]]; then
export RUST_TEST_THREADS=1
fi
if [[ $QEMU ]]; then
cargo test --target $TARGET --no-run
if [[ ${RUN_TESTS:-y} == "y" ]]; then
$QEMU target/**/debug/rustc_builtins-*
fi
cargo test --target $TARGET --release --no-run
if [[ ${RUN_TESTS:-y} == "y" ]]; then
$QEMU target/**/release/rustc_builtins-*
fi
elif [[ ${RUN_TESTS:-y} == "y" ]]; then
cargo test --target $TARGET
cargo test --target $TARGET --release
fi
}
inspect() { inspect() {
$PREFIX$NM -g --defined-only target/**/debug/*.rlib $PREFIX$NM -g --defined-only target/**/debug/*.rlib
set +e set +e
@ -35,17 +15,31 @@ inspect() {
set -e set -e
} }
run_tests() {
if [[ $QEMU_LD_PREFIX ]]; then
export RUST_TEST_THREADS=1
fi
if [[ ${RUN_TESTS:-y} == "y" ]]; then
cargo test --target $TARGET
cargo test --target $TARGET --release
fi
}
main() { main() {
if [[ $DOCKER == "y" ]]; then if [[ $TRAVIS_OS_NAME == "linux" && ${IN_DOCKER_CONTAINER:-n} == "n" ]]; then
local tag=2016-08-13
docker run \ docker run \
-e DOCKER=i \ --privileged \
-e IN_DOCKER_CONTAINER=y \
-e TARGET=$TARGET \ -e TARGET=$TARGET \
-e TRAVIS_OS_NAME=$TRAVIS_OS_NAME \ -e TRAVIS_OS_NAME=$TRAVIS_OS_NAME \
-v $(pwd):/mnt \ -v $(pwd):/mnt \
ubuntu:16.04 \ japaric/rustc-builtins:$tag \
sh -c 'set -ex; sh -c 'set -ex;
cd /mnt; cd /mnt;
export PATH="$PATH:$HOME/.cargo/bin"; export PATH="$PATH:/root/.cargo/bin";
bash ci/install.sh; bash ci/install.sh;
bash ci/script.sh' bash ci/script.sh'
else else