Skip to content

Commit b334e83

Browse files
sarahboycefelixxm
authored andcommitted
Refs #34043 -- Added GitHub action to capture screenshots in Selenium tests.
1 parent be56c98 commit b334e83

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/screenshots.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Visual Regression Tests
2+
3+
on:
4+
pull_request:
5+
types: [labeled, synchronize, opened, reopened]
6+
paths-ignore:
7+
- 'docs/**'
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
17+
jobs:
18+
selenium-screenshots:
19+
if: contains(join(github.event.pull_request.labels.*.name, '|'), 'screenshots')
20+
runs-on: ubuntu-latest
21+
name: Screenshots
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: '3.11'
29+
cache: 'pip'
30+
cache-dependency-path: 'tests/requirements/py3.txt'
31+
- name: Install and upgrade packaging tools
32+
run: python -m pip install --upgrade pip setuptools wheel
33+
- run: python -m pip install -r tests/requirements/py3.txt -e .
34+
- name: Run Selenium tests with screenshots
35+
id: generate-screenshots
36+
working-directory: ./tests/
37+
run: |
38+
python -Wall runtests.py --verbosity 2 --noinput --selenium=chrome --headless --screenshots --settings=test_sqlite --parallel 2
39+
echo "date=$(date)" >> $GITHUB_OUTPUT
40+
echo "🖼️ **Screenshots created**" >> $GITHUB_STEP_SUMMARY
41+
echo "Generated screenshots for ${{ github.event.pull_request.head.sha }} at $(date)" >> $GITHUB_STEP_SUMMARY
42+
43+
- name: Upload screenshots
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: screenshots-${{ github.event.pull_request.head.sha }}
47+
path: tests/screenshots/
48+
49+
- name: Find comment to update
50+
uses: peter-evans/find-comment@v2
51+
id: find-comment
52+
with:
53+
issue-number: ${{ github.event.pull_request.number }}
54+
comment-author: 'github-actions[bot]'
55+
body-includes: You can download the generated screenshots from the workflow artifacts.
56+
57+
- name: Create comment
58+
if: steps.find-comment.outputs.comment-id == ''
59+
uses: peter-evans/create-or-update-comment@v3
60+
with:
61+
issue-number: ${{ github.event.pull_request.number }}
62+
body: |
63+
🖼️ **Screenshots created**
64+
65+
You can download the generated screenshots from the workflow artifacts.
66+
67+
_Please note that artifacts are only available for download for ${{ github.retention_days }} days._
68+
69+
- 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 }}))
70+
71+
- name: Update comment
72+
if: steps.find-comment.outputs.comment-id != ''
73+
uses: peter-evans/create-or-update-comment@v3
74+
with:
75+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
76+
body: |
77+
- 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 }}))

0 commit comments

Comments
 (0)