summaryrefslogtreecommitdiffstats
path: root/ci/script.sh
blob: 4b363f2173c800c071d7fe3edab156732dd7e125 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
set -exo pipefail

main() {
    if [ ! -z $COVERAGE ] && [ $TRAVIS_RUST_VERSION = nightly ]; then
        export CARGO_INCREMENTAL=0;
        export RUSTFLAGS="-Zprofile -Ccodegen-units=1";
    fi

    if [[ ! $TARGET =~ .*linux.* ]]; then
        sed -i "s/linux-embedded-hal/#linux-embedded-hal/g" Cargo.toml
        sed -i "s/embedded-hal-mock/#embedded-hal-mock/g" Cargo.toml
    fi

    if [ ! -z $FEATURES ]; then
       export FEATURES="--features $FEATURES"
    fi

    cargo check --target $TARGET $FEATURES
    cargo build --target $TARGET --release $FEATURES
    if [ -z $DISABLE_EXAMPLES ] && [[ $TARGET =~ .*linux.* ]]; then
        cargo build --target $TARGET $FEATURES --examples
    fi

    if [ -z $DISABLE_TESTS ] && [ $TRAVIS_RUST_VERSION = nightly ] && [[ $TARGET =~ .*linux.* ]]; then
        cargo test --target $TARGET $FEATURES
        if [ ! -z $COVERAGE ]; then
            find . -name "*.gc*" -print
            zip -0 ccov.zip `find . \( -name "ads1x1x*.gc*" -o -name "tier*.gc*" -name "mux*.gc*" -name "construction*.gc*" -name "linux-*.gc*" -o -name "llvmgcov.gc*" \) -print`;
            grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore-dir "/*" > lcov.info;
            bash <(curl -s https://codecov.io/bash) -f lcov.info;
            grcov ./target -t coveralls+ -s . --token `$COVERALLS_TOKEN` --llvm --branch --ignore-not-existing --ignore-dir "/*"
        fi
    fi


}

main