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

Update the check-bot (#970)

* Add check for strokes in check-bot

* Add check for svg file name

* Update gulpfile to remove x and y of svg elem

* Revert name changes to err file

* check-bot now check devicon object as well

* Fixed minor bugs

* Improve logging in check_icon

Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
Thomas Bui
2022-03-13 15:02:41 -07:00
committed by GitHub
parent 5153e0f0da
commit bb589370da
9 changed files with 221 additions and 194 deletions

View File

@@ -1,6 +1,5 @@
from build_assets.selenium_runner.PeekSeleniumRunner import PeekSeleniumRunner
from build_assets import filehandler, arg_getters
from build_assets import util
from build_assets import filehandler, arg_getters, util
def main():
@@ -11,12 +10,10 @@ def main():
# get only the icon object that has the name matching the pr title
filtered_icon = util.find_object_added_in_pr(all_icons, args.pr_title)
check_devicon_object(filtered_icon)
print("Icon being checked:", filtered_icon, sep = "\n", end='\n\n')
runner = PeekSeleniumRunner(args.download_path, args.geckodriver_path, args.headless)
svgs = filehandler.get_svgs_paths([filtered_icon], args.icons_folder_path, True)
screenshot_folder = filehandler.create_screenshot_folder("./")
runner = PeekSeleniumRunner(args.download_path, args.geckodriver_path, args.headless)
svgs_with_strokes = runner.peek(svgs, screenshot_folder, filtered_icon)
print("Task completed.")
@@ -33,57 +30,5 @@ def main():
runner.close()
def check_devicon_object(icon: dict):
"""
Check that the devicon object added is up to standard.
:param icon: a dictionary containing info on an icon. Taken from the devicon.json.
:return a string containing the error messages if any.
"""
err_msgs = []
try:
for tag in icon["tags"]:
if type(tag) != str:
raise TypeError()
except TypeError:
err_msgs.append("- 'tags' must be an array of strings, not: " + str(icon["tags"]))
except KeyError:
err_msgs.append("- missing key: 'tags'.")
try:
if type(icon["versions"]) != dict:
err_msgs.append("- 'versions' must be an object.")
except KeyError:
err_msgs.append("- missing key: 'versions'.")
try:
if type(icon["versions"]["svg"]) != list or len(icon["versions"]["svg"]) == 0:
err_msgs.append("- must contain at least 1 svg version in a list.")
except KeyError:
err_msgs.append("- missing key: 'svg' in 'versions'.")
try:
if type(icon["versions"]["font"]) != list or len(icon["versions"]["svg"]) == 0:
err_msgs.append("- must contain at least 1 font version in a list.")
except KeyError:
err_msgs.append("- missing key: 'font' in 'versions'.")
try:
if type(icon["color"]) != str or "#" not in icon["color"]:
err_msgs.append("- 'color' must be a string in the format '#abcdef'")
except KeyError:
err_msgs.append("- missing key: 'color'.")
try:
if type(icon["aliases"]) != list:
err_msgs.append("- 'aliases' must be an array.")
except KeyError:
err_msgs.append("- missing key: 'aliases'.")
if len(err_msgs) > 0:
message = "Error found in 'devicon.json' for '{}' entry: \n{}".format(icon["name"], "\n".join(err_msgs))
raise ValueError(message)
return ""
if __name__ == "__main__":
main()