Add cross-platform visual test tolerance for CI #42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| push: | |
| branches: [development, firefox-ci] | |
| pull_request: | |
| branches: [development] | |
| workflow_call: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test-chrome: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'lts/*' | |
| cache: 'npm' | |
| - name: Log environment versions | |
| run: | | |
| echo "OS: ${{ matrix.os }}" | |
| echo "Node: $(node --version)" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Cache Playwright browsers | |
| id: playwright-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ matrix.os == 'macos-latest' && '~/Library/Caches/ms-playwright' || (matrix.os == 'windows-latest' && '~/AppData/Local/ms-playwright' || '~/.cache/ms-playwright') }} | |
| key: playwright-${{ matrix.os }}-${{ hashFiles('package-lock.json') }} | |
| - name: Install Playwright browsers | |
| if: steps.playwright-cache.outputs.cache-hit != 'true' | |
| run: npx playwright install chromium --with-deps | |
| # Only needed on Linux - Windows/macOS have system deps pre-installed | |
| - name: Install Playwright dependencies (Linux only) | |
| if: steps.playwright-cache.outputs.cache-hit == 'true' && matrix.os == 'ubuntu-latest' | |
| run: npx playwright install-deps chromium | |
| - name: Build Chrome extension | |
| run: npm run build:chrome | |
| - name: Validate GitHub API PAT | |
| id: validate-pat | |
| shell: bash | |
| env: | |
| API_CONTRACT_TEST_PAT: ${{ secrets.API_CONTRACT_TEST_PAT }} | |
| run: | | |
| if [ -z "$API_CONTRACT_TEST_PAT" ]; then | |
| echo "error_msg=API_CONTRACT_TEST_PAT secret is not configured. The API contract test requires this secret." >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| response=$(curl -s -o /dev/null -w "%{http_code}" \ | |
| -H "Authorization: Bearer $API_CONTRACT_TEST_PAT" \ | |
| https://api.github.com/rate_limit) | |
| if [ "$response" = "401" ]; then | |
| echo "error_msg=API_CONTRACT_TEST_PAT is expired or invalid (HTTP 401). Please update the repository secret." >> "$GITHUB_OUTPUT" | |
| elif [ "$response" != "200" ]; then | |
| echo "error_msg=GitHub API returned HTTP $response when validating PAT." >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Run tests (excluding @auth-pat and @auth-session) | |
| run: npm run test:chrome -- --grep-invert "@auth-pat|@auth-session" | |
| - name: Run @auth-pat tests | |
| if: ${{ !steps.validate-pat.outputs.error_msg }} | |
| run: npm run test:chrome -- --grep @auth-pat | |
| env: | |
| API_CONTRACT_TEST_PAT: ${{ secrets.API_CONTRACT_TEST_PAT }} | |
| - name: Fail @auth-pat tests (PAT issue) | |
| if: ${{ steps.validate-pat.outputs.error_msg }} | |
| shell: bash | |
| run: | | |
| echo "::error::${{ steps.validate-pat.outputs.error_msg }}" | |
| exit 1 | |
| - name: Skip @auth-session tests (no session auth in CI) | |
| run: echo "::notice::@auth-session tests skipped - GitHub session auth not available in CI" | |
| - name: Upload Chrome extension | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: chrome-extension-${{ matrix.os }} | |
| path: build/bundle/*.zip | |
| retention-days: 7 | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-report-${{ matrix.os }} | |
| path: tests/runs/chrome/report/ | |
| retention-days: 7 | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }} | |
| path: tests/runs/chrome/results/ | |
| retention-days: 7 | |
| if-no-files-found: ignore | |
| test-firefox: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest, ubuntu-latest] | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'lts/*' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build Firefox extension | |
| run: npm run build:firefox | |
| - name: Run Firefox tests | |
| run: npm run test:firefox | |
| - name: Upload Firefox test screenshots | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: firefox-screenshots-${{ matrix.os }} | |
| path: tests/runs/firefox/screenshots/ | |
| retention-days: 7 | |
| if-no-files-found: ignore | |
| lint: | |
| runs-on: macos-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'lts/*' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build Firefox extension | |
| run: npm run build:firefox | |
| - name: Lint extension | |
| run: npm run lint | |
| - name: Upload Firefox extension | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: firefox-extension | |
| path: build/bundle/*.xpi | |
| retention-days: 7 |