-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sh
executable file
·53 lines (45 loc) · 1.36 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
REAL_SCRIPT_FILE="$(readlink -e "$(realpath "${BASH_SOURCE[0]}")")"
CURRENT_DIR="${REAL_SCRIPT_FILE%/*}"
set -o errexit
set -o pipefail
declare image="$1"
shift || true
if [[ -z "${image}" || "${image}" = "" ]]; then
echo "try : ./test.sh scrasnups/build:bash-tools-alpine-5.0 -r src -j 30"
echo "or : ./test.sh scrasnups/build:bash-tools-ubuntu-5.3 -r src -j 30"
echo "display bats help : ./test.sh scrasnups/build:bash-tools-ubuntu-5.3 --help"
exit 0
fi
# build docker image
if [[ "${CI_MODE:-0}" = "1" ]] || ! docker inspect --type=image "${image}" &>/dev/null; then
docker pull "${image}"
fi
# run docker image
declare -a localDockerRunArgs=(
--rm
-e KEEP_TEMP_FILES="${KEEP_TEMP_FILES:-0}"
-e BATS_FIX_TEST="${BATS_FIX_TEST:-0}"
-e USER_ID="${USER_ID:-1000}"
-e GROUP_ID="${GROUP_ID:-1000}"
--user "www-data:www-data"
-w /bash
-v "${CURRENT_DIR}:/bash"
--entrypoint /usr/local/bin/bash
)
if [[ -d "${CURRENT_DIR}/vendor/bash-tools-framework" ]]; then
FRAMEWORK_ROOT_DIR="$(cd "${CURRENT_DIR}/vendor/bash-tools-framework" && pwd -P)"
localDockerRunArgs+=(
-v "${FRAMEWORK_ROOT_DIR}:/bash/vendor/bash-tools-framework"
)
fi
if [[ "${CI_MODE:-0}" = "0" ]]; then
localDockerRunArgs+=(-v "/tmp:/tmp")
localDockerRunArgs+=(-it)
fi
set -x
docker run \
"${localDockerRunArgs[@]}" \
"${image}" \
/bash/vendor/bats/bin/bats \
"$@"