2022-11-05 04:04:13 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
TEMP_DB=$(mktemp)
|
|
|
|
BUILD_ID=$((RANDOM % 7200 + 600))
|
2023-01-05 07:25:51 +01:00
|
|
|
BROWSER="electron" # Default. Will try to use Google Chrome.
|
2023-01-05 07:15:10 +01:00
|
|
|
|
|
|
|
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
|
2022-11-05 04:04:13 +01:00
|
|
|
|
|
|
|
# Change to the root directory of the repository
|
2023-01-05 07:15:10 +01:00
|
|
|
pushd "$(git rev-parse --show-toplevel)"
|
2022-11-05 04:04:13 +01:00
|
|
|
|
|
|
|
# Bundle the updated web code into the server codebase.
|
2023-01-05 07:25:51 +01:00
|
|
|
if [ -z "$SKIP_BUILD" ]; then
|
2023-01-05 07:15:10 +01:00
|
|
|
echo "Bundling web code into server..."
|
|
|
|
./build/web/bundleWeb.sh >/dev/null
|
|
|
|
else
|
|
|
|
echo "Skipping web build..."
|
|
|
|
fi
|
2022-11-05 04:04:13 +01:00
|
|
|
|
|
|
|
# Install the web test framework
|
2023-01-05 07:15:10 +01:00
|
|
|
if [ -z "$SKIP_BUILD" ]; then
|
|
|
|
echo "Installing test dependencies..."
|
|
|
|
pushd test/automated/browser
|
|
|
|
npm install --quiet --no-progress
|
2022-11-05 04:04:13 +01:00
|
|
|
|
2023-01-05 07:15:10 +01:00
|
|
|
popd
|
|
|
|
else
|
|
|
|
echo "Skipping dependencies installation"
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -o nounset
|
2022-11-05 04:04:13 +01:00
|
|
|
|
|
|
|
# Download a specific version of ffmpeg
|
2023-01-04 23:22:55 +01:00
|
|
|
if [ ! -d "ffmpeg" ]; then
|
|
|
|
echo "Downloading ffmpeg..."
|
|
|
|
mkdir -p /tmp/ffmpeg
|
|
|
|
pushd /tmp/ffmpeg >/dev/null
|
|
|
|
curl -sL --fail https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.2.1/ffmpeg-4.2.1-linux-64.zip --output ffmpeg.zip
|
|
|
|
unzip -o ffmpeg.zip >/dev/null
|
|
|
|
PATH=$PATH:$(pwd)
|
|
|
|
popd >/dev/null
|
|
|
|
fi
|
2022-11-05 04:04:13 +01:00
|
|
|
|
|
|
|
# Build and run owncast from source
|
|
|
|
echo "Building owncast..."
|
|
|
|
go build -o owncast main.go
|
2023-01-05 07:15:10 +01:00
|
|
|
|
2022-11-05 04:04:13 +01:00
|
|
|
echo "Running owncast..."
|
2022-12-26 04:17:13 +01:00
|
|
|
./owncast -database "$TEMP_DB" &
|
2022-11-05 04:04:13 +01:00
|
|
|
SERVER_PID=$!
|
|
|
|
|
|
|
|
pushd test/automated/browser
|
|
|
|
|
|
|
|
# Run cypress browser tests for desktop
|
2023-01-05 07:15:10 +01:00
|
|
|
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"
|
2022-11-05 04:04:13 +01:00
|
|
|
# Run cypress browser tests for mobile
|
2023-01-05 07:15:10 +01:00
|
|
|
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
|
2022-11-05 04:04:13 +01:00
|
|
|
|
|
|
|
# Start streaming the test file over RTMP to
|
|
|
|
# the local owncast instance.
|
|
|
|
echo "Waiting for stream to start..."
|
2023-01-04 23:22:55 +01:00
|
|
|
ffmpeg -hide_banner -loglevel panic -stream_loop -1 -re -i ../test.mp4 -vcodec libx264 -profile:v main -sc_threshold 0 -b:v 1300k -acodec copy -f flv rtmp://127.0.0.1/live/abc123 &
|
2022-11-05 04:04:13 +01:00
|
|
|
STREAMING_CLIENT=$!
|
|
|
|
|
|
|
|
function finish {
|
|
|
|
echo "Cleaning up..."
|
2023-01-04 23:22:55 +01:00
|
|
|
rm "$TEMP_DB"
|
2022-11-05 04:04:13 +01:00
|
|
|
kill $SERVER_PID $STREAMING_CLIENT
|
|
|
|
}
|
|
|
|
trap finish EXIT SIGHUP SIGINT SIGTERM SIGQUIT SIGABRT SIGTERM
|
|
|
|
|
|
|
|
sleep 20
|
|
|
|
|
|
|
|
# Run cypress browser tests for desktop
|
2023-01-05 07:15:10 +01:00
|
|
|
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"
|
2022-11-05 04:04:13 +01:00
|
|
|
# Run cypress browser tests for mobile
|
2023-01-05 07:15:10 +01:00
|
|
|
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
|