Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add running voiceover on chrome and firefox #26

Merged
merged 17 commits into from
Jul 22, 2024
Merged
20 changes: 20 additions & 0 deletions .github/workflows/voiceover-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ on:
- "13"
- "14"
default: "14"
browser:
description: |
The browser to use for testing, "chrome" or "firefox" or "safari", default "safari"
required: false
type: string

env:
ARIA_AT_WORK_DIR: ${{ inputs.work_dir || 'tests/alert' }}
ARIA_AT_CALLBACK_URL: ${{ inputs.callback_url }}
ARIA_AT_STATUS_URL: ${{ inputs.status_url }}
ARIA_AT_CALLBACK_HEADER: ${{ inputs.callback_header || 'x-header-param:empty' }}
BROWSER: ${{ inputs.browser || 'safari' }}

jobs:
voiceover-test:
Expand All @@ -72,6 +78,20 @@ jobs:
cache: "npm"
cache-dependency-path: "**/package-lock.json"

- uses: browser-actions/setup-chrome@v1
if: inputs.browser == 'chrome'
with:
chrome-version: stable

- uses: browser-actions/setup-firefox@v1
if: inputs.browser == 'firefox'

- name: Install geckodriver
if: inputs.browser == 'firefox'
env:
token: ${{ secrets.GITHUB_TOKEN }}
run: ./install-geckodriver.sh

- name: Setup Environment
uses: guidepup/[email protected]

Expand Down
59 changes: 59 additions & 0 deletions install-geckodriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -euo pipefail

os="$(uname)"
arch="$(uname -m)"
api_token="$token"
api_url="https://api.github.com/repos/mozilla/geckodriver/releases/latest"

if [[ "$os" == "Darwin" ]]; then

# Add Authorization header if a token is provided
if [ -n "$api_token" ]; then
auth_header="Authorization: token $api_token"
else
auth_header=""
fi
# Make the API request and extract the tag_name
latest_version=$(curl -s -H "$auth_header" "$api_url" | awk -F'"' '/tag_name/{print $4}')

if [ -z "$latest_version" ]; then
echo "Failed to get latest version"
exit 1
fi

echo "Found latest version of geckodriver ${latest_version}"

mkdir -p geckodriver
(
cd geckodriver

case "$arch" in
"arm64")
echo "Downloading geckodriver"
wget https://github.com/mozilla/geckodriver/releases/download/${latest_version}/geckodriver-${latest_version}-macos-aarch64.tar.gz

tar xzf geckodriver-${latest_version}-macos-aarch64.tar.gz
;;
"x86_64")
echo "Downloading geckodriver"
wget https://github.com/mozilla/geckodriver/releases/download/${latest_version}/geckodriver-${latest_version}-macos.tar.gz
tar xzf geckodriver-${latest_version}-macos.tar.gz
;;
*)
echo "Unsupported architecture - $arch"
exit 1
;;
esac

chmod +x geckodriver
echo "geckodriver available at ${PWD}"
)
echo "Running geckodriver --version"
geckodriver/geckodriver --version
exit 0
else
echo "Unsupported OS - ${os}"
exit 1
fi
75 changes: 66 additions & 9 deletions run-tester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,83 @@

set -euo pipefail

# This URL is used for firefox and chrome, and is only a placeholder for safari.
# When run in macOS, the test harness does not use WebDriver because
# SafariDriver's "glass pane" feature interferes with testing. Provide a valid
# URL simply as a placeholder.
url_placeholder=http://example.com
# SafariDriver's "glass pane" feature interferes with testing.
webdriver_url=http://127.0.0.1:4444

aria-at-automation-driver/package/bin/at-driver serve --port 3031 > at-driver.log 2>&1 &

atdriver_pid=$!
# Initialize so we can set up trap right away
webdriver_pid=0
atdriver_pid=0

function clean_up {
kill -9 ${atdriver_pid} || true
if [[ ${webdriver_pid} -ne 0 ]]; then
kill -9 ${webdriver_pid} || true
fi
if [[ ${atdriver_pid} -ne 0 ]]; then
kill -9 ${atdriver_pid} || true
fi
}
trap clean_up EXIT

aria-at-automation-driver/package/bin/at-driver serve --port 3031 > at-driver.log 2>&1 &
atdriver_pid=$!

poll_url() {
local url="$1"
local attempt=0
echo "Polling ${url}"

while [ ${attempt} -lt 30 ]; do
((attempt++))

response=$(curl -s -o /dev/null -v -w "%{http_code}" -m 2 "$url" || true)
gnarf marked this conversation as resolved.
Show resolved Hide resolved

if [ ${response:--1} -ge 99 ]; then
echo "Success: ${response} after ${attempt} tries"
return 0
else
echo "Attempt ${attempt}: URL ${url} returned HTTP ${response}. Retrying in 1 second..."
sleep 1
fi
done

echo "Error: Max attempts reached. ${url} is not responding."
exit 1
}

case ${BROWSER} in
chrome)
echo "Starting chromedriver"
chromedriver --port=4444 --log-level=INFO > webdriver.log 2>&1 &
webdriver_pid=$!
echo "Started chromedriver"
poll_url $webdriver_url
;;

firefox)
echo "Starting geckodriver"
geckodriver/geckodriver > webdriver.log 2>&1 &
webdriver_pid=$!
echo "Started geckodriver"
poll_url $webdriver_url
;;

safari)
;;

*)
echo "Unknown browser (${BROWSER})"
exit 1
;;
esac

node aria-at-automation-harness/bin/host.js run-plan \
--plan-workingdir aria-at/build/${ARIA_AT_WORK_DIR} \
--debug \
--agent-web-driver-url=${url_placeholder} \
--agent-web-driver-url=${webdriver_url} \
--agent-at-driver-url=ws://127.0.0.1:3031/session \
--reference-hostname=127.0.0.1 \
--agent-web-driver-browser=safari \
--agent-web-driver-browser=${BROWSER} \
'{reference/**,test-*-voiceover_macos.*}' 2>&1 | \
tee harness-run.log
Loading