From 12834632236c66966f401d2ed433f9eb72226028 Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Thu, 23 Jan 2020 23:58:08 -0600 Subject: [PATCH 1/2] Added multiple platforms for bitvec CI. --- .travis.yml | 79 ++++++++++++++++++++++++++++++++++++++++------ ci/install_rust.sh | 47 +++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 9 deletions(-) create mode 100755 ci/install_rust.sh diff --git a/.travis.yml b/.travis.yml index d3b0f224..df1da5c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,12 +9,65 @@ language: rust sudo: required cache: cargo -rust: - - stable - - beta - - nightly matrix: + include: + - rust: stable + env: TARGET=x86_64-unknown-linux-gnu + - rust: beta + env: TARGET=x86_64-unknown-linux-gnu + - rust: nightly + env: TARGET=x86_64-unknown-linux-gnu + + # 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 + - 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 allow_failures: - rust: nightly @@ -25,17 +78,25 @@ addons: - libssl-dev before_cache: | - if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then + if [[ "$TRAVIS_RUST_VERSION" = stable ]] && [[ "$TARGET" = x86_64-unknown-linux-gnu ]]; then cargo install cargo-tarpaulin -f fi +before_install: + - set -e + - rustup self update + +install: + - sh ci/install_rust.sh + - source ~/.cargo/env || true + script: -- cargo clean -- cargo build --all-features -- cargo test --all-features + - cross clean + - cross build --target $TARGET --all-features + - if [ -z $DISABLE_TESTS ]; then cross test --target $TARGET --all-features ; fi after_success: | - if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then + if [[ "$TRAVIS_RUST_VERSION" = stable ]] && [[ "$TARGET" = x86_64-unknown-linux-gnu ]]; then # Uncomment the following line for coveralls.io # cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID diff --git a/ci/install_rust.sh b/ci/install_rust.sh new file mode 100755 index 00000000..80e18e47 --- /dev/null +++ b/ci/install_rust.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 From 5b1bd48fb57ec3b8c375022c7e8958856ca066fb Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Fri, 24 Jan 2020 09:36:54 -0600 Subject: [PATCH 2/2] Simplified CI and patched tarpaulin issue with cross. --- .travis.yml | 29 +++++++++-------------------- ci/coverage.sh | 9 +++++++++ ci/install_taurpin.sh | 7 +++++++ ci/script.sh | 19 +++++++++++++++++++ 4 files changed, 44 insertions(+), 20 deletions(-) create mode 100755 ci/coverage.sh create mode 100755 ci/install_taurpin.sh create mode 100755 ci/script.sh diff --git a/.travis.yml b/.travis.yml index df1da5c7..6266a984 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,10 @@ cache: cargo matrix: include: + # Disable cross while building coverage, since cross interferes + # with caching and the current tarpaulin install. - rust: stable - env: TARGET=x86_64-unknown-linux-gnu + env: TARGET=x86_64-unknown-linux-gnu COVERAGE=1 DISABLE_CROSS=1 - rust: beta env: TARGET=x86_64-unknown-linux-gnu - rust: nightly @@ -52,7 +54,6 @@ matrix: - 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 @@ -77,31 +78,19 @@ addons: packages: - libssl-dev -before_cache: | - if [[ "$TRAVIS_RUST_VERSION" = stable ]] && [[ "$TARGET" = x86_64-unknown-linux-gnu ]]; then - cargo install cargo-tarpaulin -f - fi +before_cache: + - bash ci/install_taurpin.sh before_install: - set -e - rustup self update install: - - sh ci/install_rust.sh + - bash ci/install_rust.sh - source ~/.cargo/env || true script: - - cross clean - - cross build --target $TARGET --all-features - - if [ -z $DISABLE_TESTS ]; then cross test --target $TARGET --all-features ; fi - -after_success: | - if [[ "$TRAVIS_RUST_VERSION" = stable ]] && [[ "$TARGET" = x86_64-unknown-linux-gnu ]]; then - # Uncomment the following line for coveralls.io - # cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID + - bash ci/script.sh - # Uncomment the following two lines create and upload a report for codecov.io - cargo tarpaulin --out Xml - bash <(curl -s https://codecov.io/bash) - echo "Uploaded code coverage" - fi +after_success: + - bash ci/coverage.sh diff --git a/ci/coverage.sh b/ci/coverage.sh new file mode 100755 index 00000000..2790bc8c --- /dev/null +++ b/ci/coverage.sh @@ -0,0 +1,9 @@ +if [[ ! -z $COVERAGE ]]; then + # Uncomment the following line for coveralls.io + # cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID + + # Uncomment the following two lines create and upload a report for codecov.io + cargo tarpaulin --out Xml + bash <(curl -s https://codecov.io/bash) + echo "Uploaded code coverage" +fi diff --git a/ci/install_taurpin.sh b/ci/install_taurpin.sh new file mode 100755 index 00000000..3236df62 --- /dev/null +++ b/ci/install_taurpin.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -ex + +if [[ ! -z $COVERAGE ]]; then + cargo install cargo-tarpaulin -f +fi diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 00000000..14fd67e5 --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -ex + +# Detect our build command if we are on travis or not (so we can test locally). +if [ -z $CI ] || [ ! -z $DISABLE_CROSS ]; then + # Not on CI or explicitly disabled cross, use cargo + CARGO=cargo +else + # On CI, use cross. + CARGO=cross + CARGO_TARGET="--target $TARGET" +fi + +$CARGO clean +$CARGO build $CARGO_TARGET --all-features +if [ -z $DISABLE_TESTS ]; then + $CARGO test $CARGO_TARGET --all-features +fi