Add performance testing to Cypress results

This commit is contained in:
Gabe Kangas
2023-01-04 22:15:10 -08:00
parent 74cbc949ea
commit 80ab351cbe
8 changed files with 3845 additions and 17 deletions

View File

@@ -1,25 +1,42 @@
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
TEMP_DB=$(mktemp)
BUILD_ID=$((RANDOM % 7200 + 600))
BROWSER="electron" #Default. Will try to use Google Chrome.
if hash google-chrome 2>/dev/null; then
BROWSER="chrome"
echo "Using Google Chrome as a browser."
else
echo "Google Chrome not found. Using Electron."
fi
# Change to the root directory of the repository
cd "$(git rev-parse --show-toplevel)"
pushd "$(git rev-parse --show-toplevel)"
# Bundle the updated web code into the server codebase.
echo "Bundling web code into server..."
./build/web/bundleWeb.sh >/dev/null
if [ -z $SKIP_BUILD ]; then
echo "Bundling web code into server..."
./build/web/bundleWeb.sh >/dev/null
else
echo "Skipping web build..."
fi
# Install the web test framework
echo "Installing test dependencies..."
pushd test/automated/browser
npm install --quiet --no-progress
if [ -z "$SKIP_BUILD" ]; then
echo "Installing test dependencies..."
pushd test/automated/browser
npm install --quiet --no-progress
popd
popd
else
echo "Skipping dependencies installation"
fi
set -o nounset
# Download a specific version of ffmpeg
if [ ! -d "ffmpeg" ]; then
@@ -35,6 +52,7 @@ fi
# Build and run owncast from source
echo "Building owncast..."
go build -o owncast main.go
echo "Running owncast..."
./owncast -database "$TEMP_DB" &
SERVER_PID=$!
@@ -42,9 +60,9 @@ SERVER_PID=$!
pushd test/automated/browser
# Run cypress browser tests for desktop
npx cypress run --group "desktop-offline" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js"
npx cypress run --browser "$BROWSER" --group "desktop-offline" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js"
# Run cypress browser tests for mobile
npx cypress run --group "mobile-offline" --ci-build-id $BUILD_ID --tag "mobile,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js" --config viewportWidth=375,viewportHeight=667
npx cypress run --browser "$BROWSER" --group "mobile-offline" --ci-build-id $BUILD_ID --tag "mobile,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js" --config viewportWidth=375,viewportHeight=667
# Start streaming the test file over RTMP to
# the local owncast instance.
@@ -62,6 +80,6 @@ trap finish EXIT SIGHUP SIGINT SIGTERM SIGQUIT SIGABRT SIGTERM
sleep 20
# Run cypress browser tests for desktop
npx cypress run --group "desktop-online" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,online" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/online/*.cy.js"
npx cypress run --browser "$BROWSER" --group "desktop-online" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,online" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/online/*.cy.js"
# Run cypress browser tests for mobile
npx cypress run --group "mobile-online" --ci-build-id $BUILD_ID --tag "mobile,online" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/online/*.cy.js" --config viewportWidth=375,viewportHeight=667
npx cypress run --browser "$BROWSER" --group "mobile-online" --ci-build-id $BUILD_ID --tag "mobile,online" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/online/*.cy.js" --config viewportWidth=375,viewportHeight=667