2
0

screenshots.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. name: Visual Regression Tests
  2. on:
  3. pull_request:
  4. types: [labeled, synchronize, opened, reopened]
  5. paths-ignore:
  6. - 'docs/**'
  7. concurrency:
  8. group: ${{ github.workflow }}-${{ github.ref }}
  9. cancel-in-progress: true
  10. permissions:
  11. contents: read
  12. jobs:
  13. selenium-screenshots:
  14. if: contains(join(github.event.pull_request.labels.*.name, '|'), 'screenshots')
  15. runs-on: ubuntu-latest
  16. name: Screenshots
  17. steps:
  18. - name: Checkout
  19. uses: actions/checkout@v4
  20. - name: Set up Python
  21. uses: actions/setup-python@v5
  22. with:
  23. python-version: '3.11'
  24. cache: 'pip'
  25. cache-dependency-path: 'tests/requirements/py3.txt'
  26. - name: Install and upgrade packaging tools
  27. run: python -m pip install --upgrade pip setuptools wheel
  28. - run: python -m pip install -r tests/requirements/py3.txt -e .
  29. - name: Run Selenium tests with screenshots
  30. working-directory: ./tests/
  31. run: python -Wall runtests.py --verbosity=2 --noinput --selenium=chrome --headless --screenshots --settings=test_sqlite --parallel=2
  32. - name: Cache oxipng
  33. uses: actions/cache@v4
  34. with:
  35. path: ~/.cargo/
  36. key: ${{ runner.os }}-cargo
  37. - name: Install oxipng
  38. run: which oxipng || cargo install oxipng
  39. - name: Optimize screenshots
  40. run: oxipng --interlace=0 --opt=4 --strip=safe tests/screenshots/*.png
  41. - name: Organize screenshots
  42. run: |
  43. mkdir --parents "/tmp/screenshots/${{ github.event.pull_request.head.sha }}"
  44. mv tests/screenshots/* "/tmp/screenshots/${{ github.event.pull_request.head.sha }}/"
  45. - name: Upload screenshots
  46. uses: actions/upload-artifact@v4
  47. with:
  48. name: screenshots-${{ github.event.pull_request.head.sha }}
  49. path: /tmp/screenshots/
  50. if-no-files-found: error