ci: only start required docker for integration tests
This commit is contained in:
parent
fbea5dce58
commit
f785da075b
|
@ -121,27 +121,8 @@ jobs:
|
|||
PGSQL_TAG: 13
|
||||
REDIS_TAG: 6
|
||||
run: |
|
||||
docker-compose \
|
||||
-f .ci/docker-compose-file/docker-compose-mongo-single-tcp.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose-mongo-single-tls.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose-mysql-tcp.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose-mysql-tls.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose-pgsql-tcp.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose-pgsql-tls.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose-redis-single-tcp.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose-redis-single-tls.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose-redis-sentinel-tls.yaml \
|
||||
-f .ci/docker-compose-file/docker-compose.yaml \
|
||||
up -d --build
|
||||
|
||||
# produces <app-name>.coverdata
|
||||
- name: run common test
|
||||
working-directory: source
|
||||
run: |
|
||||
docker exec -i ${{ matrix.otp_release }} bash -c "git config --global --add safe.directory \"$GITHUB_WORKSPACE\" && make ${{ matrix.app_name }}-ct"
|
||||
./scripts/ct/run.sh --app ${{ matrix.app_name }}
|
||||
- uses: actions/upload-artifact@v1
|
||||
if: matrix.otp_release == 'erlang24'
|
||||
with:
|
||||
name: coverdata
|
||||
path: source/_build/test/cover
|
||||
|
|
1
Makefile
1
Makefile
|
@ -80,7 +80,6 @@ static_checks:
|
|||
|
||||
APPS=$(shell $(SCRIPTS)/find-apps.sh)
|
||||
|
||||
## app/name-ct targets are intended for local tests hence cover is not enabled
|
||||
.PHONY: $(APPS:%=%-ct)
|
||||
define gen-app-ct-target
|
||||
$1-ct: $(REBAR)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
mongo
|
||||
redis
|
||||
mysql
|
||||
pgsql
|
|
@ -0,0 +1,4 @@
|
|||
mongo
|
||||
redis
|
||||
mysql
|
||||
pgsql
|
|
@ -0,0 +1,4 @@
|
|||
mongo
|
||||
redis
|
||||
mysql
|
||||
pgsql
|
|
@ -12,7 +12,8 @@ parse_semver() {
|
|||
echo "$1" | tr '.|-' ' '
|
||||
}
|
||||
|
||||
while read -r app; do
|
||||
APPS="$(./scripts/find-apps.sh)"
|
||||
for app in ${APPS}; do
|
||||
if [ "$app" != "emqx" ]; then
|
||||
app_path="$app"
|
||||
else
|
||||
|
@ -46,7 +47,7 @@ while read -r app; do
|
|||
bad_app_count=$(( bad_app_count + 1))
|
||||
fi
|
||||
fi
|
||||
done < <(./scripts/find-apps.sh)
|
||||
done
|
||||
|
||||
if [ $bad_app_count -gt 0 ]; then
|
||||
exit 1
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
## This script runs CT (and necessary dependencies) in docker container(s)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# ensure dir
|
||||
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/../.."
|
||||
|
||||
help() {
|
||||
echo
|
||||
echo "-h|--help: To display this usage info"
|
||||
echo "--app lib_dir/app_name: Print apps in json"
|
||||
echo "--console: Start EMQX in console mode"
|
||||
}
|
||||
|
||||
WHICH_APP='novalue'
|
||||
CONSOLE='no'
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
--app)
|
||||
WHICH_APP="$2"
|
||||
shift 2
|
||||
;;
|
||||
--console)
|
||||
CONSOLE='yes'
|
||||
shift 1
|
||||
;;
|
||||
*)
|
||||
echo "unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "${WHICH_APP}" = 'novalue' ]; then
|
||||
echo "must provide --app arg"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ERLANG_CONTAINER='erlang24'
|
||||
DOCKER_CT_ENVS_FILE="${WHICH_APP}/docker-ct"
|
||||
|
||||
if [ -f "$DOCKER_CT_ENVS_FILE" ]; then
|
||||
# shellcheck disable=SC2002
|
||||
CT_DEPS="$(cat "$DOCKER_CT_ENVS_FILE" | xargs)"
|
||||
fi
|
||||
CT_DEPS="${ERLANG_CONTAINER} ${CT_DEPS}"
|
||||
|
||||
FILES=( )
|
||||
|
||||
for dep in ${CT_DEPS}; do
|
||||
case "${dep}" in
|
||||
erlang24)
|
||||
FILES+=( '.ci/docker-compose-file/docker-compose.yaml' )
|
||||
;;
|
||||
mongo)
|
||||
FILES+=( '.ci/docker-compose-file/docker-compose-mongo-single-tcp.yaml'
|
||||
'.ci/docker-compose-file/docker-compose-mongo-single-tls.yaml' )
|
||||
;;
|
||||
redis)
|
||||
FILES+=( '.ci/docker-compose-file/docker-compose-redis-single-tcp.yaml'
|
||||
'.ci/docker-compose-file/docker-compose-redis-single-tls.yaml'
|
||||
'.ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml'
|
||||
'.ci/docker-compose-file/docker-compose-redis-sentinel-tls.yaml' )
|
||||
;;
|
||||
mysql)
|
||||
FILES+=( '.ci/docker-compose-file/docker-compose-mysql-tcp.yaml'
|
||||
'.ci/docker-compose-file/docker-compose-mysql-tls.yaml' )
|
||||
;;
|
||||
pgsql)
|
||||
FILES+=( '.ci/docker-compose-file/docker-compose-pgsql-tcp.yaml'
|
||||
'.ci/docker-compose-file/docker-compose-pgsql-tls.yaml' )
|
||||
;;
|
||||
*)
|
||||
echo "unknown_ct_dependency $dep"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
F_OPTIONS=""
|
||||
|
||||
for file in "${FILES[@]}"; do
|
||||
F_OPTIONS="$F_OPTIONS -f $file"
|
||||
done
|
||||
|
||||
# shellcheck disable=2086 # no quotes for F_OPTIONS
|
||||
docker-compose $F_OPTIONS up -d --build
|
||||
|
||||
# /emqx is where the source dir is mounted to the Erlang container
|
||||
# in .ci/docker-compose-file/docker-compose.yaml
|
||||
TTY=''
|
||||
if [[ -t 1 ]]; then
|
||||
TTY='-t'
|
||||
fi
|
||||
docker exec -i $TTY "$ERLANG_CONTAINER" bash -c 'git config --global --add safe.directory /emqx'
|
||||
|
||||
if [ "$CONSOLE" = 'yes' ]; then
|
||||
docker exec -i $TTY "$ERLANG_CONTAINER" bash -c "make run"
|
||||
else
|
||||
set +e
|
||||
docker exec -i $TTY "$ERLANG_CONTAINER" bash -c "make ${WHICH_APP}-ct"
|
||||
RESULT=$?
|
||||
# shellcheck disable=2086 # no quotes for F_OPTIONS
|
||||
docker-compose $F_OPTIONS down
|
||||
exit $RESULT
|
||||
fi
|
|
@ -1,4 +0,0 @@
|
|||
# apps need docker-compose to run CT
|
||||
apps/emqx_authn
|
||||
apps/emqx_authz
|
||||
apps/emqx_connector
|
|
@ -50,24 +50,25 @@ find_app() {
|
|||
|
||||
CE="$(find_app 'apps')"
|
||||
EE="$(find_app 'lib-ee')"
|
||||
APPS_ALL="$(echo -e "${CE}\n${EE}")"
|
||||
|
||||
if [ "$CT" = 'novalue' ]; then
|
||||
echo -e "${CE}\n${EE}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
APPS_ALL="$(echo -e "${CE}\n${EE}")"
|
||||
APPS_DOCKER_CT="$(grep -v -E '^#.*' scripts/docker-ct-apps)"
|
||||
|
||||
# shellcheck disable=SC2068
|
||||
for app in ${APPS_DOCKER_CT[@]}; do
|
||||
APPS_ALL=("${APPS_ALL[@]/$app}")
|
||||
done
|
||||
|
||||
if [ "$CT" = 'docker' ]; then
|
||||
RESULT="${APPS_DOCKER_CT}"
|
||||
RESULT="${APPS_ALL}"
|
||||
else
|
||||
RESULT="${APPS_ALL[*]}"
|
||||
APPS_NORMAL_CT=( )
|
||||
APPS_DOCKER_CT=( )
|
||||
for app in ${APPS_ALL}; do
|
||||
if [ -f "${app}/docker-ct" ]; then
|
||||
APPS_DOCKER_CT+=("$app")
|
||||
else
|
||||
APPS_NORMAL_CT+=("$app")
|
||||
fi
|
||||
done
|
||||
if [ "$CT" = 'docker' ]; then
|
||||
RESULT="${APPS_DOCKER_CT[*]}"
|
||||
else
|
||||
RESULT="${APPS_NORMAL_CT[*]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$WANT_JSON" = 'yes' ]; then
|
||||
|
|
Loading…
Reference in New Issue