* Add TypeScript test workflow * Update follow-redirects and katex versions * Add Python setup and Poetry installation for backend * Update Poetry version and setup Python in workflows * Add Poetry installation step to GitHub Actions workflow * Add Playwright report artifact upload and improve test script * Update Playwright test configuration and add global teardown script * Update path for playwright-report directory * Update timeout value in playwright.config.ts * Update page URLs in end-to-end tests * Update GitHub Actions workflow and Playwright configuration * Update TypeScript test workflow * Add pattern and merge-multiple options to artifact download * Update TypeScript test workflow to install Poetry * Add cache steps for Playwright and Poetry * Update PLAYWRIGHT_BROWSERS_PATH in TypeScript test workflow * Add 'stuff/' to .gitignore * Remove caching of Poetry virtualenv * Update frontend tests to use Playwright for UI testing * Add global teardown for removing temp database * Add cache-hit condition to setup-node and setup-python steps * Add new file to .gitignore and update ignored files * Update playwright cache key in TypeScript test workflow * Update path for blob-report in GitHub workflow * Update path for playwright cache * Update dependency installation in workflows * Update baseURL in playwright.config.ts * Update baseURL in playwright.config.ts * Refactor test timeouts * Remove playwright-report index.html file * Add npm run start command to playwright.config.ts * Update npm start command in playwright.config.ts * Update Playwright browser caching and installation * Update playwright cache path * Update playwright cache path * Update actions/cache version to v4 * Update Playwright cache key to use package-lock.json * Update Playwright cache and install dependencies * Fix typo in Playwright installation command * Fix npm ci command in TypeScript test workflow * Update TypeScript test workflow
118 lines
No EOL
3.1 KiB
Bash
Executable file
118 lines
No EOL
3.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Default value for the --ui flag
|
|
ui=false
|
|
|
|
# Absolute path to the project root directory
|
|
PROJECT_ROOT="../../"
|
|
|
|
# Check if necessary commands are available
|
|
for cmd in npx poetry fuser; do
|
|
if ! command -v $cmd &> /dev/null; then
|
|
echo "Error: Required command '$cmd' is not installed. Aborting."
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# Parse command-line arguments
|
|
while [[ $# -gt 0 ]]; do
|
|
key="$1"
|
|
case $key in
|
|
--ui)
|
|
ui=true
|
|
shift
|
|
;;
|
|
*)
|
|
echo "Unknown option: $key"
|
|
exit 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# Function to forcibly terminate a process by port
|
|
terminate_process_by_port() {
|
|
port="$1"
|
|
echo "Terminating process on port: $port"
|
|
if ! fuser -k -n tcp "$port"; then
|
|
echo "Failed to terminate process on port $port. Please check manually."
|
|
else
|
|
echo "Process terminated."
|
|
fi
|
|
}
|
|
|
|
delete_temp() {
|
|
if cd "$PROJECT_ROOT"; then
|
|
echo "Deleting temp database"
|
|
rm -f temp && echo "Temp database deleted." || echo "Failed to delete temp database."
|
|
else
|
|
echo "Failed to navigate to project root for cleanup."
|
|
fi
|
|
}
|
|
|
|
# Trap signals to ensure cleanup on script termination
|
|
trap 'terminate_process_by_port 7860; terminate_process_by_port 3000; delete_temp' EXIT
|
|
|
|
# Ensure the script is executed from the project root directory
|
|
if ! cd "$PROJECT_ROOT"; then
|
|
echo "Error: Failed to navigate to project root directory. Aborting."
|
|
exit 1
|
|
fi
|
|
|
|
# Install playwright if not installed yet
|
|
if ! npx playwright install; then
|
|
echo "Error: Failed to install Playwright. Aborting."
|
|
exit 1
|
|
fi
|
|
|
|
# Start the frontend
|
|
make frontend > /dev/null 2>&1 &
|
|
|
|
# Adjust sleep duration as needed
|
|
sleep 10
|
|
|
|
# Install backend dependencies
|
|
if ! poetry install; then
|
|
echo "Error: Failed to install backend dependencies. Aborting."
|
|
exit 1
|
|
fi
|
|
|
|
# Start the backend
|
|
LANGFLOW_DATABASE_URL=sqlite:///./temp LANGFLOW_AUTO_LOGIN=True poetry run langflow run --backend-only --port 7860 --host 0.0.0.0 --no-open-browser > /dev/null 2>&1 &
|
|
backend_pid=$! # Capture PID of the backend process
|
|
# Adjust sleep duration as needed
|
|
sleep 25
|
|
|
|
# Navigate to the test directory
|
|
if ! cd src/frontend; then
|
|
echo "Error: Failed to navigate to test directory. Aborting."
|
|
kill $backend_pid # Terminate the backend process if navigation fails
|
|
echo "Backend process terminated."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if backend is running
|
|
if ! lsof -i :7860; then
|
|
echo "Error: Backend is not running. Aborting."
|
|
exit 1
|
|
fi
|
|
|
|
# Run Playwright tests
|
|
if [ "$ui" = true ]; then
|
|
TEST_COMMAND="npx playwright test tests/end-to-end --ui --project=chromium"
|
|
else
|
|
TEST_COMMAND="npx playwright test tests/end-to-end --project=chromium"
|
|
fi
|
|
|
|
if ! PLAYWRIGHT_HTML_REPORT=playwright-report/e2e $TEST_COMMAND; then
|
|
echo "Error: Playwright tests failed. Aborting."
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$ui" = true ]; then
|
|
echo "Opening Playwright report..."
|
|
npx playwright show-report
|
|
fi
|
|
|
|
|
|
trap 'terminate_process_by_port 7860; terminate_process_by_port 3000; delete_temp; kill $backend_pid 2>/dev/null' EXIT |