From fb820310e6d55f6ba650dc135d32822e5e8af104 Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 12 Apr 2019 22:09:30 +0800 Subject: [PATCH] chore: setup integration test in ci - Use Travis Branch Trigger to run integration test. - Use Travis Pull Request Trigger to run unit test. - Run both tests in master branch. --- .travis.yml | 2 +- devtools/ci/script.sh | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index a312748972..9098234bf1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ git: depth: 2 submodules: false -if: 'branch IN (master, develop, staging, trying) OR type != push OR fork = true OR tag =~ ^v' +if: 'branch IN (master, develop) OR branch =~ /^rc\// OR type != push OR fork = true OR tag IS present' env: global: diff --git a/devtools/ci/script.sh b/devtools/ci/script.sh index ea731302d2..5b255e1f11 100755 --- a/devtools/ci/script.sh +++ b/devtools/ci/script.sh @@ -5,24 +5,43 @@ echo "TRAVIS_BRANCH=$TRAVIS_BRANCH" cargo sweep -s -if [ "$FMT" = true ]; then - make fmt -fi -if [ "$CHECK" = true ]; then - make check - make clippy -fi -if [ "$TEST" = true ]; then - make test +# Run test only in master branch and pull requests +RUN_TEST=false +# Run integration only in master, develop and rc branches +RUN_INTEGRATION=false +if [ "$TRAVIS_PULL_REQUEST" != false ]; then + RUN_TEST=true +else + RUN_INTEGRATION=true + if [ "$TRAVIS_BRANCH" = master ]; then + RUN_TEST=true + fi fi -git diff --exit-code Cargo.lock +if [ "$RUN_TEST" = true ]; then + if [ "$FMT" = true ]; then + make fmt + fi + if [ "$CHECK" = true ]; then + make check + make clippy + fi + if [ "$TEST" = true ]; then + make test + fi + + git diff --exit-code Cargo.lock +fi -if [ "$TRAVIS_BRANCH" = master -o "$TRAVIS_BRANCH" = staging -o "$TRAVIS_BRANCH" = trying ]; then - cargo build +# We'll create PR for develop and rc branches to trigger the integration test. +if [ "$RUN_INTEGRATION" = true ]; then + echo "Running integration test..." + cargo build --verbose cd test && cargo run ../target/debug/ckb # Switch to release mode when the running time is much longer than the build time. # cargo build --release # cargo run --release -p ckb-test target/release/ckb +else + echo "Skip integration test..." fi