screenshots.yml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. name: Visual Regression Tests
  2. on:
  3. pull_request_target:
  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. pull-requests: write
  13. jobs:
  14. selenium-screenshots:
  15. if: contains(join(github.event.pull_request.labels.*.name, '|'), 'screenshots')
  16. runs-on: ubuntu-latest
  17. name: Screenshots
  18. steps:
  19. - name: Checkout
  20. uses: actions/checkout@v4
  21. - name: Set up Python
  22. uses: actions/setup-python@v4
  23. with:
  24. python-version: '3.11'
  25. cache: 'pip'
  26. cache-dependency-path: 'tests/requirements/py3.txt'
  27. - name: Install and upgrade packaging tools
  28. run: python -m pip install --upgrade pip setuptools wheel
  29. - run: python -m pip install -r tests/requirements/py3.txt -e .
  30. - name: Run Selenium tests with screenshots
  31. id: generate-screenshots
  32. working-directory: ./tests/
  33. run: |
  34. python -Wall runtests.py --verbosity 2 --noinput --selenium=chrome --headless --screenshots --settings=test_sqlite --parallel 2
  35. echo "date=$(date)" >> $GITHUB_OUTPUT
  36. echo "🖼️ **Screenshots created**" >> $GITHUB_STEP_SUMMARY
  37. echo "Generated screenshots for ${{ github.event.pull_request.head.sha }} at $(date)" >> $GITHUB_STEP_SUMMARY
  38. - name: Upload screenshots
  39. uses: actions/upload-artifact@v3
  40. with:
  41. name: screenshots-${{ github.event.pull_request.head.sha }}
  42. path: tests/screenshots/
  43. - name: Find comment to update
  44. uses: peter-evans/find-comment@v2
  45. id: find-comment
  46. with:
  47. issue-number: ${{ github.event.pull_request.number }}
  48. comment-author: 'github-actions[bot]'
  49. body-includes: You can download the generated screenshots from the workflow artifacts.
  50. - name: Create comment
  51. if: steps.find-comment.outputs.comment-id == ''
  52. uses: peter-evans/create-or-update-comment@v3
  53. with:
  54. token: ${{ secrets.GITHUB_TOKEN }}
  55. issue-number: ${{ github.event.pull_request.number }}
  56. body: |
  57. 🖼️ **Screenshots created**
  58. You can download the generated screenshots from the workflow artifacts.
  59. _Please note that artifacts are only available for download for ${{ github.retention_days }} days._
  60. - Generated screenshots for ${{ github.event.pull_request.head.sha }} at ${{ steps.generate-screenshots.outputs.date }} ([download](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})).
  61. - name: Update comment
  62. if: steps.find-comment.outputs.comment-id != ''
  63. uses: peter-evans/create-or-update-comment@v3
  64. with:
  65. token: ${{ secrets.GITHUB_TOKEN }}
  66. comment-id: ${{ steps.find-comment.outputs.comment-id }}
  67. body: |
  68. - Generated screenshots for ${{ github.event.pull_request.head.sha }} at ${{ steps.generate-screenshots.outputs.date }} ([download](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})).