Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
787def9
Add check for strokes in check-bot
Thomas-Boi Dec 12, 2021
c959b04
Add check for svg file name
Thomas-Boi Dec 12, 2021
5e357c9
Update gulpfile to remove x and y of svg elem
Thomas-Boi Dec 16, 2021
6932e20
Revert name changes to err file
Thomas-Boi Dec 18, 2021
afd0197
Merge branch 'develop' into thomas/feature/checkBotUpgrade
Thomas-Boi Dec 18, 2021
886dcf9
Working on labeler
Thomas-Boi Dec 25, 2021
3e35603
Add in_develop_labeler
Thomas-Boi Dec 25, 2021
74320bd
Build bot can close issues based on labels
Thomas-Boi Dec 25, 2021
857b1b8
Test mode for build
Thomas-Boi Dec 25, 2021
c618c05
Merge pull request #77 from devicons/thomas/feature/inDevelopLabeler
Thomas-Boi Dec 25, 2021
81495ee
Add test.txt
Thomas-Boi Dec 25, 2021
b73c13c
Merge pull request #80 from Thomas-Boi/dummy
Thomas-Boi Dec 25, 2021
313ee67
Update in_develop_labeler.ylm
Thomas-Boi Dec 26, 2021
b6ef6af
Merge pull request #81 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
0a04da5
Fixed str error in yml file
Thomas-Boi Dec 26, 2021
acd84b7
Merge pull request #82 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
880d7f5
Add test log
Thomas-Boi Dec 26, 2021
d03a761
Merge pull request #83 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
2ab8ffd
Add more logging
Thomas-Boi Dec 26, 2021
1c3389a
Merge pull request #85 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
cc46f76
Update yml
Thomas-Boi Dec 26, 2021
1851df4
Merge pull request #86 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
2350976
Update yml
Thomas-Boi Dec 26, 2021
cbcdff3
update
Thomas-Boi Dec 26, 2021
d4dd141
update
Thomas-Boi Dec 26, 2021
2a09eb2
update
Thomas-Boi Dec 26, 2021
6156755
update
Thomas-Boi Dec 26, 2021
74f0008
update
Thomas-Boi Dec 26, 2021
66fdac7
update
Thomas-Boi Dec 26, 2021
9591313
update
Thomas-Boi Dec 26, 2021
99f3118
update
Thomas-Boi Dec 26, 2021
32ad7d0
Merge pull request #87 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
c2e28cc
update
Thomas-Boi Dec 26, 2021
acd7c0e
Merge pull request #88 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
04ed9b0
update
Thomas-Boi Dec 26, 2021
401a48e
Merge pull request #89 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
2202d9b
update
Thomas-Boi Dec 26, 2021
138c7d4
Merge pull request #90 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
349feb2
update
Thomas-Boi Dec 26, 2021
3dc7700
Merge pull request #91 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
6d5347a
update
Thomas-Boi Dec 26, 2021
3927518
Merge pull request #92 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
ffce811
update
Thomas-Boi Dec 26, 2021
7c31495
Merge pull request #93 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
85747b6
update
Thomas-Boi Dec 26, 2021
f975a77
update
Thomas-Boi Dec 26, 2021
3a7da12
update
Thomas-Boi Dec 26, 2021
99e43d1
update
Thomas-Boi Dec 26, 2021
9348607
update
Thomas-Boi Dec 26, 2021
91cd11a
update
Thomas-Boi Dec 26, 2021
43e11c9
update
Thomas-Boi Dec 26, 2021
7a3b816
update
Thomas-Boi Dec 26, 2021
dd909a8
update
Thomas-Boi Dec 26, 2021
703993b
update
Thomas-Boi Dec 26, 2021
58869d2
update
Thomas-Boi Dec 26, 2021
c80f74c
Merge pull request #94 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
8819cdf
Fixed build_icons.yml
Thomas-Boi Dec 26, 2021
41acdf9
Merge pull request #95 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
851ae2a
update
Thomas-Boi Dec 26, 2021
0c97e5e
Merge pull request #96 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
61b5739
update
Thomas-Boi Dec 26, 2021
1171296
Merge pull request #97 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
46b786b
update
Thomas-Boi Dec 26, 2021
3ba0959
Merge pull request #98 from Thomas-Boi/dummy
Thomas-Boi Dec 26, 2021
6b39426
update
Thomas-Boi Dec 26, 2021
a66329d
Merge branch 'dummy' into develop
Thomas-Boi Dec 26, 2021
c6ed4b0
Merge branch 'develop' into thomas/feature/checkBotUpgrade
Thomas-Boi Dec 26, 2021
0c44d7f
check-bot now check devicon object as well
Thomas-Boi Dec 26, 2021
ebc871b
Fixed minor bugs
Thomas-Boi Dec 27, 2021
c891979
Merge branch 'thomas/feature/checkBotUpgrade' of https://github.com/d…
Thomas-Boi Dec 27, 2021
41b2569
Merge pull request #99 from devicons/thomas/feature/checkBotUpgrade
Thomas-Boi Dec 27, 2021
6a07985
Update
Thomas-Boi Dec 27, 2021
fbecbb7
Update
Thomas-Boi Dec 27, 2021
bec2bc1
change logging format
Thomas-Boi Dec 27, 2021
a79f759
improve logging
Thomas-Boi Dec 27, 2021
55ff366
add post_check_icon_pr back
Thomas-Boi Dec 27, 2021
59fff68
fixed exception printing bug
Thomas-Boi Dec 27, 2021
cea8c05
check svgs is none
Thomas-Boi Dec 27, 2021
a078a58
rename err file
Thomas-Boi Dec 27, 2021
ac5f981
update post workflow
Thomas-Boi Dec 27, 2021
6efec79
Added testing files
Thomas-Boi May 17, 2021
a629db7
missing aliases
Thomas-Boi Dec 27, 2021
e1abaec
invalid version in devicon json and filename
Thomas-Boi Dec 27, 2021
86fcb30
improve logging
Thomas-Boi Dec 27, 2021
226f075
Added testing files
Thomas-Boi May 17, 2021
7eaae46
missing aliases
Thomas-Boi Dec 27, 2021
f8ffc89
invalid version in devicon json and filename
Thomas-Boi Dec 27, 2021
b96509a
Added better logging
Thomas-Boi Dec 27, 2021
55c5c6a
Merge branch 'testing' of https://github.com/Thomas-Boi/devicon into …
Thomas-Boi Dec 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 85 additions & 2 deletions .github/scripts/build_assets/api_handler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import requests
import sys
import re
from typing import List


