mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
create basic integration tests with .env file support for specific engines
This commit is contained in:
parent
a19028bd90
commit
3877dbc764
7 changed files with 189 additions and 78 deletions
130
manage
130
manage
|
|
@ -45,6 +45,8 @@ GECKODRIVER_VERSION="v0.33.0"
|
|||
# SPHINXOPTS=
|
||||
BLACK_OPTIONS=("--target-version" "py311" "--line-length" "120" "--skip-string-normalization")
|
||||
BLACK_TARGETS=("--exclude" "(searx/static|searx/languages.py)" "--include" 'searxng.msg|\.pyi?$' "searx" "searxng_extra" "tests")
|
||||
# add one or more engines, comma seperated, here to only test a subset of engines
|
||||
INTEGRATION_ENGINES="google"
|
||||
|
||||
_dev_redis_sock="/usr/local/searxng-redis/run/redis.sock"
|
||||
# set SEARXNG_REDIS_URL if it is not defined and "{_dev_redis_sock}" exists.
|
||||
|
|
@ -66,8 +68,8 @@ pylint.FILES() {
|
|||
|
||||
YAMLLINT_FILES=()
|
||||
while IFS= read -r line; do
|
||||
YAMLLINT_FILES+=("$line")
|
||||
done <<< "$(git ls-files './tests/*.yml' './searx/*.yml' './utils/templates/etc/searxng/*.yml')"
|
||||
YAMLLINT_FILES+=("$line")
|
||||
done <<<"$(git ls-files './tests/*.yml' './searx/*.yml' './utils/templates/etc/searxng/*.yml')"
|
||||
|
||||
RST_FILES=(
|
||||
'README.rst'
|
||||
|
|
@ -129,7 +131,6 @@ environment ...
|
|||
EOF
|
||||
}
|
||||
|
||||
|
||||
if [ "$VERBOSE" = "1" ]; then
|
||||
SPHINX_VERBOSE="-v"
|
||||
PYLINT_VERBOSE="-v"
|
||||
|
|
@ -142,14 +143,14 @@ webapp.run() {
|
|||
local parent_proc="$$"
|
||||
(
|
||||
if [ "${LIVE_THEME}" ]; then
|
||||
( themes.live "${LIVE_THEME}" )
|
||||
(themes.live "${LIVE_THEME}")
|
||||
kill $parent_proc
|
||||
fi
|
||||
)&
|
||||
) &
|
||||
(
|
||||
sleep 3
|
||||
xdg-open http://127.0.0.1:8888/
|
||||
)&
|
||||
) &
|
||||
SEARXNG_DEBUG=1 pyenv.cmd python -m searx.webapp
|
||||
}
|
||||
|
||||
|
|
@ -176,19 +177,20 @@ docker.build() {
|
|||
|
||||
# See https://www.shellcheck.net/wiki/SC1001 and others ..
|
||||
# shellcheck disable=SC2031,SC2230,SC2002,SC2236,SC2143,SC1001
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
|
||||
# Check if it is a git repository
|
||||
if [ ! -d .git ]; then
|
||||
die 1 "This is not Git repository"
|
||||
die 1 "This is not Git repository"
|
||||
fi
|
||||
if [ ! -x "$(which git)" ]; then
|
||||
die 1 "git is not installed"
|
||||
die 1 "git is not installed"
|
||||
fi
|
||||
|
||||
if ! git remote get-url origin 2> /dev/null; then
|
||||
die 1 "there is no remote origin"
|
||||
if ! git remote get-url origin 2>/dev/null; then
|
||||
die 1 "there is no remote origin"
|
||||
fi
|
||||
|
||||
# This is a git repository
|
||||
|
|
@ -217,22 +219,22 @@ docker.build() {
|
|||
build_msg DOCKER "Building image ${SEARXNG_IMAGE_NAME}:${SEARXNG_GIT_VERSION}"
|
||||
# shellcheck disable=SC2086
|
||||
docker $BUILD \
|
||||
--build-arg BASE_IMAGE="${DEPENDENCIES_IMAGE_NAME}" \
|
||||
--build-arg GIT_URL="${GIT_URL}" \
|
||||
--build-arg SEARXNG_DOCKER_TAG="${DOCKER_TAG}" \
|
||||
--build-arg SEARXNG_GIT_VERSION="${VERSION_STRING}" \
|
||||
--build-arg VERSION_GITCOMMIT="${VERSION_GITCOMMIT}" \
|
||||
--build-arg LABEL_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
|
||||
--build-arg LABEL_VCS_REF="$(git rev-parse HEAD)" \
|
||||
--build-arg LABEL_VCS_URL="${GIT_URL}" \
|
||||
--build-arg TIMESTAMP_SETTINGS="$(git log -1 --format="%cd" --date=unix -- searx/settings.yml)" \
|
||||
--build-arg TIMESTAMP_UWSGI="$(git log -1 --format="%cd" --date=unix -- dockerfiles/uwsgi.ini)" \
|
||||
-t "${SEARXNG_IMAGE_NAME}:latest" -t "${SEARXNG_IMAGE_NAME}:${DOCKER_TAG}" .
|
||||
--build-arg BASE_IMAGE="${DEPENDENCIES_IMAGE_NAME}" \
|
||||
--build-arg GIT_URL="${GIT_URL}" \
|
||||
--build-arg SEARXNG_DOCKER_TAG="${DOCKER_TAG}" \
|
||||
--build-arg SEARXNG_GIT_VERSION="${VERSION_STRING}" \
|
||||
--build-arg VERSION_GITCOMMIT="${VERSION_GITCOMMIT}" \
|
||||
--build-arg LABEL_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
|
||||
--build-arg LABEL_VCS_REF="$(git rev-parse HEAD)" \
|
||||
--build-arg LABEL_VCS_URL="${GIT_URL}" \
|
||||
--build-arg TIMESTAMP_SETTINGS="$(git log -1 --format="%cd" --date=unix -- searx/settings.yml)" \
|
||||
--build-arg TIMESTAMP_UWSGI="$(git log -1 --format="%cd" --date=unix -- dockerfiles/uwsgi.ini)" \
|
||||
-t "${SEARXNG_IMAGE_NAME}:latest" -t "${SEARXNG_IMAGE_NAME}:${DOCKER_TAG}" .
|
||||
|
||||
if [ "$1" = "push" ]; then
|
||||
docker push "${SEARXNG_IMAGE_NAME}:latest"
|
||||
docker push "${SEARXNG_IMAGE_NAME}:${DOCKER_TAG}"
|
||||
fi
|
||||
docker push "${SEARXNG_IMAGE_NAME}:latest"
|
||||
docker push "${SEARXNG_IMAGE_NAME}:${DOCKER_TAG}"
|
||||
fi
|
||||
)
|
||||
dump_return $?
|
||||
}
|
||||
|
|
@ -243,10 +245,11 @@ gecko.driver() {
|
|||
|
||||
build_msg INSTALL "gecko.driver"
|
||||
# run installation in a subprocess and activate pyenv
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
|
||||
INSTALLED_VERSION=$(geckodriver -V 2> /dev/null | head -1 | awk '{ print "v" $2}') || INSTALLED_VERSION=""
|
||||
INSTALLED_VERSION=$(geckodriver -V 2>/dev/null | head -1 | awk '{ print "v" $2}') || INSTALLED_VERSION=""
|
||||
set +e
|
||||
if [ "${INSTALLED_VERSION}" = "${GECKODRIVER_VERSION}" ]; then
|
||||
build_msg INSTALL "geckodriver already installed"
|
||||
|
|
@ -254,13 +257,13 @@ gecko.driver() {
|
|||
fi
|
||||
PLATFORM="$(python3 -c 'import platform; print(platform.system().lower(), platform.architecture()[0])')"
|
||||
case "$PLATFORM" in
|
||||
"linux 32bit" | "linux2 32bit") ARCH="linux32";;
|
||||
"linux 64bit" | "linux2 64bit") ARCH="linux64";;
|
||||
"windows 32 bit") ARCH="win32";;
|
||||
"windows 64 bit") ARCH="win64";;
|
||||
"mac 64bit") ARCH="macos";;
|
||||
"linux 32bit" | "linux2 32bit") ARCH="linux32" ;;
|
||||
"linux 64bit" | "linux2 64bit") ARCH="linux64" ;;
|
||||
"windows 32 bit") ARCH="win32" ;;
|
||||
"windows 64 bit") ARCH="win64" ;;
|
||||
"mac 64bit") ARCH="macos" ;;
|
||||
esac
|
||||
GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz";
|
||||
GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz"
|
||||
|
||||
build_msg GECKO "Installing ${PY_ENV_BIN}/geckodriver from $GECKODRIVER_URL"
|
||||
|
||||
|
|
@ -284,13 +287,14 @@ pygments.less() {
|
|||
py.build() {
|
||||
build_msg BUILD "python package ${PYDIST}"
|
||||
pyenv.cmd python setup.py \
|
||||
sdist -d "${PYDIST}" \
|
||||
bdist_wheel --bdist-dir "${PYBUILD}" -d "${PYDIST}"
|
||||
sdist -d "${PYDIST}" \
|
||||
bdist_wheel --bdist-dir "${PYBUILD}" -d "${PYDIST}"
|
||||
}
|
||||
|
||||
py.clean() {
|
||||
build_msg CLEAN pyenv
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.drop
|
||||
[ "$VERBOSE" = "1" ] && set -x
|
||||
rm -rf "${PYDIST}" "${PYBUILD}" "${PY_ENV}" ./.tox ./*.egg-info
|
||||
|
|
@ -301,7 +305,7 @@ py.clean() {
|
|||
}
|
||||
|
||||
pyenv.check() {
|
||||
cat <<EOF
|
||||
cat <<EOF
|
||||
import yaml
|
||||
print('import yaml --> OK')
|
||||
EOF
|
||||
|
|
@ -310,13 +314,14 @@ EOF
|
|||
pyenv.install() {
|
||||
|
||||
if ! pyenv.OK; then
|
||||
py.clean > /dev/null
|
||||
py.clean >/dev/null
|
||||
fi
|
||||
if pyenv.install.OK > /dev/null; then
|
||||
if pyenv.install.OK >/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv
|
||||
build_msg PYENV "[install] pip install -e 'searx${PY_SETUP_EXTRAS}'"
|
||||
"${PY_ENV_BIN}/python" -m pip install -e ".${PY_SETUP_EXTRAS}"
|
||||
|
|
@ -329,8 +334,8 @@ pyenv.install() {
|
|||
|
||||
pyenv.uninstall() {
|
||||
build_msg PYENV "[pyenv.uninstall] uninstall packages: ${PYOBJECTS}"
|
||||
pyenv.cmd python setup.py develop --uninstall 2>&1 \
|
||||
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||
pyenv.cmd python setup.py develop --uninstall 2>&1 |
|
||||
prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -353,17 +358,17 @@ format.python() {
|
|||
dump_return $?
|
||||
}
|
||||
|
||||
|
||||
PYLINT_FILES=()
|
||||
while IFS= read -r line; do
|
||||
PYLINT_FILES+=("$line")
|
||||
done <<< "$(pylint.FILES)"
|
||||
PYLINT_FILES+=("$line")
|
||||
done <<<"$(pylint.FILES)"
|
||||
|
||||
# shellcheck disable=SC2119
|
||||
main() {
|
||||
|
||||
local _type
|
||||
local cmd="$1"; shift
|
||||
local cmd="$1"
|
||||
shift
|
||||
|
||||
if [ "$cmd" == "" ]; then
|
||||
help
|
||||
|
|
@ -372,22 +377,25 @@ main() {
|
|||
fi
|
||||
|
||||
case "$cmd" in
|
||||
--getenv) var="$1"; echo "${!var}";;
|
||||
--help) help;;
|
||||
--*)
|
||||
help
|
||||
err_msg "unknown option $cmd"
|
||||
--getenv)
|
||||
var="$1"
|
||||
echo "${!var}"
|
||||
;;
|
||||
--help) help ;;
|
||||
--*)
|
||||
help
|
||||
err_msg "unknown option $cmd"
|
||||
return 42
|
||||
;;
|
||||
*)
|
||||
_type="$(type -t "$cmd")"
|
||||
if [ "$_type" != 'function' ]; then
|
||||
err_msg "unknown command: $cmd / use --help"
|
||||
return 42
|
||||
;;
|
||||
*)
|
||||
_type="$(type -t "$cmd")"
|
||||
if [ "$_type" != 'function' ]; then
|
||||
err_msg "unknown command: $cmd / use --help"
|
||||
return 42
|
||||
else
|
||||
"$cmd" "$@"
|
||||
fi
|
||||
;;
|
||||
else
|
||||
"$cmd" "$@"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue