Validate Mock Selectors #8
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: Validate Mock Selectors | |
| on: | |
| schedule: | |
| # Run weekly on Mondays at 9am UTC | |
| - cron: '0 9 * * 1' | |
| workflow_dispatch: | |
| jobs: | |
| validate: | |
| name: Validate Provider Selectors | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Playwright browsers | |
| run: npx playwright install chromium | |
| - name: Validate mock selectors | |
| id: validate | |
| continue-on-error: true | |
| run: npm run validate:mocks | |
| - name: Create issue on failure | |
| if: steps.validate.outcome == 'failure' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const title = 'Mock Selector Validation Failed'; | |
| const body = `## Mock Selector Validation Failed | |
| The weekly validation of mock provider selectors has detected issues. | |
| This means one or more genealogy providers have updated their website structure, | |
| and our mock templates may need to be updated to match. | |
| ### Action Required | |
| 1. Review the [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) | |
| 2. Update the affected selectors in \`tests/__mocks__/providers/*/selectors.json\` | |
| 3. Update the corresponding HTML templates in \`tests/__mocks__/providers/*/pages/\` | |
| 4. Re-run the scraper tests to verify | |
| ### Affected Run | |
| - Workflow: ${context.workflow} | |
| - Run ID: ${context.runId} | |
| - Date: ${new Date().toISOString()} | |
| /label mock-validation`; | |
| // Check if issue already exists | |
| const { data: issues } = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| labels: 'mock-validation', | |
| state: 'open' | |
| }); | |
| if (issues.length === 0) { | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title, | |
| body, | |
| labels: ['mock-validation', 'maintenance'] | |
| }); | |
| } |