#!/bin/bash # Started by scripts/e2e-edgerealm.sh. Runs inside a throwaway container: a copy of the deployed # code with its own SQLite DB, test user, WS server (port 6099) and game:events worker. # Production data is not touched. set -e mkdir /tmp/app && (cd /src && tar cf - --exclude=./docker-data --exclude=./.git .) | tar xf - -C /tmp/app && cd /tmp/app rm -f .env bootstrap/cache/*.php export APP_ENV=local APP_DEBUG=false APP_KEY="base64:$(head -c 32 /dev/urandom | base64)" export DB_CONNECTION=sqlite DB_DATABASE=/tmp/e2e.sqlite CACHE_STORE=file SESSION_DRIVER=array QUEUE_CONNECTION=sync LOG_CHANNEL=stderr export PUSHER_APP_ID=e2e PUSHER_APP_KEY=e2e PUSHER_APP_SECRET=e2e-secret touch /tmp/e2e.sqlite php artisan migrate --force -q && php artisan db:seed --force -q TOKEN=$(php artisan tinker --execute 'echo App\Models\User::create(["name"=>"E2E","email"=>"e2e@example.test","password"=>"e2e-only-pass"])->createToken("e2e")->plainTextToken;' | tail -1) php artisan websockets:serve --port=6099 > /tmp/ws.log 2>&1 & php artisan game:events > /tmp/worker.log 2>&1 & sleep 4 node /src/scripts/e2e/client.mjs ws://127.0.0.1:6099/app/e2e "$TOKEN" || { echo "--- ws.log"; tail -30 /tmp/ws.log; echo "--- worker.log"; tail -20 /tmp/worker.log; exit 1; }