0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 18:26:15 +01:00
posthog/plugin-server/bin/ci_functional_tests.sh
timgl 22bd594263
fix(webhooks): Always check for unsafe urls (#18360)
* fix(webhooks): Always check for unsafe urls

* Roll out the hostname guard fully

The mechanism is now only disabled in local dev.

* Update hooks.test.ts

* Disable URL check in functional tests

---------

Co-authored-by: Michael Matloka <michal@matloka.com>
2023-11-03 12:58:30 +01:00

74 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Script for running the functional tests in CI, outputting an Istambul coverage
# report. When running the intetgration tests locally, it's probably better to
# simply run `pnpm functional_tests` directly which will allow e.g. to watch for
# changes. This script is intended to handle the complexities of spinning up the
# plugin server with the appropriate environment vars setup, and ensuring we
# bring down the server such that c8 produces the coverage report.
# Context is this was originally written in the GitHub Actions workflow file,
# but it's easier to debug in a script.
set -e -o pipefail
export WORKER_CONCURRENCY=1
export CONVERSION_BUFFER_ENABLED=true
export BUFFER_CONVERSION_SECONDS=2 # Make sure we don't have to wait for the default 60 seconds
export KAFKA_MAX_MESSAGE_BATCH_SIZE=0
export APP_METRICS_GATHERED_FOR_ALL=true
export NODE_ENV=production-functional-tests
# Not important at all, but I like to see nice red/green for tests
export FORCE_COLOR=true
LOG_FILE=$(mktemp)
echo '::group::Starting plugin server'
NODE_OPTIONS='--max_old_space_size=4096' ./node_modules/.bin/c8 --reporter html node dist/index.js >"$LOG_FILE" 2>&1 &
SERVER_PID=$!
SECONDS=0
until curl http://localhost:6738/_ready; do
if ((SECONDS > 60)); then
echo 'Timed out waiting for plugin-server to be ready'
echo '::endgroup::'
echo '::group::Plugin Server logs'
cat "$LOG_FILE"
echo '::endgroup::'
exit 1
fi
echo ''
echo 'Waiting for plugin-server to be ready...'
sleep 1
done
echo ''
echo '::endgroup::'
set +e
pnpm functional_tests --maxConcurrency=10 --verbose
exit_code=$?
set -e
kill $SERVER_PID
SECONDS=0
while kill -0 $SERVER_PID; do
if ((SECONDS > 60)); then
echo 'Timed out waiting for plugin-server to exit'
break
fi
echo "Waiting for plugin-server to exit, pid $SERVER_PID..."
sleep 1
done
echo '::group::Plugin Server logs'
cat "$LOG_FILE"
echo '::endgroup::'
exit $exit_code