# our base url which leads to devicon
# base_url = "https://api.github.com/repos/devicons/devicon/"
# testing url
base_url = "https://api.github.com/repos/Thomas-Boi/devicon/"

def get_merged_pull_reqs_since_last_release(token):
"""
Get all the merged pull requests since the last release.
Expand Down Expand Up @@ -38,7 +44,7 @@ def get_merged_pull_reqs(token, page):
:param token, a GitHub API token.
:param page, the page number.
"""
queryPath = "https://api.github.com/repos/devicons/devicon/pulls"
url = base_url + "pulls"
headers = {
"Authorization": f"token {token}"
}
Expand All @@ -50,7 +56,7 @@ def get_merged_pull_reqs(token, page):
}

print(f"Querying the GitHub API for requests page #{page}")
response = requests.get(queryPath, headers=headers, params=params)
response = requests.get(url, headers=headers, params=params)
if not response:
print(f"Can't query the GitHub API. Status code is {response.status_code}. Message is {response.text}")
sys.exit(1)
Expand Down Expand Up @@ -99,3 +105,80 @@ def find_all_authors(pull_req_data, token):
authors.add(commit["commit"]["author"]["name"])
print(f"This URL didn't have an `author` attribute: {pull_req_data['commits_url']}")
return ", ".join(["@" + author for author in list(authors)])


def label_issues(token: str, repo: str, issues: List[str], labels: List[str]):
"""
Label the issues specified with the label specified.
:param token: the GitHub API token.
:param issues: the issue numbers (as str) that we are labelling.
:param labels: the labels that we are labelling.
"""
headers = {
"Authorization": f"token {token}",
"accept": "application/vnd.github.v3+json"
}
url = base_url + "issues/{}/labels"
for issue in issues:
body = {
"labels": labels
}
response = requests.post(url.format(repo, issue), headers=headers, json=body)
if not response:
raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}, API response: " + response.text)
else:
print(f"Successfully labelled issue {issue}")


def close_issues(token: str, issues: List[str]):
"""
Close issues.
:param token: the GitHub API token.
:param issues: the issue numbers (as str) that we are labelling.
"""
headers = {
"Authorization": f"token {token}",
"accept": "application/vnd.github.v3+json"
}
url = base_url + "issues/{}"
body = {
"state": "closed"
}
for issue in issues:
response = requests.patch(url.format(issue), headers=headers, json=body)
if not response:
raise Exception(f"Can't close Issue provided. Issue: {issue}, API response: " + response.text)
else:
print(f"Successfully closed issue {issue}")


def get_issues_by_labels(token: str, labels: List[str]):
"""
Get a list of issues based on their labels.
:param token: the GitHub API token.
:param labels: the labels that we are labelling.
"""
url = base_url + "issues?per_page=100&labels={}&page={}"
headers = {
"Authorization": f"token {token}",
"accept": "application/vnd.github.v3+json"
}
issues = []
done = False
page_num = 1
while not done:
response = requests.get(url.format(",".join(labels), page_num), headers=headers)
if not response:
raise Exception(f"Can't access API. Can't get issues for labels: {labels}, API response: " + response.text)
else:
results = response.json()
if len(results) < 100:
done = True # we are done
else:
page_num += 1 # page is full => might need to check another page

# GitHub API also returns PRs for issues queries => have to check
issues_only = [issue for issue in results if issue.get("pull_request") is None]
issues.extend(issues_only)

return issues
40 changes: 31 additions & 9 deletions .github/scripts/build_assets/arg_getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,32 @@ def get_selenium_runner_args(peek_mode=False):
action=PathResolverAction)

