mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Organized images in the screenshots workflow.
Added a top-level directory in the zip archive that is the commit hash which makes it easier when downloading multiple artifacts for comparison. Updated the filenames of screenshots for easier comparison between different cases. Added that an error is raised if no screenshots uploaded in workflow.
This commit is contained in:
parent
02c2090dc0
commit
962215db13
8
.github/workflows/screenshots.yml
vendored
8
.github/workflows/screenshots.yml
vendored
@ -47,8 +47,14 @@ jobs:
|
|||||||
- name: Optimize screenshots
|
- name: Optimize screenshots
|
||||||
run: oxipng --interlace=0 --opt=4 --strip=safe tests/screenshots/*.png
|
run: oxipng --interlace=0 --opt=4 --strip=safe tests/screenshots/*.png
|
||||||
|
|
||||||
|
- name: Organize screenshots
|
||||||
|
run: |
|
||||||
|
mkdir --parents "/tmp/screenshots/${{ github.event.pull_request.head.sha }}"
|
||||||
|
mv tests/screenshots/* "/tmp/screenshots/${{ github.event.pull_request.head.sha }}/"
|
||||||
|
|
||||||
- name: Upload screenshots
|
- name: Upload screenshots
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: screenshots-${{ github.event.pull_request.head.sha }}
|
name: screenshots-${{ github.event.pull_request.head.sha }}
|
||||||
path: tests/screenshots/
|
path: /tmp/screenshots/
|
||||||
|
if-no-files-found: error
|
||||||
|
@ -142,6 +142,8 @@ class SeleniumTestCase(LiveServerTestCase, metaclass=SeleniumTestCaseBase):
|
|||||||
|
|
||||||
test.__name__ = f"{name}_{screenshot_case}"
|
test.__name__ = f"{name}_{screenshot_case}"
|
||||||
test.__qualname__ = f"{test.__qualname__}_{screenshot_case}"
|
test.__qualname__ = f"{test.__qualname__}_{screenshot_case}"
|
||||||
|
test._screenshot_name = name
|
||||||
|
test._screenshot_case = screenshot_case
|
||||||
setattr(cls, test.__name__, test)
|
setattr(cls, test.__name__, test)
|
||||||
|
|
||||||
@classproperty
|
@classproperty
|
||||||
@ -214,7 +216,9 @@ class SeleniumTestCase(LiveServerTestCase, metaclass=SeleniumTestCaseBase):
|
|||||||
def take_screenshot(self, name):
|
def take_screenshot(self, name):
|
||||||
if not self.screenshots:
|
if not self.screenshots:
|
||||||
return
|
return
|
||||||
path = Path.cwd() / "screenshots" / f"{self._testMethodName}-{name}.png"
|
test = getattr(self, self._testMethodName)
|
||||||
|
filename = f"{test._screenshot_name}--{name}--{test._screenshot_case}.png"
|
||||||
|
path = Path.cwd() / "screenshots" / filename
|
||||||
path.parent.mkdir(exist_ok=True, parents=True)
|
path.parent.mkdir(exist_ok=True, parents=True)
|
||||||
self.selenium.save_screenshot(path)
|
self.selenium.save_screenshot(path)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user