Skip to content

Commit

Permalink
Simplified CI and patched tarpaulin issue with cross.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhuszagh authored and myrrlyn committed Jan 24, 2020
1 parent 8125bfb commit 0059760
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
29 changes: 9 additions & 20 deletions .travis.yml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
9 changes: 9 additions & 0 deletions 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
7 changes: 7 additions & 0 deletions ci/install_taurpin.sh
@@ -0,0 +1,7 @@
#!/bin/bash

set -ex

if [[ ! -z $COVERAGE ]]; then
cargo install cargo-tarpaulin -f
fi
19 changes: 19 additions & 0 deletions 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

0 comments on commit 0059760

Please sign in to comment.