fix: use localStorage for theme switching in visual tests #56
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: UI Tests | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| timeout-minutes: 60 | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Skip installing package docs to avoid wasting time | |
| # See: https://github.com/actions/runner-images/issues/10977#issuecomment-2810713336 | |
| - name: Skip installing package docs | |
| run: | | |
| sudo tee /etc/dpkg/dpkg.cfg.d/01_nodoc > /dev/null << 'EOF' | |
| path-exclude /usr/share/doc/* | |
| path-exclude /usr/share/man/* | |
| path-exclude /usr/share/info/* | |
| EOF | |
| - uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Playwright Browsers | |
| run: npx playwright install --with-deps chromium webkit | |
| - name: Setup Zola | |
| uses: taiki-e/install-action@zola | |
| - name: Run Playwright tests | |
| run: npm run test | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| retention-days: 30 | |
| - name: Upload screenshots | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: test-screenshots | |
| path: test-results/ | |
| retention-days: 30 | |
| - name: Deploy report to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| if: failure() && github.event_name == 'pull_request' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./playwright-report | |
| destination_dir: pr-${{ github.event.pull_request.number }} | |
| keep_files: true | |
| - name: Find existing PR comment | |
| uses: peter-evans/find-comment@v3 | |
| if: always() && github.event_name == 'pull_request' | |
| id: find-comment | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: 'Visual Regression Tests' | |
| - name: Comment test failure on PR | |
| uses: peter-evans/create-or-update-comment@v5 | |
| if: failure() && github.event_name == 'pull_request' | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| edit-mode: replace | |
| body: | | |
| ## Playwright Tests failed! | |
| [View report](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}) | |
| - name: Comment test success on PR | |
| uses: peter-evans/create-or-update-comment@v5 | |
| if: success() && github.event_name == 'pull_request' | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| edit-mode: replace | |
| body: | | |
| ## Playwright Tests passed! | |
| All visual regression tests passed successfully! |