forked from oldratlee/useful-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |