Skip to content

Commit

Permalink
+ add travis-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Feb 19, 2021
1 parent 831391d commit 95675ae
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
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
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

<img src="docs/script-logo.png" width="20%" align="right" />

[![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)

👉 把平时有用的手动操作做成脚本,这样可以便捷的使用。 ✨

Expand Down
60 changes: 60 additions & 0 deletions test-cases/integration-test.sh
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

0 comments on commit 95675ae

Please sign in to comment.