This commit is contained in:
Mathieu David 2016-04-25 15:51:27 +02:00
commit 7f34512751
4 changed files with 125 additions and 82 deletions

View File

@ -1,6 +1,6 @@
sudo: false sudo: false
language: rust language: generic
env: env:
global: global:
@ -10,73 +10,59 @@ matrix:
include: include:
# Stable channel # Stable channel
- os: osx - os: osx
env: TARGET=i686-apple-darwin env: TARGET=i686-apple-darwin CHANNEL=stable
rust: stable
- os: linux - os: linux
env: TARGET=i686-unknown-linux-gnu env: TARGET=i686-unknown-linux-gnu CHANNEL=stable
rust: stable
addons: addons:
apt: apt:
packages: &i686_unknown_linux_gnu packages: &i686_unknown_linux_gnu
- gcc-multilib - gcc-multilib
- os: osx - os: osx
env: TARGET=x86_64-apple-darwin env: TARGET=x86_64-apple-darwin CHANNEL=stable
rust: stable
- os: linux - os: linux
env: TARGET=x86_64-unknown-linux-gnu env: TARGET=x86_64-unknown-linux-gnu CHANNEL=stable
rust: stable
addons: addons:
apt: apt:
packages: packages:
- nodejs - nodejs
- npm - npm
- os: linux - os: linux
env: TARGET=x86_64-unknown-linux-musl env: TARGET=x86_64-unknown-linux-musl CHANNEL=stable
rust: stable
# Beta channel # Beta channel
- os: osx - os: osx
env: TARGET=i686-apple-darwin env: TARGET=i686-apple-darwin CHANNEL=beta
rust: beta
- os: linux - os: linux
env: TARGET=i686-unknown-linux-gnu env: TARGET=i686-unknown-linux-gnu CHANNEL=beta
rust: beta
addons: addons:
apt: apt:
packages: *i686_unknown_linux_gnu packages: *i686_unknown_linux_gnu
- os: osx - os: osx
env: TARGET=x86_64-apple-darwin env: TARGET=x86_64-apple-darwin CHANNEL=beta
rust: beta
- os: linux - os: linux
env: TARGET=x86_64-unknown-linux-gnu env: TARGET=x86_64-unknown-linux-gnu CHANNEL=beta
rust: beta
- os: linux - os: linux
env: TARGET=x86_64-unknown-linux-musl env: TARGET=x86_64-unknown-linux-musl CHANNEL=beta
rust: beta
# Nightly channel # Nightly channel
- os: osx - os: osx
env: TARGET=i686-apple-darwin env: TARGET=i686-apple-darwin CHANNEL=nightly
rust: nightly
- os: linux - os: linux
env: TARGET=i686-unknown-linux-gnu env: TARGET=i686-unknown-linux-gnu CHANNEL=nightly
rust: nightly
addons: addons:
apt: apt:
packages: *i686_unknown_linux_gnu packages: *i686_unknown_linux_gnu
- os: osx - os: osx
env: TARGET=x86_64-apple-darwin env: TARGET=x86_64-apple-darwin CHANNEL=nightly
rust: nightly
- os: linux - os: linux
env: TARGET=x86_64-unknown-linux-gnu env: TARGET=x86_64-unknown-linux-gnu CHANNEL=nightly
rust: nightly
- os: linux - os: linux
env: TARGET=x86_64-unknown-linux-musl env: TARGET=x86_64-unknown-linux-musl CHANNEL=nightly
rust: nightly
install: install:
- sh ci/install.sh - export PATH="$PATH:$HOME/.cargo/bin"
- bash ci/install.sh
script: script:
- sh ci/script.sh - bash ci/script.sh
after_success: after_success:
- test $TRAVIS_PULL_REQUEST == "false" && - test $TRAVIS_PULL_REQUEST == "false" &&
@ -87,7 +73,7 @@ after_success:
bash deploy.sh bash deploy.sh
before_deploy: before_deploy:
- sh ci/before_deploy.sh - bash ci/before_deploy.sh
deploy: deploy:
provider: releases provider: releases
@ -98,7 +84,7 @@ deploy:
skip_cleanup: true skip_cleanup: true
# deploy when a new tag is pushed # deploy when a new tag is pushed
on: on:
condition: $TRAVIS_RUST_VERSION = stable condition: $CHANNEL = stable
tags: true tags: true
notifications: notifications:

