diff --git a/.gitea/workflows/playwright-install.yml b/.gitea/workflows/playwright-install.yml new file mode 100644 index 00000000..6a9f19ac --- /dev/null +++ b/.gitea/workflows/playwright-install.yml @@ -0,0 +1,180 @@ +# playwright-install.yml — Install Playwright for visual smoke tests +# Refs: Issue #561, PR #558 (nexus_smoke_test.py) +# +# Installs Playwright and Chromium for visual smoke tests. +# Can be reused by other workflows that need browser automation. + +name: Install Playwright + +on: + # Run when called by other workflows + workflow_call: + inputs: + install_chromium: + description: 'Install Chromium browser' + required: false + default: true + type: boolean + install_deps: + description: 'Install system dependencies' + required: false + default: true + type: boolean + + # Run on push to main when Playwright files change + push: + branches: [main] + paths: + - 'scripts/**/nexus_smoke_test.py' + - 'scripts/**/*playwright*' + - '.gitea/workflows/playwright-install.yml' + + # Run on PRs that touch Playwright files + pull_request: + paths: + - 'scripts/**/nexus_smoke_test.py' + - 'scripts/**/*playwright*' + - '.gitea/workflows/playwright-install.yml' + +jobs: + install-playwright: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install playwright + + - name: Install Playwright browsers + if: inputs.install_chromium + run: | + playwright install chromium + playwright install-deps chromium + + - name: Install system dependencies + if: inputs.install_deps + run: | + sudo apt-get update + sudo apt-get install -y \ + libnss3 \ + libnspr4 \ + libatk1.0-0 \ + libatk-bridge2.0-0 \ + libcups2 \ + libdrm2 \ + libxkbcommon0 \ + libxcomposite1 \ + libxdamage1 \ + libxfixes3 \ + libxrandr2 \ + libgbm1 \ + libpango-1.0-0 \ + libcairo2 \ + libasound2 \ + libatspi2.0-0 \ + libwayland-client0 + + - name: Verify Playwright installation + run: | + python -c "import playwright; print(f'Playwright version: {playwright.__version__}')" + python -c "from playwright.sync_api import sync_playwright; print('Playwright API imported successfully')" + playwright --version + + - name: Test Chromium launch + if: inputs.install_chromium + run: | + python -c " + from playwright.sync_api import sync_playwright + with sync_playwright() as p: + browser = p.chromium.launch() + page = browser.new_page() + page.goto('data:text/html,