1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-11-14 02:57:18 +00:00

Refactor tfw.sh to make usage more intuitive

This commit is contained in:
Kristóf Tóth 2018-03-31 19:01:59 +02:00
parent 459f0e9411
commit be3146533f

View File

@ -18,10 +18,11 @@ TEST_PORT="${TEST_PORT:-8888}"
AVATAO_SECRET="${AVATAO_SECRET:-secret}"
BUILD_CONTEXT="${BUILD_CONTEXT:-solvable}"
run_frontend()
build_baseimage()
{
cd $FRONTEND_PATH
yarn start
[ ! -d "$BASEIMAGE_PATH" ] && return || :
cd $BASEIMAGE_PATH
docker build -t "${BASEIMAGE_NAME}:$(baseimage_releasename)" -t "${BASEIMAGE_NAME}:latest" .
}
release_baseimage()
@ -37,13 +38,6 @@ release_baseimage()
fi
}
build_baseimage()
{
[ ! -d "$BASEIMAGE_PATH" ] && return || :
cd $BASEIMAGE_PATH
docker build -t "${BASEIMAGE_NAME}:$(baseimage_releasename)" -t "${BASEIMAGE_NAME}:latest" .
}
baseimage_releasename()
{
VERSION="$(cat VERSION | head -n 1)"
@ -53,6 +47,7 @@ baseimage_releasename()
build_test()
{
build_baseimage
cd $TEST_PATH
docker build -t $IMAGE_NAME -f ${BUILD_CONTEXT}/Dockerfile --build-arg BUILD_CONTEXT=$BUILD_CONTEXT --build-arg NOFRONTEND=1 .
}
@ -68,20 +63,17 @@ build_and_run_test()
run_test
}
build_and_start_tfw()
run_frontend()
{
trap 'exit' INT TERM
trap 'kill 0' EXIT
build_baseimage
run_frontend & build_and_run_test
wait
cd $FRONTEND_PATH
yarn start
}
start_tfw()
start_test()
{
trap 'exit' INT TERM
trap 'kill 0' EXIT
run_frontend & run_test
run_frontend & build_and_run_test
wait
}
@ -89,24 +81,20 @@ case $1 in
buildtfw)
build_baseimage
;;
releasetfw)
release_baseimage
;;
build)
build_test
;;
start)
start_tfw
;;
buildstart)
build_and_start_tfw
;;
release)
release_baseimage
start_test
;;
*)
echo "Usage: tfw.sh [buildtfw|build|start|buildstart]"
echo " |--- buildtfw: build TFW baseimage"
echo " |--- releasetfw: tag TFW baseimage and push to upstream"
echo " |--- build: build TFW test"
echo " |--- start: start TFW test"
echo " |--- buildstart: build all, then start TFW test"
echo " |--- release: tag TFW baseimage and push to upstream"
echo " |--- start: build & start TFW test"
;;
esac