View File

@ -2,12 +2,31 @@
set -ex set -ex
cargo build --target $TARGET --release mktempd() {
echo $(mktemp -d 2>/dev/null || mktemp -d -t tmp)
}
mkdir staging mk_artifacts() {
cargo build --target $TARGET --release
}
cp target/$TARGET/release/mdbook staging mk_tarball() {
local td=$(mktempd)
local out_dir=$(pwd)
cd staging cp target/$TARGET/release/mdbook $td
tar czf ../${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz * pushd $td
tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz *
popd $td
rm -r $td
}
main() {
mk_artifacts
mk_tarball
}
main

View File

@ -2,32 +2,57 @@
set -ex set -ex
case $TARGET in case "$TRAVIS_OS_NAME" in
# Install standard libraries needed for cross compilation linux)
i686-apple-darwin | \ host=x86_64-unknown-linux-gnu
i686-unknown-linux-gnu | \
x86_64-unknown-linux-musl)
case $TRAVIS_RUST_VERSION in
stable)
# e.g. 1.6.0
version=$(rustc -V | cut -d' ' -f2)
;;
*)
version=$TRAVIS_RUST_VERSION
;;
esac
tarball=rust-std-${version}-${TARGET}
curl -Os http://static.rust-lang.org/dist/${tarball}.tar.gz
tar xzf ${tarball}.tar.gz
${tarball}/install.sh --prefix=$(rustc --print sysroot)
rm -r ${tarball}
rm ${tarball}.tar.gz
;; ;;
# Nothing to do for native builds osx)
*) host=x86_64-apple-darwin
;; ;;
esac esac
mktempd() {
echo $(mktemp -d 2>/dev/null || mktemp -d -t tmp)
}
install_rustup() {
local td=$(mktempd)
pushd $td
curl -O https://static.rust-lang.org/rustup/dist/$host/rustup-setup
chmod +x rustup-setup
./rustup-setup -y
popd
rm -r $td
rustup default $CHANNEL
rustc -V
cargo -V
}
install_standard_crates() {
if [ "$host" != "$TARGET" ]; then
if [ ! "$CHANNEL" = "stable" ]; then
rustup target add $TARGET
else
local version=$(rustc -V | cut -d' ' -f2)
local tarball=rust-std-${version}-${TARGET}
local td=$(mktempd)
curl -s https://static.rust-lang.org/dist/${tarball}.tar.gz | \
tar --strip-components 1 -C $td -xz
$td/install.sh --prefix=$(rustc --print sysroot)
rm -r $td
fi
fi
}
main() {
install_rustup
install_standard_crates
}
main

View File

@ -2,23 +2,36 @@
set -ex set -ex
case "$TRAVIS_OS_NAME" in # NOTE Workaround for rust-lang/rust#31907 - disable doc tests when cross compiling
linux) # This has been fixed in the nightly channel but it would take a while to reach the other channels
host=x86_64-unknown-linux-gnu disable_cross_doctests() {
;; local host
osx) case "$TRAVIS_OS_NAME" in
host=x86_64-apple-darwin linux)
;; host=x86_64-unknown-linux-gnu
esac ;;
osx)
host=x86_64-apple-darwin
;;
esac
# NOTE Workaround for rust-lang/rust#31907 - disable doc tests when crossing if [ "$host" != "$TARGET" ] && [ "$CHANNEL" != "nightly" ]; then
if [ "$host" != "$TARGET" ]; then if [ "$TRAVIS_OS_NAME" = "osx" ]; then
if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install gnu-sed --default-names
brew install gnu-sed --default-names fi
find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g'
fi fi
}
find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g' run_test_suite() {
fi cargo build --target $TARGET --verbose
cargo test --target $TARGET --verbose
}
cargo build --target $TARGET --verbose main() {
cargo test --target $TARGET --verbose disable_cross_doctests
run_test_suite
}
main