mirror of
https://github.com/konpa/devicon.git
synced 2025-08-17 20:01:38 +02:00
Build bot now check both PR and devicon.json
This commit is contained in:
50
.github/scripts/icomoon_build.py
vendored
50
.github/scripts/icomoon_build.py
vendored
@@ -20,31 +20,31 @@ def main():
|
||||
runner = None
|
||||
try:
|
||||
args = arg_getters.get_selenium_runner_args()
|
||||
new_icons = get_icons_for_building(args.devicon_json_path, args.token)
|
||||
new_icons = get_icons_for_building(args.icomoon_json_path, args.devicon_json_path, args.token)
|
||||
if len(new_icons) == 0:
|
||||
sys.exit("No files need to be uploaded. Ending script...")
|
||||
|
||||
print(f"There are {len(new_icons)} icons to be build. Here are they:", *new_icons, sep = "\n")
|
||||
|
||||
print("Begin optimizing files")
|
||||
optimize_svgs(new_icons, args.icons_folder_path)
|
||||
# print("Begin optimizing files")
|
||||
# optimize_svgs(new_icons, args.icons_folder_path)
|
||||
|
||||
print("Updating the icomoon json")
|
||||
update_icomoon_json(new_icons, args.icomoon_json_path)
|
||||
# print("Updating the icomoon json")
|
||||
# update_icomoon_json(new_icons, args.icomoon_json_path)
|
||||
|
||||
icon_svgs = filehandler.get_svgs_paths(
|
||||
new_icons, args.icons_folder_path, icon_versions_only=True)
|
||||
runner = SeleniumRunner(args.download_path,
|
||||
args.geckodriver_path, args.headless)
|
||||
runner.upload_icomoon(args.icomoon_json_path)
|
||||
runner.upload_svgs(icon_svgs)
|
||||
# icon_svgs = filehandler.get_svgs_paths(
|
||||
# new_icons, args.icons_folder_path, icon_versions_only=True)
|
||||
# runner = SeleniumRunner(args.download_path,
|
||||
# args.geckodriver_path, args.headless)
|
||||
# runner.upload_icomoon(args.icomoon_json_path)
|
||||
# runner.upload_svgs(icon_svgs)
|
||||
|
||||
zip_name = "devicon-v1.0.zip"
|
||||
zip_path = Path(args.download_path, zip_name)
|
||||
runner.download_icomoon_fonts(zip_path)
|
||||
filehandler.extract_files(str(zip_path), args.download_path)
|
||||
filehandler.rename_extracted_files(args.download_path)
|
||||
print("Task completed.")
|
||||
# zip_name = "devicon-v1.0.zip"
|
||||
# zip_path = Path(args.download_path, zip_name)
|
||||
# runner.download_icomoon_fonts(zip_path)
|
||||
# filehandler.extract_files(str(zip_path), args.download_path)
|
||||
# filehandler.rename_extracted_files(args.download_path)
|
||||
# print("Task completed.")
|
||||
except TimeoutException as e:
|
||||
util.exit_with_err("Selenium Time Out Error: \n" + str(e))
|
||||
except Exception as e:
|
||||
@@ -54,21 +54,31 @@ def main():
|
||||
runner.close()
|
||||
|
||||
|
||||
def get_icons_for_building(devicon_json_path: str, token: str):
|
||||
def get_icons_for_building(icomoon_json_path: str, devicon_json_path: str, token: str):
|
||||
"""
|
||||
Get the icons for building.
|
||||
:param icomoon_json_path - the path to the `icomoon.json`.
|
||||
:param devicon_json_path - the path to the `devicon.json`.
|
||||
:param token - the token to access the GitHub API.
|
||||
"""
|
||||
all_icons = filehandler.get_json_file_content(devicon_json_path)
|
||||
devicon_json = filehandler.get_json_file_content(devicon_json_path)
|
||||
pull_reqs = api_handler.get_merged_pull_reqs_since_last_release(token)
|
||||
new_icons = []
|
||||
|
||||
for pull_req in pull_reqs:
|
||||
if api_handler.is_feature_icon(pull_req):
|
||||
filtered_icon = util.find_object_added_in_this_pr(all_icons, pull_req["title"])
|
||||
filtered_icon = util.find_object_added_in_pr(devicon_json, pull_req["title"])
|
||||
if filtered_icon not in new_icons:
|
||||
new_icons.append(filtered_icon)
|
||||
|
||||
# get any icons that might not have been found by the API
|
||||
new_icons_from_devicon_json = filehandler.find_new_icons_in_devicon_json(
|
||||
devicon_json_path, icomoon_json_path)
|
||||
|
||||
for icon in new_icons_from_devicon_json:
|
||||
if icon not in new_icons:
|
||||
new_icons.append(icon)
|
||||
|
||||
return new_icons
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user