Skip to content

Commit

Permalink
Merge pull request #44 from pitdicker/ci
Browse files Browse the repository at this point in the history
Add CI based on `trust`
  • Loading branch information
dhardy authored Nov 11, 2017
2 parents c8a8f86 + c218f7a commit 701679c
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 23 deletions.
126 changes: 105 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,114 @@
# 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:
- CRATE_NAME=rand

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:
Expand Down
47 changes: 47 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion rand_core/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Rng for OsRng {
struct ReadRng<R> (R);

impl<R: Read> ReadRng<R> {
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| {
Expand Down

0 comments on commit 701679c

Please sign in to comment.