Files
posthog/plugin-server/bin/ci_functional_tests.sh
Thomas Obermüller 4a30e78b22 chore: use pnpm to manage dependencies (closes #12635) (#13190)
* chore: use pnpm to manage dependencies

* Fix CI errors

* Don't report Docker image size for external PRs

* Fix pnpm-lock.yaml formatting

* Fix module versions

* Ignore pnpm-lock.yaml

* Upgrade Cypress action for pnpm support

* Set up node and pnpm before Cypress

* Fix typescript issues

* Include patches directory in Dockerfile

* Fix Jest tests in CI

* Update lockfile

* Update lockfile

* Clean up Dockerfile

* Update pnpm-lock.yaml to reflect current package.json files

* remove yarn-error.log from .gitignore

* formatting

* update data exploration readme

* type jest.config.ts

* fix @react-hook issues for jest

* fix react-syntax-highlighter issues for jest

* fix jest issues from query-selector-shadow-dom

* fix transform ignore patterns and undo previous fixes

* add missing storybook peer dependencies

* fix nullish coalescing operator for storybook

* reorder storybook plugins

* update editor-update-tsd warning to new npm script

* use legacy ssl for chromatic / node 18 compatibility

* use pnpm for visual regression testing workflow

* use node 16 for chromatic

* add @babel/plugin-proposal-nullish-coalescing-operator as direct dependency

* try fix for plugin-server

* cleanup

* fix comment and warning

* update more comments

* update playwright dockerfile

* update plugin source types

* conditional image size reporting

* revert react-native instructions

* less restrictive pnpm verions

* use ref component name in line with style guide

Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
2022-12-12 10:28:06 +01:00

55 lines
1.5 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
LOG_FILE=$(mktemp)
echo '::group::Starting plugin server'
./node_modules/.bin/c8 --reporter html node dist/index.js > $LOG_FILE 2>&1 &
SERVER_PID=$!
until curl http://localhost:6738/_ready; do
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
while kill -0 $SERVER_PID; do
echo "Waiting for plugin-server to exit, pid $SERVER_PID..."
((c++)) && ((c==60)) && break
sleep 1
done
echo '::group::Plugin Server logs'
cat $LOG_FILE
echo '::endgroup::'
exit $exit_code