|
| 1 | +name: A11y / Playwright Scans |
| 2 | + |
| 3 | +on: |
| 4 | + # TEMP: remove before merging — allows testing the workflow from this |
| 5 | + # branch, since workflow_dispatch only registers once the file is on main. |
| 6 | + push: |
| 7 | + branches: [feat/a11y] |
| 8 | + # TEMP: remove before merging — run on PRs while validating the workflow. |
| 9 | + pull_request: |
| 10 | + schedule: |
| 11 | + # Run nightly at 02:00 UTC, after the nightly build window |
| 12 | + - cron: "0 2 * * *" |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + ref: |
| 16 | + description: "(Optional) ref to checkout" |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + assert: |
| 20 | + description: "Fail the run when scans differ from committed baselines" |
| 21 | + required: false |
| 22 | + type: boolean |
| 23 | + default: false |
| 24 | + |
| 25 | +env: |
| 26 | + NODE_VERSION: "22" |
| 27 | + PYTHON_VERSION: "3.13" |
| 28 | + # Define the directory where Playwright browsers will be installed. |
| 29 | + # This path is used for caching across workflows |
| 30 | + PLAYWRIGHT_BROWSERS_PATH: "ms-playwright" |
| 31 | + PLAYWRIGHT_VERSION: "1.59.1" |
| 32 | + |
| 33 | +jobs: |
| 34 | + a11y-scan: |
| 35 | + name: IBM Equal Access |
| 36 | + runs-on: ubuntu-latest |
| 37 | + permissions: |
| 38 | + contents: read |
| 39 | + steps: |
| 40 | + # Cron only fires from the default branch, so scheduled runs resolve the |
| 41 | + # latest release-* branch and scan that (same pattern as nightly_build). |
| 42 | + - name: Resolve Ref To Scan |
| 43 | + id: resolve_ref |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + if [ -n "${{ inputs.ref }}" ]; then |
| 47 | + REF="${{ inputs.ref }}" |
| 48 | + elif [ "${{ github.event_name }}" = "schedule" ]; then |
| 49 | + REF=$(git ls-remote --heads https://github.com/${{ github.repository }} 'refs/heads/release-*' \ |
| 50 | + | awk '{print $2}' \ |
| 51 | + | sed 's|refs/heads/||' \ |
| 52 | + | grep -E '^release-[0-9]+\.[0-9]+\.[0-9]+$' \ |
| 53 | + | sort -V \ |
| 54 | + | tail -n 1) |
| 55 | + if [ -z "$REF" ]; then |
| 56 | + echo "No release-* branch found in ${{ github.repository }}" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + else |
| 60 | + REF="${{ github.ref }}" |
| 61 | + fi |
| 62 | + echo "ref=$REF" >> "$GITHUB_OUTPUT" |
| 63 | + echo "Scanning ref: $REF" |
| 64 | +
|
| 65 | + - name: Checkout Repository |
| 66 | + uses: actions/checkout@v6 |
| 67 | + with: |
| 68 | + ref: ${{ steps.resolve_ref.outputs.ref }} |
| 69 | + |
| 70 | + - name: Setup Node.js Environment |
| 71 | + uses: actions/setup-node@v6 |
| 72 | + with: |
| 73 | + node-version: ${{ env.NODE_VERSION }} |
| 74 | + |
| 75 | + - name: Get npm cache directory |
| 76 | + id: npm-cache-dir |
| 77 | + shell: bash |
| 78 | + run: echo "dir=$(npm config get cache)" >> "$GITHUB_OUTPUT" |
| 79 | + |
| 80 | + - name: Cache npm dependencies |
| 81 | + uses: actions/cache@v5 |
| 82 | + continue-on-error: true |
| 83 | + with: |
| 84 | + path: ${{ steps.npm-cache-dir.outputs.dir }} |
| 85 | + key: ${{ runner.os }}-npm-${{ env.NODE_VERSION }}-${{ hashFiles('src/frontend/package-lock.json') }} |
| 86 | + restore-keys: | |
| 87 | + ${{ runner.os }}-npm-${{ env.NODE_VERSION }}- |
| 88 | +
|
| 89 | + - name: Install Frontend Dependencies |
| 90 | + run: npm ci |
| 91 | + working-directory: ./src/frontend |
| 92 | + |
| 93 | + - name: Cache Playwright Browsers |
| 94 | + id: cache-playwright |
| 95 | + uses: actions/cache@v5 |
| 96 | + continue-on-error: true |
| 97 | + with: |
| 98 | + path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }} |
| 99 | + key: playwright-${{ env.PLAYWRIGHT_VERSION }}-chromium-${{ runner.os }} |
| 100 | + restore-keys: | |
| 101 | + playwright-${{ env.PLAYWRIGHT_VERSION }}-chromium-${{ runner.os }} |
| 102 | +
|
| 103 | + - name: Install Playwright Browser Dependencies |
| 104 | + if: steps.cache-playwright.outputs.cache-hit != 'true' |
| 105 | + shell: bash |
| 106 | + run: | |
| 107 | + cd ./src/frontend |
| 108 | + npx playwright install --with-deps chromium |
| 109 | +
|
| 110 | + - name: "Setup Environment" |
| 111 | + uses: astral-sh/setup-uv@v6 |
| 112 | + with: |
| 113 | + enable-cache: true |
| 114 | + cache-dependency-glob: "uv.lock" |
| 115 | + python-version: ${{ env.PYTHON_VERSION }} |
| 116 | + prune-cache: false |
| 117 | + |
| 118 | + - name: Install Python Dependencies |
| 119 | + run: uv sync |
| 120 | + |
| 121 | + - name: Run Playwright Specs With IBM Scans |
| 122 | + shell: bash |
| 123 | + env: |
| 124 | + RUN_A11Y: "true" |
| 125 | + RUN_A11Y_ASSERT: ${{ github.event_name == 'workflow_dispatch' && inputs.assert && 'true' || 'false' }} |
| 126 | + LANGFLOW_DEACTIVATE_TRACING: "true" |
| 127 | + run: | |
| 128 | + cd src/frontend |
| 129 | + # Only specs that call runA11yScan produce reports; discover them |
| 130 | + # so new scan hosts are picked up without editing this workflow. |
| 131 | + SCAN_SPECS=$(grep -rl "runA11yScan(" tests --include="*.spec.ts" | sort) |
| 132 | + echo "Specs with a11y scans:" |
| 133 | + echo "$SCAN_SPECS" |
| 134 | + test -n "$SCAN_SPECS" |
| 135 | + npx playwright test $SCAN_SPECS --project=chromium --workers=1 --retries=2 |
| 136 | +
|
| 137 | + - name: Build Aggregated A11y Summary |
| 138 | + if: always() |
| 139 | + shell: bash |
| 140 | + run: | |
| 141 | + cd src/frontend |
| 142 | + if ls coverage/accessibility-reports/*.json > /dev/null 2>&1; then |
| 143 | + npm run a11y:report --silent |
| 144 | + { |
| 145 | + echo '```text' |
| 146 | + npm run a11y:report --silent |
| 147 | + echo '```' |
| 148 | + } >> "$GITHUB_STEP_SUMMARY" |
| 149 | + else |
| 150 | + echo "No accessibility reports were generated." | tee -a "$GITHUB_STEP_SUMMARY" |
| 151 | + fi |
| 152 | +
|
| 153 | + - name: Upload Accessibility Reports |
| 154 | + if: always() |
| 155 | + uses: actions/upload-artifact@v6 |
| 156 | + with: |
| 157 | + name: accessibility-reports-${{ github.run_attempt }} |
| 158 | + path: src/frontend/coverage/accessibility-reports |
| 159 | + retention-days: 30 |
| 160 | + overwrite: true |
0 commit comments