diff --git a/.travis.yml b/.travis.yml index 0c0355ae..75b85e71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,110 +1,42 @@ +language: rust sudo: false -language: generic +cache: cargo -env: - global: - - PROJECT_NAME=mdBook +rust: + - stable + - beta + - nightly -matrix: - include: - # Stable channel - - os: osx - env: TARGET=i686-apple-darwin CHANNEL=stable - - os: linux - env: TARGET=i686-unknown-linux-gnu CHANNEL=stable - addons: - apt: - packages: &i686_unknown_linux_gnu - - gcc-multilib - - os: osx - env: TARGET=x86_64-apple-darwin CHANNEL=stable - - os: linux - env: TARGET=x86_64-unknown-linux-gnu CHANNEL=stable - addons: - apt: - packages: - - nodejs - - os: linux - env: TARGET=x86_64-unknown-linux-musl CHANNEL=stable - dist: trusty - addons: - apt: - packages: &musl_packages - - musl - - musl-dev - - musl-tools - # Beta channel - - os: osx - env: TARGET=i686-apple-darwin CHANNEL=beta - - os: linux - env: TARGET=i686-unknown-linux-gnu CHANNEL=beta - addons: - apt: - packages: *i686_unknown_linux_gnu - - os: osx - env: TARGET=x86_64-apple-darwin CHANNEL=beta - - os: linux - env: TARGET=x86_64-unknown-linux-gnu CHANNEL=beta - - os: linux - env: TARGET=x86_64-unknown-linux-musl CHANNEL=beta - dist: trusty - addons: - apt: - packages: &musl_packages - - musl - - musl-dev - - musl-tools - # Nightly channel - - os: osx - env: TARGET=i686-apple-darwin CHANNEL=nightly - - os: linux - env: TARGET=i686-unknown-linux-gnu CHANNEL=nightly - addons: - apt: - packages: *i686_unknown_linux_gnu - - os: osx - env: TARGET=x86_64-apple-darwin CHANNEL=nightly - - os: linux - env: TARGET=x86_64-unknown-linux-gnu CHANNEL=nightly - - os: linux - env: TARGET=x86_64-unknown-linux-musl CHANNEL=nightly - dist: trusty - addons: - apt: - packages: &musl_packages - - musl - - musl-dev - - musl-tools - -install: - - export PATH="$PATH:$HOME/.cargo/bin" - - bash ci/install.sh +os: + - linux + - osx script: - - bash ci/script.sh + - cargo build --verbose + - cargo test --verbose after_success: + # Deploy the docs if the commit is on master - test "$TRAVIS_PULL_REQUEST" == "false" && test "$TRAVIS_BRANCH" == "master" && - test "$TARGET" == "x86_64-unknown-linux-gnu" && - test "$CHANNEL" = "stable" && + "$TRAVIS_RUST_VERSION" == "stable" && npm install stylus nib && - bash deploy.sh + bash ci/deploy.sh before_deploy: + # Script to create packages from the build artefacts to upload to GitHub - bash ci/before_deploy.sh deploy: provider: releases api_key: secure: Z1k7WqX7z+tT4+SzTh4tBBzf11VaADB4AWuEczHtylaEb/0hRs8gaiHCNSVHm/QTp0QPWQR2Vw7uKMhVuxG7I8X7h31j3A7ulYBh/iVk0DVIrtrn2Q4WOED9CpoXLuLtk2nxo9MBViFW7mw4nJe9H2Tn9o/9oEYBuwzekvW5mh4muqUuCVTr8eQVYbs3jbC9pQy5oYjOLeUnlL9Cey5VN/nAhzAtyFP+6lIMri0PKit4JtkFou/O1MEpFYlP3VGC2lFiWuByocPKBT/L45FecS9qoHq+i6+ZCPDH2eu46nuYsDbLKAkPdGvf1MdPBPwoj0vSnZbgaTisQ4hIoBngQQQPZlPaGtcdd6g6asxSfnbA9cQhClI5oZJmg+ksxQE+peE8pnbmZ10Ix0PpIkkfWdQeMdUUCQarOTkTK54Munw+X+kp1lH19j6+krQPLBYr95fPRd4b5tWsJD2+pb/UOYFEEJxMNoUHyLCrtdCO7imOwrSUcv51+Z8UudqfPpKQeszrJcntL4owip35r3sF5TsE9YfW5qssLC164IylvP32y1AcfL1jqg8b+zrqLZKanjvDOJ1dtHHuwKqxcwf7PhAf0YjAtVSH9OIYcDzmDa0EMLrq7EK0fs6NAeb5qt6CML7pZrRS3fmOxN53Fbmj81qm6TmjQjDe4dmZlELgNow= - file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz + file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TRAVIS_OS_NAME}.tar.gz # don't delete the artifacts from previous phases skip_cleanup: true - # deploy when a new tag is pushed on: - condition: $CHANNEL = stable + condition: $TRAVIS_RUST_VERSION = stable tags: true notifications: diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh index 9fa9ab1b..a61411fa 100644 --- a/ci/before_deploy.sh +++ b/ci/before_deploy.sh @@ -18,7 +18,7 @@ mk_tarball() { pushd $td - tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz * + tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TRAVIS_OS_NAME}.tar.gz * popd $td rm -r $td diff --git a/deploy.sh b/ci/deploy.sh similarity index 100% rename from deploy.sh rename to ci/deploy.sh diff --git a/ci/install.sh b/ci/install.sh deleted file mode 100644 index 94259cdb..00000000 --- a/ci/install.sh +++ /dev/null @@ -1,59 +0,0 @@ -# `install` phase: install stuff needed for the `script` phase - -set -ex - -case "$TRAVIS_OS_NAME" in - linux) - host=x86_64-unknown-linux-gnu - ;; - osx) - host=x86_64-apple-darwin - ;; -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 self update - rustup install "$CHANNEL" - 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 diff --git a/ci/script.sh b/ci/script.sh deleted file mode 100644 index 9504ae8f..00000000 --- a/ci/script.sh +++ /dev/null @@ -1,45 +0,0 @@ -# `script` phase: you usually build, test and generate docs in this phase - -set -ex - -# NOTE Workaround for rust-lang/rust#31907 - disable doc tests when cross compiling -# This has been fixed in the nightly channel but it would take a while to reach the other channels -disable_cross_doctests() { - local host - case "$TRAVIS_OS_NAME" in - linux) - host=x86_64-unknown-linux-gnu - ;; - osx) - host=x86_64-apple-darwin - ;; - esac - - if [ "$host" != "$TARGET" ] && [ "$CHANNEL" != "nightly" ]; then - if [ "$TRAVIS_OS_NAME" = "osx" ]; then - brew install gnu-sed --default-names - fi - - find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g' - fi -} - -run_test_suite() { - # Extra test without default features to avoid bitrot. We only test on a single target (but with - # all the channels) to avoid significantly increasing the build times - if [ $TARGET = x86_64-unknown-linux-gnu ]; then - cargo build --target $TARGET --no-default-features --verbose - cargo test --target $TARGET --no-default-features --verbose - cargo clean - fi - - cargo build --target $TARGET --verbose - cargo test --target $TARGET --verbose -} - -main() { - disable_cross_doctests - run_test_suite -} - -main