Try to take advantage of travis cache and build stages

This commit is contained in:
Trinity Pointard 2018-11-04 20:27:27 +01:00
parent 8d5eaaec6a
commit dca91945af
1 changed files with 29 additions and 22 deletions

View File

@ -1,7 +1,10 @@
language: rust language: rust
rust: rust:
- nightly-2018-07-17 - nightly-2018-07-17
cache: cargo cache:
cargo: true
directories:
- kcov-master
sudo: true sudo: true
dist: trusty dist: trusty
@ -16,32 +19,36 @@ addons:
- binutils-dev - binutils-dev
- zlib1g-dev - zlib1g-dev
- libiberty-dev - libiberty-dev
stages:
- build
- code coverage
jobs: jobs:
include: include:
- stage: test and build - stage: build
name: "Build with postgresql"
env:
- MIGRATION_DIR=migrations/postgres FEATURES=postgres DATABASE_URL=postgres://postgres@localhost/plume
script: cargo build --no-default-features --features="${FEATURES}"
- stage: build
name: "Build with sqlite"
env:
- MIGRATION_DIR=migrations/sqlite FEATURES=sqlite DATABASE_URL=plume.sqlite3
script: cargo build --no-default-features --features="${FEATURES}"
- stage: code coverage
name: "Calculate code coverage"
env: env:
- RUSTFLAGS='-C link-dead-code' - RUSTFLAGS='-C link-dead-code'
script: cargo test --features sqlite --no-default-features --all script:
after_success:
- | - |
cargo test --features sqlite --no-default-features --all && (
wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
tar xzf master.tar.gz && tar xzf master.tar.gz &&
cd kcov-master && mkdir -p kcov-master/build &&
mkdir build && cd kcov-master/build &&
cd build &&
cmake .. && cmake .. &&
make && make &&
sudo make install && sudo make install &&
cd ../.. && cd ../.. &&
rm -rf kcov-master &&
for crate in plume plume_common plume_models plume_api plm lib; do for file in target/debug/$crate-*[^\.d]; do mkdir -p "target/cov/$(basename $file)"; kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; done; done && for crate in plume plume_common plume_models plume_api plm lib; do for file in target/debug/$crate-*[^\.d]; do mkdir -p "target/cov/$(basename $file)"; kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; done; done &&
bash <(curl -s https://codecov.io/bash) && bash <(curl -s https://codecov.io/bash) &&
echo "Uploaded code coverage" echo "Uploaded code coverage" || true )
- stage: test and build
env:
- MIGRATION_DIR=migrations/postgres FEATURES=postgres DATABASE_URL=postgres://postgres@localhost/plume
script: cargo build --no-default-features --features="${FEATURES}"
- stage: test and build
env:
- MIGRATION_DIR=migrations/sqlite FEATURES=sqlite DATABASE_URL=plume.sqlite3
script: cargo build --no-default-features --features="${FEATURES}"