gristlabs_grist-core/test/test_under_docker.sh
Paul Fitzpatrick 65ac8aaa85 (core) run test:docker target prior to pushing grist-core image
Summary:
This activates the new tests that can run on a grist-core image,
and will not push a new version to `latest` tag unless those tests
pass.

This also runs a smoke test in the regular CI tests, to confirm the
code continues to work without GRIST_TEST_LOGIN enabled.

Test Plan: tested on a fork of grist-core

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3186
2021-12-14 14:22:02 -05:00

55 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# This runs browser tests with the server started using docker, to
# catch any configuration problems.
# Run with MOCHA_WEBDRIVER_HEADLESS=1 for headless operation.
# Run with VERBOSE=1 for server logs.
# Settings for script robustness
set -o pipefail # trace ERR through pipes
set -o nounset # same as set -u : treat unset variables as an error
set -o errtrace # same as set -E: inherit ERR trap in functions
set -o errexit # same as set -e: exit on command failures
trap 'cleanup' EXIT
trap 'echo "Exiting on SIGINT"; exit 1' INT
trap 'echo "Exiting on SIGTERM"; exit 1' TERM
PORT=8585
DOCKER_CONTAINER=grist-core-test
DOCKER_PID=""
cleanup() {
return_value=$?
docker rm -f $DOCKER_CONTAINER
if [ -n "$DOCKER_PID" ]; then
wait $DOCKER_PID || echo "docker container gone"
fi
echo "Cleaned up docker container, bye."
exit $return_value
}
docker run --name $DOCKER_CONTAINER --rm \
--env VERBOSE=${VERBOSE:-} \
-p $PORT:$PORT --env PORT=$PORT \
--env GRIST_SESSION_COOKIE=grist_test_cookie \
--env GRIST_TEST_LOGIN=1 \
--env TEST_SUPPORT_API_KEY=api_key_for_support \
${TEST_IMAGE:-gristlabs/grist} &
DOCKER_PID="$!"
echo "[waiting for server]"
while true; do
curl -s http://localhost:$PORT/status && break
sleep 1
done
echo ""
echo "[server found]"
TEST_ADD_SAMPLES=1 TEST_ACCOUNT_PASSWORD=not-needed \
HOME_URL=http://localhost:8585 \
GRIST_SESSION_COOKIE=grist_test_cookie \
GRIST_TEST_LOGIN=1 \
NODE_PATH=_build:_build/stubs \
mocha _build/test/nbrowser/*.js "$@"