Skip to content

Asap 178 accessibility audit #16

Asap 178 accessibility audit

Asap 178 accessibility audit #16

name: Accessibility Scan
on:
pull_request:
branches: [ main, dev ]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Compile CSS and JS
run: |
npm install -g [email protected] [email protected]
yarn install
yarn build
yarn build:css
- name: Set up database
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432/access_pdf_test
run: |
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails db:setup
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Firefox and GeckoDriver
run: |
sudo apt-get update
sudo apt-get install -y firefox wget xvfb dbus-x11 openbox
sudo rm -rf /var/lib/apt/lists/*
# Use a more recent GeckoDriver version
wget -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-linux64.tar.gz
sudo tar -xzf /tmp/geckodriver.tar.gz -C /usr/local/bin/
sudo chmod +x /usr/local/bin/geckodriver
rm /tmp/geckodriver.tar.gz
# Verify installations
firefox --version
geckodriver --version
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r python_components/accessibility_scan/requirements.txt
- name: Start Rails server
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432/access_pdf_test
run: |
# Start Rails server on a specific port in the background
bin/rails server -e test -p 3000 &
echo $! > rails_server.pid
# Wait for Rails server to be ready
echo "Waiting for Rails server to start..."
timeout=60
while ! curl -f http://localhost:3000 >/dev/null 2>&1; do
sleep 2
timeout=$((timeout - 2))
if [ $timeout -le 0 ]; then
echo "Rails server failed to start within 60 seconds"
exit 1
fi
done
echo "Rails server is ready!"
- name: Debug Environment
run: |
echo "=== System Information ==="
uname -a
echo "=== Firefox Version ==="
firefox --version
echo "=== GeckoDriver Version ==="
geckodriver --version
echo "=== Network ==="
netstat -tlnp | grep :3000
echo "=== Rails Server Test ==="
curl -v http://localhost:3000 || echo "Rails server not responding"
- name: Run Accessibility Scan
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432/access_pdf_test
DISPLAY: :99
MOZ_HEADLESS: 1
DBUS_SESSION_BUS_ADDRESS: /dev/null
run: |
# Start virtual display with better settings
Xvfb :99 -screen 0 1280x1024x24 -ac +extension GLX +render -noreset &
XVFB_PID=$!
sleep 3
# Debug: Check if Xvfb is running
if ! ps -p $XVFB_PID > /dev/null; then
echo "Xvfb failed to start"
exit 1
fi
# Debug: Check if Rails server is still running
curl -f http://localhost:3000 || (echo "Rails server not responding" && exit 1)
# Set additional Firefox environment variables for headless mode
export MOZ_HEADLESS=1
export DISPLAY=:99
export GECKO_DRIVER_LOG=debug
# Run the accessibility scan with timeout
timeout 300 python python_components/accessibility_scan/main.py || (echo "Accessibility scan timed out or failed" && exit 1)
- name: Stop Rails server
if: always()
run: |
if [ -f rails_server.pid ]; then
kill $(cat rails_server.pid) || true
rm rails_server.pid
fi