if peek_mode:
parser.add_argument("--pr_title",
parser.add_argument("pr_title",
help="The title of the PR that we are peeking at")
else:
parser.add_argument("token",
help="The GitHub token to access the GitHub REST API.",
type=str)
help="The GitHub token to access the GitHub REST API.")

return parser.parse_args()


def get_check_svgs_on_pr_args():
def get_check_icon_pr_args():
"""
Get the commandline arguments for the check_svgs_on_pr.py.
Get the commandline arguments for the check_icon_pr.py.
"""
parser = ArgumentParser(description="Check the SVGs to ensure their attributes are correct. Run whenever a PR is opened")
parser.add_argument("files_added_json_path",
help="The path to the files_added.json created by the gh-action-get-changed-files@2.1.4",

parser.add_argument("pr_title",
help="The title of the PR that we are peeking at")

parser.add_argument("icons_folder_path",
help="The path to the icons folder",
action=PathResolverAction)

parser.add_argument("files_modified_json_path",
help="The path to the files_modified.json created by the gh-action-get-changed-files@2.1.4",
parser.add_argument("devicon_json_path",
help="The path to the devicon.json",
action=PathResolverAction)

return parser.parse_args()


Expand All @@ -64,7 +68,25 @@ def get_release_message_args():
Get the commandline arguments for get_release_message.py.
"""
parser = ArgumentParser(description="Create a text containing the icons and features added since last release.")
parser.add_argument("token",
help="The GitHub token to access the GitHub REST API.")
return parser.parse_args()


def get_in_develop_labeler_args():
"""
Get the commandline arguments for in_develop_labeler.py.
"""
parser = ArgumentParser(description="Parse the PR body to find the issue(s) we are labelling.")
parser.add_argument("token",
help="The GitHub token to access the GitHub REST API.",
type=str)

parser.add_argument("body",
help="The PR's initial comment by the author AKA the `body` attribute of the `pull_request` API object.",
type=str)

parser.add_argument("repo",
help="The owner and repo name. Ex: devicons/devicon",
type=str)
return parser.parse_args()
21 changes: 11 additions & 10 deletions .github/scripts/build_assets/filehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_svgs_paths(new_icons: List[dict], icons_folder_path: str,
folder_path = Path(icons_folder_path, icon_info['name'])

if not folder_path.is_dir():
raise ValueError(f"Invalid path. This is not a directory: {folder_path}.")
raise ValueError(f"Invalid path. This is not a directory: '{folder_path}'.")

if icon_versions_only:
get_icon_svgs_paths(folder_path, icon_info, file_paths, as_str)
Expand Down Expand Up @@ -100,7 +100,7 @@ def get_icon_svgs_paths(folder_path: Path, icon_info: dict,
if path.exists():
file_paths.append(str(path) if as_str else path)
else:
raise ValueError(f"This path doesn't exist: {path}")
raise ValueError(f"This path doesn't exist: '{path}'")


def get_all_svgs_paths(folder_path: Path, icon_info: dict,
Expand All @@ -119,7 +119,7 @@ def get_all_svgs_paths(folder_path: Path, icon_info: dict,
if path.exists():
file_paths.append(str(path) if as_str else path)
else:
raise ValueError(f"This path doesn't exist: {path}")
raise ValueError(f"This path doesn't exist: '{path}'")


def is_alias(font_version: str, aliases: List[dict]):
Expand Down Expand Up @@ -207,6 +207,14 @@ def create_screenshot_folder(dir, screenshot_name: str="screenshots/"):
finally:
return str(screenshot_folder)

def write_to_file(path: str, value: any):
"""
Write the value to a file.
"""
with open(path, "w") as file:
file.write(value)

# --- NOT USED CURRENTLY ---
def get_added_modified_svgs(files_added_json_path: str,
files_modified_json_path: str):
"""
Expand All @@ -231,10 +239,3 @@ def get_added_modified_svgs(files_added_json_path: str,

return svgs


def write_to_file(path: str, value: any):
"""
Write the value to a file.
"""
with open(path, "w") as file:
file.write(value)
22 changes: 22 additions & 0 deletions .github/scripts/build_assets/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import sys
import traceback

# patterns for versions
valid_versions = "(original|plain|line)(-wordmark)?"
valid_versions_pattern = re.compile(f"^{valid_versions}$")
valid_svg_filename_pattern = re.compile(r"^\w+-" + valid_versions + r"\.svg$")


def exit_with_err(err: Exception):
"""
Expand Down Expand Up @@ -66,3 +71,20 @@ def find_object_added_in_pr(icons: List[dict], pr_title: str):
message = "util.find_object_added_in_pr: Couldn't find an icon matching the name in the PR title.\n" \
f"PR title is: '{pr_title}'"
raise Exception(message)


def is_version_name_valid(version: str):
"""
Check whether the version name is valid.
:param version: the version name.
:return bool, whether the version is valid (match our standards)
"""
return valid_versions_pattern.search(version) is not None

def is_svg_name_valid(filename: str):
"""
Check whether the svg filename is valid.
:param version: the version name.
:return bool, whether the version is valid (match our standards)
"""
return valid_svg_filename_pattern.search(filename) is not None
Loading