From c9714b628a78f8098282234af4163c33759b70c2 Mon Sep 17 00:00:00 2001 From: Ihor Date: Tue, 23 Jun 2020 20:03:41 +0200 Subject: [PATCH] chore(travis): fix travis to fail on single step failure --- .travis.yml | 23 +++-------------------- scripts/npm_run_time.sh | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) create mode 100755 scripts/npm_run_time.sh diff --git a/.travis.yml b/.travis.yml index 75feb0fe..4a089e3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,26 +4,9 @@ node_js: - 12 - 13 script: - - | - start_lint=$(date +%s) - npm run lint - duration_lint=$(echo "$(date +%s) - $start_lint" | bc) - echo "Lint time: ${duration_lint}s" - echo "${duration_lint}s" > lint-execution-time.log - - - | - start_build=$(date +%s) - npm run build - duration_build=$(echo "$(date +%s) - $start_build" | bc) - echo "Build time ${duration_build}s" - echo "${duration_build}s" > build-execution-time.log - - - | - start_test=$(date +%s) - npm run test:ci - duration_test=$(echo "$(date +%s) - $start_test" | bc) - echo "Test time ${duration_test}s" - echo "${duration_test}s" > test-execution-time.log + - ./scripts/npm_run_time.sh lint + - ./scripts/npm_run_time.sh build + - ./scripts/npm_run_time.sh test:ci after_success: - scripts/seriesci.sh \ No newline at end of file diff --git a/scripts/npm_run_time.sh b/scripts/npm_run_time.sh new file mode 100755 index 00000000..828f23de --- /dev/null +++ b/scripts/npm_run_time.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +script_name=$1 + +startTime=$(date +%s) + +cmd="npm run ${script_name}" +$cmd +cmdExitCode=$(echo $? | bc -l) + +if [ $cmdExitCode -ne 0 ]; then + exit ${cmdExitCode} +else + duration=$(echo "$(date +%s) - $startTime" | bc) + echo "${script_name} time: ${duration}s" + echo "${duration}s" > ${script_name}-execution-time.log +fi