1
0
mirror of https://github.com/konpa/devicon.git synced 2025-08-11 17:14:27 +02:00

New Feature: Upgrade Peekbot (#966)

* Moved stroke detection down

* Add code to retry no connection in peekbot

* Change upload artifact to earlier version

* Clean up logging msg

* Add ability to customize port number

* Update Selenium and geckodriver

* Move upload-artifact version to 2.2.4

* Add logging for webdriver retry

* Add color checking to peek-bot
This commit is contained in:
Thomas Bui
2021-12-21 12:33:41 -08:00
committed by GitHub
parent 34a54bcf1a
commit 2a8c499605
9 changed files with 112 additions and 26 deletions

View File

@@ -5,17 +5,18 @@ from build_assets.selenium_runner.SeleniumRunner import SeleniumRunner
from build_assets.selenium_runner.enums import IcomoonPage, IcomoonAlerts
class PeekSeleniumRunner(SeleniumRunner):
def peek(self, svgs: List[str], screenshot_folder: str):
def peek(self, svgs: List[str], screenshot_folder: str, icon_info: dict):
"""
Upload the SVGs and peek at how Icomoon interpret its SVGs and
font versions.
:param svgs: a list of svg Paths that we'll upload to icomoon.
:param screenshot_folder: the name of the screenshot_folder.
:param icon_info: a dictionary containing info on an icon. Taken from the devicon.json.
:return an array of svgs with strokes as strings. These show which icon
contains stroke.
"""
messages = self.peek_svgs(svgs, screenshot_folder)
self.peek_icons(svgs, screenshot_folder)
self.peek_icons(screenshot_folder, icon_info)
return messages
def peek_svgs(self, svgs: List[str], screenshot_folder: str):
@@ -61,10 +62,11 @@ class PeekSeleniumRunner(SeleniumRunner):
print("Finished peeking the svgs...")
return svgs_with_strokes
def peek_icons(self, svgs: List[str], screenshot_folder: str):
def peek_icons(self, screenshot_folder: str, icon_info: dict):
"""
Peek at the icon versions of the SVGs that were uploaded.
:param screenshot_folder: the name of the screenshot_folder.
:param icon_info: a dictionary containing info on an icon. Taken from the devicon.json.
"""
print("Begin peeking at the icons...")
# ensure all icons in the set is selected.
@@ -85,7 +87,7 @@ class PeekSeleniumRunner(SeleniumRunner):
main_content = self.driver.find_element_by_xpath(main_content_xpath)
main_content.screenshot(new_icons_path);
# go downward so we get the oldest icon first
# go in reverse order so we get the oldest icon first
icon_divs_xpath = f'//div[@id="glyphSet0"]/div'
icon_divs = self.driver.find_elements_by_xpath(icon_divs_xpath)
icon_divs.reverse()
@@ -98,6 +100,23 @@ class PeekSeleniumRunner(SeleniumRunner):
Path(screenshot_folder, f"new_icon_{i}.png").resolve()
)
icon_div.screenshot(icon_screenshot)
i += 1
# test the colors
style = "#glyphSet0 span:first-of-type {color: " + icon_info["color"] + "}"
script = f"document.styleSheets[0].insertRule('{style}', 0)"
self.driver.execute_script(script)
i = 0
for icon_div in icon_divs:
if not icon_div.is_displayed():
continue
icon_screenshot = str(
Path(screenshot_folder, f"new_colored_icon_{i}.png").resolve()
)
icon_div.screenshot(icon_screenshot)
i += 1
print("Finished peeking the icons...")