From 09d60a5e391f7c96b2306a52f3b6e156be59e351 Mon Sep 17 00:00:00 2001 From: Paul Dicker Date: Fri, 10 Nov 2017 21:01:15 +0100 Subject: [PATCH] Add CI based on `trust` --- .travis.yml | 127 ++++++++++++++++++++++++++++++++++------- ci/install.sh | 47 +++++++++++++++ ci/script.sh | 28 +++++++++ rand_core/src/impls.rs | 2 +- src/os.rs | 2 +- 5 files changed, 183 insertions(+), 23 deletions(-) create mode 100644 ci/install.sh create mode 100644 ci/script.sh diff --git a/.travis.yml b/.travis.yml index e790f0913d9..bfed5179d32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,115 @@ +# Based on the "trust" template v0.1.1 +# https://github.com/japaric/trust/tree/v0.1.1 + +dist: trusty language: rust -sudo: false -before_script: - - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH +services: docker +sudo: required + +# TODO Rust builds on stable by default, this can be +# overridden on a case by case basis down below. + +env: + global: + # TODO Update this to match the name of your project. + - CRATE_NAME=trust matrix: + # TODO These are all the build jobs. Adjust as necessary. Comment out what you + # don't need include: - - rust: 1.18.0 - - rust: stable - - rust: stable + # Android + # - env: TARGET=aarch64-linux-android DISABLE_TESTS=1 + # - env: TARGET=arm-linux-androideabi DISABLE_TESTS=1 + - env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1 + # - env: TARGET=i686-linux-android DISABLE_TESTS=1 + # - env: TARGET=x86_64-linux-android DISABLE_TESTS=1 + + # iOS + # - env: TARGET=aarch64-apple-ios DISABLE_TESTS=1 + # os: osx + - env: TARGET=armv7-apple-ios DISABLE_TESTS=1 os: osx - - rust: beta - - rust: nightly - script: - - cargo test --all - - cargo test --all --features nightly - - cargo test --all --benches - - cargo build --all --no-default-features - - cargo doc --no-deps --features nightly + # - env: TARGET=armv7s-apple-ios DISABLE_TESTS=1 + # os: osx + # - env: TARGET=i386-apple-ios DISABLE_TESTS=1 + # os: osx + # - env: TARGET=x86_64-apple-ios DISABLE_TESTS=1 + # os: osx + + # Linux + # - env: TARGET=aarch64-unknown-linux-gnu + # - env: TARGET=arm-unknown-linux-gnueabi + # - env: TARGET=armv7-unknown-linux-gnueabihf + - env: TARGET=i686-unknown-linux-gnu + # - env: TARGET=i686-unknown-linux-musl + - env: TARGET=mips-unknown-linux-gnu + - env: TARGET=mips64-unknown-linux-gnuabi64 + # - env: TARGET=mips64el-unknown-linux-gnuabi64 + # - env: TARGET=mipsel-unknown-linux-gnu + # - env: TARGET=powerpc-unknown-linux-gnu + # - env: TARGET=powerpc64-unknown-linux-gnu + # - env: TARGET=powerpc64le-unknown-linux-gnu + # - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 + - env: TARGET=x86_64-unknown-linux-gnu + # - env: TARGET=x86_64-unknown-linux-musl + + # OSX + - env: TARGET=i686-apple-darwin + os: osx + - env: TARGET=x86_64-apple-darwin + os: osx + + # *BSD + - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 + - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 + - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 + + # Windows + # - env: TARGET=x86_64-pc-windows-gnu + + # Bare metal + # These targets don't support std and as such are likely not suitable for + # most crates. + # - env: TARGET=thumbv6m-none-eabi + # - env: TARGET=thumbv7em-none-eabi + # - env: TARGET=thumbv7em-none-eabihf + # - env: TARGET=thumbv7m-none-eabi + + # Testing other channels + - env: TARGET=x86_64-unknown-linux-gnu NIGHTLY=1 + rust: nightly + - env: TARGET=x86_64-apple-darwin NIGHTLY=1 + os: osx + rust: nightly + +before_install: + - set -e + - rustup self update + +install: + - sh ci/install.sh + - source ~/.cargo/env || true + script: - - cargo test --all - - cargo build --all --no-default-features -after_success: - - travis-cargo --only nightly doc-upload -env: - global: - secure: "BdDntVHSompN+Qxz5Rz45VI4ZqhD72r6aPl166FADlnkIwS6N6FLWdqs51O7G5CpoMXEDvyYrjmRMZe/GYLIG9cmqmn/wUrWPO+PauGiIuG/D2dmfuUNvSTRcIe7UQLXrfP3yyfZPgqsH6pSnNEVopquQKy3KjzqepgriOJtbyY=" + - bash ci/script.sh + +after_script: set +e + +before_deploy: + - sh ci/before_deploy.sh + +cache: cargo +before_cache: + # Travis can't cache files that are not readable by "others" + - chmod -R a+r $HOME/.cargo + +# after_success: +# - travis-cargo --only nightly doc-upload + +# env: +# global: +# secure: "BdDntVHSompN+Qxz5Rz45VI4ZqhD72r6aPl166FADlnkIwS6N6FLWdqs51O7G5CpoMXEDvyYrjmRMZe/GYLIG9cmqmn/wUrWPO+PauGiIuG/D2dmfuUNvSTRcIe7UQLXrfP3yyfZPgqsH6pSnNEVopquQKy3KjzqepgriOJtbyY=" notifications: email: diff --git a/ci/install.sh b/ci/install.sh new file mode 100644 index 00000000000..80e18e47208 --- /dev/null +++ b/ci/install.sh @@ -0,0 +1,47 @@ +set -ex + +main() { + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-musl + sort=sort + else + target=x86_64-apple-darwin + sort=gsort # for `sort --sort-version`, from brew's coreutils. + fi + + # Builds for iOS are done on OSX, but require the specific target to be + # installed. + case $TARGET in + aarch64-apple-ios) + rustup target install aarch64-apple-ios + ;; + armv7-apple-ios) + rustup target install armv7-apple-ios + ;; + armv7s-apple-ios) + rustup target install armv7s-apple-ios + ;; + i386-apple-ios) + rustup target install i386-apple-ios + ;; + x86_64-apple-ios) + rustup target install x86_64-apple-ios + ;; + esac + + # This fetches latest stable release + local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ + | cut -d/ -f3 \ + | grep -E '^v[0.1.0-9.]+$' \ + | $sort --version-sort \ + | tail -n1) + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag $tag \ + --target $target +} + +main diff --git a/ci/script.sh b/ci/script.sh new file mode 100644 index 00000000000..6a80436aeaf --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,28 @@ +# This script takes care of testing your crate + +set -ex + +# TODO This is the "test phase", tweak it as you see fit +main() { + cross build --target $TARGET + cross build --all --no-default-features --target $TARGET --release + if [ ! -z $NIGHTLY ]; then + cross doc --no-deps --features nightly + fi + + if [ ! -z $DISABLE_TESTS ]; then + return + fi + + cross test --all --target $TARGET + + if [ ! -z $NIGHTLY ]; then + cross test --all --features nightly --target $TARGET + cross test --all --benches --target $TARGET + fi +} + +# we don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi diff --git a/rand_core/src/impls.rs b/rand_core/src/impls.rs index cffca3e882f..44319b95341 100644 --- a/rand_core/src/impls.rs +++ b/rand_core/src/impls.rs @@ -89,7 +89,7 @@ macro_rules! impl_uint_from_fill { let slice = slice::from_raw_parts_mut(ptr, $N); $self.fill_bytes(slice); } - int.to_le() + int }); } diff --git a/src/os.rs b/src/os.rs index e65d770af1e..cd0614927e8 100644 --- a/src/os.rs +++ b/src/os.rs @@ -81,7 +81,7 @@ impl Rng for OsRng { struct ReadRng (R); impl ReadRng { - fn try_fill(&mut self, mut dest: &mut [u8]) -> Result<(), Error> { + fn try_fill(&mut self, dest: &mut [u8]) -> Result<(), Error> { if dest.len() == 0 { return Ok(()); } // Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`. self.0.read_exact(dest).map_err(|err| {