diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..13702323 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: bash +# https://github.com/caarlos0-graveyard/shell-ci-build + +# The Ubuntu Linux Build Environments +# https://docs.travis-ci.com/user/reference/linux/ +dist: precise + +script: + - test-cases/integration-test.sh + +after_script: + - git status --ignored diff --git a/README.md b/README.md index 9cc4278b..78bdc993 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,14 @@ -[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) -[![Join the chat at https://gitter.im/oldratlee/useful-scripts](https://badges.gitter.im/oldratlee/useful-scripts.svg)](https://gitter.im/oldratlee/useful-scripts?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://img.shields.io/travis/oldratlee/useful-scripts/dev-2.x?logo=travis-ci&logoColor=white)](https://travis-ci.org/oldratlee/useful-scripts) [![GitHub release](https://img.shields.io/github/release/oldratlee/useful-scripts.svg)](https://github.com/oldratlee/useful-scripts/releases) -[![GitHub stars](https://img.shields.io/github/stars/oldratlee/useful-scripts.svg?style=social&label=Star&)](https://github.com/oldratlee/useful-scripts/stargazers) -[![GitHub forks](https://img.shields.io/github/forks/oldratlee/useful-scripts.svg?style=social&label=Fork&)](https://github.com/oldratlee/useful-scripts/fork) - +[![License](https://img.shields.io/github/license/oldratlee/useful-scripts?color=4D7A97)](https://www.apache.org/licenses/LICENSE-2.0.html) +[![Chat at gitter.im](https://img.shields.io/gitter/room/oldratlee/useful-scripts?color=46BC99&logo=gitter&logoColor=white)](https://gitter.im/oldratlee/useful-scripts?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![GitHub Stars](https://img.shields.io/github/stars/oldratlee/useful-scripts)](https://github.com/oldratlee/useful-scripts/stargazers) +[![GitHub Forks](https://img.shields.io/github/forks/oldratlee/useful-scripts)](https://github.com/oldratlee/useful-scripts/fork) +[![GitHub issues](https://img.shields.io/github/issues/oldratlee/useful-scripts)](https://github.com/oldratlee/useful-scripts/issues) +[![GitHub Contributors](https://img.shields.io/github/contributors/oldratlee/useful-scripts)](https://github.com/oldratlee/useful-scripts/graphs/contributors) 👉 把平时有用的手动操作做成脚本,这样可以便捷的使用。 ✨ diff --git a/test-cases/integration-test.sh b/test-cases/integration-test.sh new file mode 100755 index 00000000..7d07e0df --- /dev/null +++ b/test-cases/integration-test.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -eEuo pipefail +cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +################################################################################ +# constants +################################################################################ + +# NOTE: $'foo' is the escape sequence syntax of bash +readonly ec=$'\033' # escape char +readonly eend=$'\033[0m' # escape end +readonly nl=$'\n' # new line + +################################################################################ +# common util functions +################################################################################ + +colorEcho() { + local color=$1 + shift + + # if stdout is the console, turn on color output. + [ -t 1 ] && echo "${ec}[1;${color}m$*${eend}" || echo "$*" +} + +redEcho() { + colorEcho 31 "$@" +} + +yellowEcho() { + colorEcho 33 "$@" +} + +blueEcho() { + colorEcho 36 "$@" +} + +logAndRun() { + local simple_mode=false + [ "$1" = "-s" ] && { + simple_mode=true + shift + } + + if $simple_mode; then + echo "Run under work directory $PWD : $*" + "$@" + else + blueEcho "Run under work directory $PWD :$nl$*" + time "$@" + fi +} + +################################################################################ +# run *_test.sh unit test cases +################################################################################ + +for test_case in *_test.sh; do + logAndRun ./"$test_case" +done