From 787def9816a765169f49b0f12810684662993481 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 11 Dec 2021 19:53:25 -0800 Subject: [PATCH 01/64] Add check for strokes in check-bot --- .github/scripts/check_svgs_on_pr.py | 10 +++++----- .github/workflows/check_svgs_on_pr.yml | 5 +++-- .github/workflows/post_check_svgs_comment.yml | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/scripts/check_svgs_on_pr.py b/.github/scripts/check_svgs_on_pr.py index d6a725654..35729b5da 100644 --- a/.github/scripts/check_svgs_on_pr.py +++ b/.github/scripts/check_svgs_on_pr.py @@ -69,11 +69,11 @@ def check_svgs(svg_file_paths: List[Path]): if root.get("viewBox") != "0 0 128 128": err_msg.append("-'viewBox' is not '0 0 128 128' -> Set it or scale the file using https://www.iloveimg.com/resize-image/resize-svg.") - if root.get("x") is not None: - err_msg.append("-unneccessary 'x' attribute in svg root element -> Remove it") - - if root.get("y") is not None: - err_msg.append("-unneccessary 'y' attribute in svg root element -> Remove it") + # goes through all elems and check for strokes + for child in tree.iter(): + if child.get("stroke") != None: + err_msg.append("-SVG contains `stroke` property. This will get ignored by Icomoon. Please convert them to fills.") + break if len(err_msg) > 1: err_msgs.append("\n".join(err_msg)) diff --git a/.github/workflows/check_svgs_on_pr.yml b/.github/workflows/check_svgs_on_pr.yml index 70dd42446..a20329adc 100644 --- a/.github/workflows/check_svgs_on_pr.yml +++ b/.github/workflows/check_svgs_on_pr.yml @@ -19,6 +19,7 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} + # this is where we create the check_err_messages - name: Run the check_svg script run: > python ./.github/scripts/check_svgs_on_pr.py $HOME/files_added.json $HOME/files_modified.json @@ -27,8 +28,8 @@ jobs: uses: actions/upload-artifact@v2 if: success() with: - name: svg_err_messages - path: ./svg_err_messages.txt + name: check_err_messages + path: ./check_err_messages.txt - name: Save the pr num in an artifact shell: bash diff --git a/.github/workflows/post_check_svgs_comment.yml b/.github/workflows/post_check_svgs_comment.yml index 5ac89d3aa..5f5133d63 100644 --- a/.github/workflows/post_check_svgs_comment.yml +++ b/.github/workflows/post_check_svgs_comment.yml @@ -33,7 +33,7 @@ jobs: id: err_message_reader uses: juliangruber/read-file-action@v1.0.0 with: - path: ./svg_err_messages/svg_err_messages.txt + path: ./check_err_messages/check_err_messages.txt - name: Comment on the PR about the result - SVG Error uses: jungwinter/comment@v1 # let us comment on a specific PR From c959b04cc56ef7d654fdae32109e0c2707a9a581 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 12 Dec 2021 11:58:53 -0800 Subject: [PATCH 02/64] Add check for svg file name --- .github/scripts/build_assets/util.py | 7 ++++++- .github/scripts/check_svgs_on_pr.py | 9 ++++++++- .github/workflows/post_check_svgs_comment.yml | 7 ++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/scripts/build_assets/util.py b/.github/scripts/build_assets/util.py index 9ecbc8075..2a11f8e11 100644 --- a/.github/scripts/build_assets/util.py +++ b/.github/scripts/build_assets/util.py @@ -5,7 +5,6 @@ import sys import traceback - def exit_with_err(err: Exception): """ Exit the current step and display the err. @@ -66,3 +65,9 @@ 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) + + +valid_filename_pattern = re.compile(r"-(original|plain|line)(-wordmark)?\.svg$") +def is_svg_name_valid(filename: str): + return valid_filename_pattern.search(filename) is not None + diff --git a/.github/scripts/check_svgs_on_pr.py b/.github/scripts/check_svgs_on_pr.py index 35729b5da..9815ad9ce 100644 --- a/.github/scripts/check_svgs_on_pr.py +++ b/.github/scripts/check_svgs_on_pr.py @@ -2,6 +2,7 @@ from typing import List import xml.etree.ElementTree as et from pathlib import Path +import build_assets.util # pycharm complains that build_assets is an unresolved ref @@ -58,10 +59,16 @@ def check_svgs(svg_file_paths: List[Path]): err_msgs = [] for svg_path in svg_file_paths: try: + err_msg = [f"{svg_path}:"] + + # name check + if not is_svg_name_valid(svg_path.absolute()): + err_msg.append("-SVG file name didn't match our pattern of `name-(original|plain|line)(-wordmark)?.svg`") + + # svg check tree = et.parse(svg_path) root = tree.getroot() namespace = "{http://www.w3.org/2000/svg}" - err_msg = [f"{svg_path}:"] if root.tag != f"{namespace}svg": err_msg.append(f"-root is '{root.tag}'. Root must be an 'svg' element") diff --git a/.github/workflows/post_check_svgs_comment.yml b/.github/workflows/post_check_svgs_comment.yml index 5f5133d63..bbe415543 100644 --- a/.github/workflows/post_check_svgs_comment.yml +++ b/.github/workflows/post_check_svgs_comment.yml @@ -42,21 +42,18 @@ jobs: MESSAGE: | Hi! - I'm Devicons' SVG-Checker Bot and it seems we have some issues with your SVGs. + I'm the SVG-Checker Bot and we have some issues with your SVGs: - Here is what went wrong: ``` {0} ``` - For more reference on why these are errors, check out our [CONTRIBUTING guide](https://github.com/devicons/devicon/blob/develop/CONTRIBUTING.md#svgStandards) + Check our [CONTRIBUTING guide](https://github.com/devicons/devicon/blob/develop/CONTRIBUTING.md#svgStandards) for more details regarding these errors. Please address these issues. When you update this PR, I will check your SVGs again. Thanks for your help, SVG-Checker Bot :smile: - - PS. One day, I will be smart enough to fix these errors for you :persevere:. Until then, I can only point them out. with: type: create issue_number: ${{ steps.pr_num_reader.outputs.content }} From 5e357c9dd64db00b73175a703aae746038596276 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Thu, 16 Dec 2021 12:25:08 -0800 Subject: [PATCH 03/64] Update gulpfile to remove x and y of svg elem --- gulpfile.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index 9a7c74344..f6cc2fae5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -187,6 +187,12 @@ function configOptionCallback(file) { }, { removeDimensions: true // remove height and width + }, + { + name: "removeAttrs", + params: { + attrs: "svg:(x|y)" + } } ] }; From 6932e202ad5635b80027ca5778709cd157273f73 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 18 Dec 2021 11:04:49 -0800 Subject: [PATCH 04/64] Revert name changes to err file --- .github/workflows/check_svgs_on_pr.yml | 4 ++-- .github/workflows/post_check_svgs_comment.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_svgs_on_pr.yml b/.github/workflows/check_svgs_on_pr.yml index a20329adc..ad93d9b00 100644 --- a/.github/workflows/check_svgs_on_pr.yml +++ b/.github/workflows/check_svgs_on_pr.yml @@ -28,8 +28,8 @@ jobs: uses: actions/upload-artifact@v2 if: success() with: - name: check_err_messages - path: ./check_err_messages.txt + name: svg_err_messages + path: ./svg_err_messages.txt - name: Save the pr num in an artifact shell: bash diff --git a/.github/workflows/post_check_svgs_comment.yml b/.github/workflows/post_check_svgs_comment.yml index bbe415543..40da0e352 100644 --- a/.github/workflows/post_check_svgs_comment.yml +++ b/.github/workflows/post_check_svgs_comment.yml @@ -33,7 +33,7 @@ jobs: id: err_message_reader uses: juliangruber/read-file-action@v1.0.0 with: - path: ./check_err_messages/check_err_messages.txt + path: ./svg_err_messages/svg_err_messages.txt - name: Comment on the PR about the result - SVG Error uses: jungwinter/comment@v1 # let us comment on a specific PR From 886dcf917409e4c6e98871377f33bf454bc70969 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Fri, 24 Dec 2021 22:56:37 -0800 Subject: [PATCH 05/64] Working on labeler --- .github/scripts/build_assets/arg_getters.py | 11 +++++++++++ .github/scripts/in_develop_labeler.py | 8 ++++++++ .github/workflows/in_develop_labeler.yml | 11 +++++++++++ 3 files changed, 30 insertions(+) create mode 100644 .github/scripts/in_develop_labeler.py create mode 100644 .github/workflows/in_develop_labeler.yml diff --git a/.github/scripts/build_assets/arg_getters.py b/.github/scripts/build_assets/arg_getters.py index 80b88d3c2..1527a87cf 100644 --- a/.github/scripts/build_assets/arg_getters.py +++ b/.github/scripts/build_assets/arg_getters.py @@ -68,3 +68,14 @@ def get_release_message_args(): help="The GitHub token to access the GitHub REST API.", type=str) 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("body", + help="The PR's initial comment by the author AKA the `body` attribute of the `pull_request` API object.", + type=str) + return parser.parse_args() diff --git a/.github/scripts/in_develop_labeler.py b/.github/scripts/in_develop_labeler.py new file mode 100644 index 000000000..1cf9689ea --- /dev/null +++ b/.github/scripts/in_develop_labeler.py @@ -0,0 +1,8 @@ +import re +from build_assets import arg_getters + +def main(): + args = arg_getters.get_in_develop_labeler_args() + +if __name__ == "__main__": + main() diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml new file mode 100644 index 000000000..77dff455c --- /dev/null +++ b/.github/workflows/in_develop_labeler.yml @@ -0,0 +1,11 @@ +name: Label Issue In Develop +on: + pull_request: + types: [closed] +jobs: + label: + name: Get Fonts From Icomoon + runs-on: ubuntu-18.04 + if: github.event.merged == true + steps: + - uses: actions/checkout@v2 \ No newline at end of file From 3e35603c9ebfe28424b051c181d97df99c27be36 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 11:56:14 -0800 Subject: [PATCH 06/64] Add in_develop_labeler --- .github/scripts/build_assets/api_handler.py | 23 +++++++++++++++++++++ .github/scripts/build_assets/arg_getters.py | 4 ++++ .github/scripts/in_develop_labeler.py | 11 +++++++++- .github/workflows/in_develop_labeler.yml | 11 +++++++++- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index f75a20ccd..d677cf5ff 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -1,6 +1,7 @@ import requests import sys import re +from typing import List def get_merged_pull_reqs_since_last_release(token): @@ -99,3 +100,25 @@ 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, 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" + } + base_url = "https://api.github.com/repos/devicons/devicon/issues/{0}/labels" + for issue in issues: + body = { + "labels": labels + } + response = requests.post(base_url.format(issue), headers=headers, body=body) + if not response: + raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}.") + else: + print(f"Successfully labelled issue {issue}") diff --git a/.github/scripts/build_assets/arg_getters.py b/.github/scripts/build_assets/arg_getters.py index 1527a87cf..71f7d16b8 100644 --- a/.github/scripts/build_assets/arg_getters.py +++ b/.github/scripts/build_assets/arg_getters.py @@ -75,6 +75,10 @@ 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) diff --git a/.github/scripts/in_develop_labeler.py b/.github/scripts/in_develop_labeler.py index 1cf9689ea..827a2a443 100644 --- a/.github/scripts/in_develop_labeler.py +++ b/.github/scripts/in_develop_labeler.py @@ -1,8 +1,17 @@ import re -from build_assets import arg_getters +from build_assets import arg_getters, api_handler def main(): args = arg_getters.get_in_develop_labeler_args() + try: + # find the issue closing line + issue_line = [line for line in args.body.split("\n") if line.startswith("**This PR closes")][0] + + issue_pattern = re.compile(r"\d+") + issues_numbers = issue_pattern.findall(issue_line) + api_handler.label_issues(args.token, issues_numbers, ["in-develop"]) + except IndexError: # if can't find the issue line + raise Exception("The PR body doesn't contain `**This PR closes` keywords") if __name__ == "__main__": main() diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 77dff455c..6ae9edb4a 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -8,4 +8,13 @@ jobs: runs-on: ubuntu-18.04 if: github.event.merged == true steps: - - uses: actions/checkout@v2 \ No newline at end of file + - name: Setup Python v3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Run in_develop_labeler.py + env: + BODY: ${{ github.event.body }} + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: python in_develop_labeler.py $TOKEN $BODY From 74320bd672cbc5143c8d727dc02af6fb9df8fe4d Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 14:02:42 -0800 Subject: [PATCH 07/64] Build bot can close issues based on labels --- .github/scripts/build_assets/api_handler.py | 59 +++++++++++++++++++++ .github/scripts/icomoon_build.py | 4 ++ 2 files changed, 63 insertions(+) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index d677cf5ff..730ed561e 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -122,3 +122,62 @@ def label_issues(token: str, issues: List[str], labels: List[str]): raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}.") 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" + } + base_url = "https://api.github.com/repos/devicons/devicon/issues/{0}" + body = { + "state": "closed" + } + for issue in issues: + response = requests.post(base_url.format(issue), headers=headers, body=body) + if not response: + raise Exception(f"Can't close Issue provided. Issue: {issue}") + 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 = "https://api.github.com/repos/devicons/devicon/issues/" + headers = { + "Authorization": f"token {token}", + "accept": "application/vnd.github.v3+json" + } + issues = [] + done = False + page_num = 1 + while not done: + body = { + "labels": ",".join(labels), + "per_page": 100, + "page": page_num + } + response = requests.post(url, headers=headers, body=body) + if not response: + raise Exception(f"Can't access API. Can't get issues for labels: {labels}") + 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 diff --git a/.github/scripts/icomoon_build.py b/.github/scripts/icomoon_build.py index 1a362c697..bbe509582 100644 --- a/.github/scripts/icomoon_build.py +++ b/.github/scripts/icomoon_build.py @@ -49,6 +49,10 @@ def main(): print("Creating the release message by querying the GitHub API...") get_release_message(args.token) + print("Closing the issues with the label of `in-develop`.") + issues = api_handler.get_issues_by_labels(args.token, ["in-develop"]) + api_handler.close_issues(args.token, issues) + print("Task completed.") except TimeoutException as e: util.exit_with_err("Selenium Time Out Error: \n" + str(e)) From 857b1b8bdae41f6ef72ff8a517d438123a368c20 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 14:24:26 -0800 Subject: [PATCH 08/64] Test mode for build --- .github/scripts/icomoon_build.py | 56 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/scripts/icomoon_build.py b/.github/scripts/icomoon_build.py index bbe509582..8a321dfee 100644 --- a/.github/scripts/icomoon_build.py +++ b/.github/scripts/icomoon_build.py @@ -20,34 +20,34 @@ def main(): runner = None try: args = arg_getters.get_selenium_runner_args() - 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("Updating the icomoon json...") - update_icomoon_json(new_icons, args.icomoon_json_path) - - print("Start the building icons process...") - icon_svgs = filehandler.get_svgs_paths( - new_icons, args.icons_folder_path, icon_versions_only=True) - zip_name = "devicon-v1.0.zip" - zip_path = Path(args.download_path, zip_name) - screenshot_folder = filehandler.create_screenshot_folder("./") - runner = BuildSeleniumRunner(args.download_path, - args.geckodriver_path, args.headless) - runner.build_icons(args.icomoon_json_path, zip_path, - icon_svgs, screenshot_folder) - - filehandler.extract_files(str(zip_path), args.download_path) - filehandler.rename_extracted_files(args.download_path) - - print("Creating the release message by querying the GitHub API...") - get_release_message(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("Updating the icomoon json...") + # update_icomoon_json(new_icons, args.icomoon_json_path) + + # print("Start the building icons process...") + # icon_svgs = filehandler.get_svgs_paths( + # new_icons, args.icons_folder_path, icon_versions_only=True) + # zip_name = "devicon-v1.0.zip" + # zip_path = Path(args.download_path, zip_name) + # screenshot_folder = filehandler.create_screenshot_folder("./") + # runner = BuildSeleniumRunner(args.download_path, + # args.geckodriver_path, args.headless) + # runner.build_icons(args.icomoon_json_path, zip_path, + # icon_svgs, screenshot_folder) + + # filehandler.extract_files(str(zip_path), args.download_path) + # filehandler.rename_extracted_files(args.download_path) + + # print("Creating the release message by querying the GitHub API...") + # get_release_message(args.token) print("Closing the issues with the label of `in-develop`.") issues = api_handler.get_issues_by_labels(args.token, ["in-develop"]) From 81495ee7c76de7b303c0e97d599ca99dd0f088cd Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 15:57:25 -0800 Subject: [PATCH 09/64] Add test.txt --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 000000000..0b5d6ed36 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +hi From 313ee679286ecfc25590c0ff707b1c15ccd6022e Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 16:01:04 -0800 Subject: [PATCH 10/64] Update in_develop_labeler.ylm --- .github/workflows/in_develop_labeler.yml | 2 +- test.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 test.txt diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 6ae9edb4a..a6db97339 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -6,7 +6,7 @@ jobs: label: name: Get Fonts From Icomoon runs-on: ubuntu-18.04 - if: github.event.merged == true + if: github.event.merged == "true" steps: - name: Setup Python v3.8 uses: actions/setup-python@v2 diff --git a/test.txt b/test.txt deleted file mode 100644 index 0b5d6ed36..000000000 --- a/test.txt +++ /dev/null @@ -1 +0,0 @@ -hi From 0a04da5092c6abd782f96b69ab2884016c833189 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 16:07:42 -0800 Subject: [PATCH 11/64] Fixed str error in yml file --- .github/workflows/in_develop_labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index a6db97339..e90aa5c23 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -6,7 +6,7 @@ jobs: label: name: Get Fonts From Icomoon runs-on: ubuntu-18.04 - if: github.event.merged == "true" + if: github.event.merged == 'true' steps: - name: Setup Python v3.8 uses: actions/setup-python@v2 From 880d7f57dfe839fe7302e1e9a64685d5ee052916 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 16:11:51 -0800 Subject: [PATCH 12/64] Add test log --- .github/workflows/in_develop_labeler.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index e90aa5c23..1844fb36d 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -6,8 +6,12 @@ jobs: label: name: Get Fonts From Icomoon runs-on: ubuntu-18.04 - if: github.event.merged == 'true' + # if: github.event.merged == 'true' steps: + - env: + DATA: ${{github.event}} + run: echo $DATA + - name: Setup Python v3.8 uses: actions/setup-python@v2 with: From 2ab8ffd0f50c6dedf31e9499a719e92a71207ecb Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 16:38:37 -0800 Subject: [PATCH 13/64] Add more logging --- .github/workflows/in_develop_labeler.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 1844fb36d..d16f04307 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -8,7 +8,8 @@ jobs: runs-on: ubuntu-18.04 # if: github.event.merged == 'true' steps: - - env: + - name: Log github event + env: DATA: ${{github.event}} run: echo $DATA From cc46f765992c007761e48a39fa9bf4d4bff608d4 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 16:47:02 -0800 Subject: [PATCH 14/64] Update yml --- .github/workflows/in_develop_labeler.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index d16f04307..de497723c 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -4,13 +4,13 @@ on: types: [closed] jobs: label: - name: Get Fonts From Icomoon + name: Label Issue In Develop runs-on: ubuntu-18.04 # if: github.event.merged == 'true' steps: - name: Log github event env: - DATA: ${{github.event}} + DATA: ${{ github.event }} run: echo $DATA - name: Setup Python v3.8 From 23509761133582cc5b1bb1253491960d45326f9e Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 16:53:39 -0800 Subject: [PATCH 15/64] Update yml --- .github/workflows/in_develop_labeler.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index de497723c..54d6eaa95 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -1,25 +1,23 @@ name: Label Issue In Develop -on: - pull_request: - types: [closed] +on: pull_request jobs: label: name: Label Issue In Develop runs-on: ubuntu-18.04 # if: github.event.merged == 'true' steps: - - name: Log github event - env: - DATA: ${{ github.event }} - run: echo $DATA - - name: Setup Python v3.8 uses: actions/setup-python@v2 with: python-version: 3.8 - - name: Run in_develop_labeler.py + # - name: Run in_develop_labeler.py + # env: + # BODY: ${{ github.event.body }} + # TOKEN: ${{ secrets.GITHUB_TOKEN }} + # run: python in_develop_labeler.py $TOKEN $BODY + + - name: Log github event env: - BODY: ${{ github.event.body }} - TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: python in_develop_labeler.py $TOKEN $BODY + DATA: ${{ github.event }} + run: echo $DATA From cbcdff33304f8b2535eb0dc55e8db2e1f999dfca Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 16:56:47 -0800 Subject: [PATCH 16/64] update --- .github/workflows/in_develop_labeler.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 54d6eaa95..cb9c690fe 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -18,6 +18,4 @@ jobs: # run: python in_develop_labeler.py $TOKEN $BODY - name: Log github event - env: - DATA: ${{ github.event }} - run: echo $DATA + run: echo hello From d4dd141b81802b5a52d96f9efd88338557e0661d Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 16:57:58 -0800 Subject: [PATCH 17/64] update --- .github/workflows/in_develop_labeler.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index cb9c690fe..0d79abf45 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -18,4 +18,6 @@ jobs: # run: python in_develop_labeler.py $TOKEN $BODY - name: Log github event - run: echo hello + env: + DATA: hello + run: echo $DATA From 2a09eb2359c3e458aac367c18b7b01d62a20d40f Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 16:59:46 -0800 Subject: [PATCH 18/64] update --- .github/workflows/in_develop_labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 0d79abf45..5d19e509e 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -19,5 +19,5 @@ jobs: - name: Log github event env: - DATA: hello + EVENT: ${{ github.event }} run: echo $DATA From 6156755daf9f29836bf456bdbfd23e6d2e7106eb Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 17:02:25 -0800 Subject: [PATCH 19/64] update --- .github/workflows/in_develop_labeler.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 5d19e509e..fba5f6d5c 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -17,7 +17,8 @@ jobs: # TOKEN: ${{ secrets.GITHUB_TOKEN }} # run: python in_develop_labeler.py $TOKEN $BODY - - name: Log github event + - name: Run echo env: EVENT: ${{ github.event }} - run: echo $DATA + shell: cmd + run: echo $EVENT From 74f000836a83921184a8aed6502e52dc749eb45b Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 17:03:11 -0800 Subject: [PATCH 20/64] update --- .github/workflows/in_develop_labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index fba5f6d5c..6bf02cc6b 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -19,6 +19,6 @@ jobs: - name: Run echo env: - EVENT: ${{ github.event }} + EVENT: ${{ toJSON(github.event) }} shell: cmd run: echo $EVENT From 66fdac73fd65055963e5c8ac8977bacb4ad6dadf Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 17:10:01 -0800 Subject: [PATCH 21/64] update --- .github/workflows/in_develop_labeler.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 6bf02cc6b..6f1da2ecd 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -20,5 +20,4 @@ jobs: - name: Run echo env: EVENT: ${{ toJSON(github.event) }} - shell: cmd run: echo $EVENT From 9591313b37f6882786f0e5c89beb0b6ef4cc8686 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 17:15:58 -0800 Subject: [PATCH 22/64] update --- .github/workflows/in_develop_labeler.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 6f1da2ecd..d32c0579d 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -19,5 +19,6 @@ jobs: - name: Run echo env: - EVENT: ${{ toJSON(github.event) }} - run: echo $EVENT + MERGED_BOOL: ${{ github.event.merged == false }} + MERGED_STR: ${{ github.event.merged == 'false' }} + run: echo $MERGED_BOOL $MERGED_STR From 99f31180e8fe57b6a451740d4c9b34604405189c Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 17:23:11 -0800 Subject: [PATCH 23/64] update --- .github/workflows/in_develop_labeler.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index d32c0579d..4fe34fe44 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -1,24 +1,26 @@ name: Label Issue In Develop -on: pull_request +on: + pull_request: + types: [closed] jobs: label: name: Label Issue In Develop runs-on: ubuntu-18.04 - # if: github.event.merged == 'true' + if: github.event.merged == true steps: - name: Setup Python v3.8 uses: actions/setup-python@v2 with: python-version: 3.8 - # - name: Run in_develop_labeler.py - # env: - # BODY: ${{ github.event.body }} - # TOKEN: ${{ secrets.GITHUB_TOKEN }} - # run: python in_develop_labeler.py $TOKEN $BODY + - name: Run in_develop_labeler.py + env: + BODY: ${{ github.event.body }} + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: python in_develop_labeler.py $TOKEN $BODY - name: Run echo env: - MERGED_BOOL: ${{ github.event.merged == false }} - MERGED_STR: ${{ github.event.merged == 'false' }} + MERGED_BOOL: ${{ github.event.merged == true }} + MERGED_STR: ${{ github.event.merged == 'true' }} run: echo $MERGED_BOOL $MERGED_STR From c2e28ccf8ea774407d4f7afc4e431080deacd48c Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 17:31:37 -0800 Subject: [PATCH 24/64] update --- .github/workflows/in_develop_labeler.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 4fe34fe44..ac6ae0848 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -6,7 +6,7 @@ jobs: label: name: Label Issue In Develop runs-on: ubuntu-18.04 - if: github.event.merged == true + # if: github.event.merged == true steps: - name: Setup Python v3.8 uses: actions/setup-python@v2 @@ -23,4 +23,5 @@ jobs: env: MERGED_BOOL: ${{ github.event.merged == true }} MERGED_STR: ${{ github.event.merged == 'true' }} - run: echo $MERGED_BOOL $MERGED_STR + EVENT: ${{ toJSON(github.event) }} + run: echo $MERGED_BOOL $MERGED_STR $EVENT From 04ed9b05ca65f3aa2b80e2086c589fbaa2b555a2 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 17:56:09 -0800 Subject: [PATCH 25/64] update --- .github/workflows/in_develop_labeler.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index ac6ae0848..cb6baf04e 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -13,15 +13,13 @@ jobs: with: python-version: 3.8 - - name: Run in_develop_labeler.py - env: - BODY: ${{ github.event.body }} - TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: python in_develop_labeler.py $TOKEN $BODY - - name: Run echo env: - MERGED_BOOL: ${{ github.event.merged == true }} - MERGED_STR: ${{ github.event.merged == 'true' }} EVENT: ${{ toJSON(github.event) }} run: echo $MERGED_BOOL $MERGED_STR $EVENT + + - name: Run in_develop_labeler.py + env: + BODY: ${{ github.event.body }} + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: python .github/scripts/in_develop_labeler.py $TOKEN $BODY From 2202d9bef756203c978d63a4792da0426b85d61b Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 17:58:55 -0800 Subject: [PATCH 26/64] update --- .github/workflows/in_develop_labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index cb6baf04e..2dacbd1b1 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -16,7 +16,7 @@ jobs: - name: Run echo env: EVENT: ${{ toJSON(github.event) }} - run: echo $MERGED_BOOL $MERGED_STR $EVENT + run: echo $EVENT - name: Run in_develop_labeler.py env: From 349feb2f7d370b705e5a0ab63dc6c1c7815e100d Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:04:33 -0800 Subject: [PATCH 27/64] update --- .github/workflows/in_develop_labeler.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 2dacbd1b1..499333c3c 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -6,7 +6,7 @@ jobs: label: name: Label Issue In Develop runs-on: ubuntu-18.04 - # if: github.event.merged == true + if: github.event.pull_request.merged == true steps: - name: Setup Python v3.8 uses: actions/setup-python@v2 @@ -22,4 +22,4 @@ jobs: env: BODY: ${{ github.event.body }} TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: python .github/scripts/in_develop_labeler.py $TOKEN $BODY + run: python ./.github/scripts/in_develop_labeler.py $TOKEN $BODY From 6d5347a2bd340a7547d7448ec3fa319534c4e668 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:07:44 -0800 Subject: [PATCH 28/64] update --- .github/workflows/in_develop_labeler.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 499333c3c..e4adb605c 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -8,16 +8,13 @@ jobs: runs-on: ubuntu-18.04 if: github.event.pull_request.merged == true steps: + - uses: actions/checkout@v2 + - name: Setup Python v3.8 uses: actions/setup-python@v2 with: python-version: 3.8 - - name: Run echo - env: - EVENT: ${{ toJSON(github.event) }} - run: echo $EVENT - - name: Run in_develop_labeler.py env: BODY: ${{ github.event.body }} From ffce81186a47b6d1d6367338fc6f0cc8e0927edc Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:10:32 -0800 Subject: [PATCH 29/64] update --- .github/workflows/in_develop_labeler.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index e4adb605c..484769fd8 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -15,6 +15,11 @@ jobs: with: python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r ./.github/scripts/requirements.txt + - name: Run in_develop_labeler.py env: BODY: ${{ github.event.body }} From 85747b6a169f8b53068580a8ed5246cb40a62b65 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:12:42 -0800 Subject: [PATCH 30/64] update --- .github/workflows/in_develop_labeler.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 484769fd8..466b4b6d9 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -1,12 +1,10 @@ name: Label Issue In Develop -on: - pull_request: - types: [closed] +on: pull_request jobs: label: name: Label Issue In Develop runs-on: ubuntu-18.04 - if: github.event.pull_request.merged == true + # if: github.event.pull_request.merged == true steps: - uses: actions/checkout@v2 @@ -22,6 +20,6 @@ jobs: - name: Run in_develop_labeler.py env: - BODY: ${{ github.event.body }} TOKEN: ${{ secrets.GITHUB_TOKEN }} + BODY: ${{ github.event.pull_request.body }} run: python ./.github/scripts/in_develop_labeler.py $TOKEN $BODY From f975a77f8df4962d417bacdb64c38337c70df7ae Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:18:10 -0800 Subject: [PATCH 31/64] update --- .github/scripts/in_develop_labeler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/scripts/in_develop_labeler.py b/.github/scripts/in_develop_labeler.py index 827a2a443..21133c605 100644 --- a/.github/scripts/in_develop_labeler.py +++ b/.github/scripts/in_develop_labeler.py @@ -7,8 +7,10 @@ def main(): # find the issue closing line issue_line = [line for line in args.body.split("\n") if line.startswith("**This PR closes")][0] + print("Issue Line is " + issue_line) issue_pattern = re.compile(r"\d+") issues_numbers = issue_pattern.findall(issue_line) + print("Labelling issues: " + issues_numbers) api_handler.label_issues(args.token, issues_numbers, ["in-develop"]) except IndexError: # if can't find the issue line raise Exception("The PR body doesn't contain `**This PR closes` keywords") From 3a7da1289655ec6f543e3fa292f0928f16d78312 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:20:31 -0800 Subject: [PATCH 32/64] update --- .github/workflows/in_develop_labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 466b4b6d9..cb57390ae 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -22,4 +22,4 @@ jobs: env: TOKEN: ${{ secrets.GITHUB_TOKEN }} BODY: ${{ github.event.pull_request.body }} - run: python ./.github/scripts/in_develop_labeler.py $TOKEN $BODY + run: python ./.github/scripts/in_develop_labeler.py $TOKEN "$BODY" From 99e43d1cc6c570e8addd39744dd8e95cbba65899 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:23:54 -0800 Subject: [PATCH 33/64] update --- .github/scripts/in_develop_labeler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/in_develop_labeler.py b/.github/scripts/in_develop_labeler.py index 21133c605..fd0692ed7 100644 --- a/.github/scripts/in_develop_labeler.py +++ b/.github/scripts/in_develop_labeler.py @@ -10,7 +10,7 @@ def main(): print("Issue Line is " + issue_line) issue_pattern = re.compile(r"\d+") issues_numbers = issue_pattern.findall(issue_line) - print("Labelling issues: " + issues_numbers) + print("Labelling issues: " + str(issues_numbers)) api_handler.label_issues(args.token, issues_numbers, ["in-develop"]) except IndexError: # if can't find the issue line raise Exception("The PR body doesn't contain `**This PR closes` keywords") From 934860707bb755084f8ed22fbcb3af85c2ee833d Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:29:16 -0800 Subject: [PATCH 34/64] update --- .github/scripts/build_assets/api_handler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index 730ed561e..ae5bb3058 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -117,7 +117,7 @@ def label_issues(token: str, issues: List[str], labels: List[str]): body = { "labels": labels } - response = requests.post(base_url.format(issue), headers=headers, body=body) + response = requests.post(base_url.format(issue), headers=headers, data=body) if not response: raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}.") else: @@ -139,7 +139,7 @@ def close_issues(token: str, issues: List[str]): "state": "closed" } for issue in issues: - response = requests.post(base_url.format(issue), headers=headers, body=body) + response = requests.post(base_url.format(issue), headers=headers, data=body) if not response: raise Exception(f"Can't close Issue provided. Issue: {issue}") else: @@ -166,7 +166,7 @@ def get_issues_by_labels(token: str, labels: List[str]): "per_page": 100, "page": page_num } - response = requests.post(url, headers=headers, body=body) + response = requests.post(url, headers=headers, data=body) if not response: raise Exception(f"Can't access API. Can't get issues for labels: {labels}") else: From 91cd11a6290da13648ba20fb5a123b3a5e6c4b8c Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:35:06 -0800 Subject: [PATCH 35/64] update --- .github/scripts/build_assets/api_handler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index ae5bb3058..abce54ec8 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -119,7 +119,7 @@ def label_issues(token: str, issues: List[str], labels: List[str]): } response = requests.post(base_url.format(issue), headers=headers, data=body) if not response: - raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}.") + raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}, API response: " + response.text) else: print(f"Successfully labelled issue {issue}") @@ -141,7 +141,7 @@ def close_issues(token: str, issues: List[str]): for issue in issues: response = requests.post(base_url.format(issue), headers=headers, data=body) if not response: - raise Exception(f"Can't close Issue provided. Issue: {issue}") + raise Exception(f"Can't close Issue provided. Issue: {issue}, API response: " + response.text) else: print(f"Successfully closed issue {issue}") @@ -168,7 +168,7 @@ def get_issues_by_labels(token: str, labels: List[str]): } response = requests.post(url, headers=headers, data=body) if not response: - raise Exception(f"Can't access API. Can't get issues for labels: {labels}") + 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: From 43e11c988f26e6c7f0c7d875bd181fe7ed500bf1 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 18:58:36 -0800 Subject: [PATCH 36/64] update --- .github/scripts/build_assets/api_handler.py | 7 ++++--- .github/scripts/build_assets/arg_getters.py | 4 ++++ .github/scripts/in_develop_labeler.py | 2 +- .github/workflows/in_develop_labeler.yml | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index abce54ec8..c5e55f48b 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -101,10 +101,11 @@ def find_all_authors(pull_req_data, token): 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, issues: List[str], labels: List[str]): +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 repo: the owner and name of the repo. :param issues: the issue numbers (as str) that we are labelling. :param labels: the labels that we are labelling. """ @@ -112,12 +113,12 @@ def label_issues(token: str, issues: List[str], labels: List[str]): "Authorization": f"token {token}", "accept": "application/vnd.github.v3+json" } - base_url = "https://api.github.com/repos/devicons/devicon/issues/{0}/labels" + base_url = "https://api.github.com/repos/{}/issues/{}/labels" for issue in issues: body = { "labels": labels } - response = requests.post(base_url.format(issue), headers=headers, data=body) + response = requests.post(base_url.format(repo, issue), headers=headers, data=body) if not response: raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}, API response: " + response.text) else: diff --git a/.github/scripts/build_assets/arg_getters.py b/.github/scripts/build_assets/arg_getters.py index 71f7d16b8..e8499bb2d 100644 --- a/.github/scripts/build_assets/arg_getters.py +++ b/.github/scripts/build_assets/arg_getters.py @@ -82,4 +82,8 @@ def get_in_develop_labeler_args(): 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() diff --git a/.github/scripts/in_develop_labeler.py b/.github/scripts/in_develop_labeler.py index fd0692ed7..5b68adad3 100644 --- a/.github/scripts/in_develop_labeler.py +++ b/.github/scripts/in_develop_labeler.py @@ -11,7 +11,7 @@ def main(): issue_pattern = re.compile(r"\d+") issues_numbers = issue_pattern.findall(issue_line) print("Labelling issues: " + str(issues_numbers)) - api_handler.label_issues(args.token, issues_numbers, ["in-develop"]) + api_handler.label_issues(args.token, args.repo, issues_numbers, ["in-develop"]) except IndexError: # if can't find the issue line raise Exception("The PR body doesn't contain `**This PR closes` keywords") diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index cb57390ae..ad30b3d9c 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -22,4 +22,4 @@ jobs: env: TOKEN: ${{ secrets.GITHUB_TOKEN }} BODY: ${{ github.event.pull_request.body }} - run: python ./.github/scripts/in_develop_labeler.py $TOKEN "$BODY" + run: python ./.github/scripts/in_develop_labeler.py $TOKEN "$BODY" $GITHUB_REPOSITORY From 7a3b81657a840680dd704a22cb4c882e3fe0e386 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 19:10:36 -0800 Subject: [PATCH 37/64] update --- .github/scripts/build_assets/api_handler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index c5e55f48b..d2b6eee21 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -2,6 +2,7 @@ import sys import re from typing import List +import json def get_merged_pull_reqs_since_last_release(token): @@ -118,7 +119,7 @@ def label_issues(token: str, repo: str, issues: List[str], labels: List[str]): body = { "labels": labels } - response = requests.post(base_url.format(repo, issue), headers=headers, data=body) + response = requests.post(base_url.format(repo, issue), headers=headers, json=json.dumps(body)) if not response: raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}, API response: " + response.text) else: From dd909a84943650764c7ff9276b9b4486d0d97eba Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 19:22:13 -0800 Subject: [PATCH 38/64] update --- .github/scripts/build_assets/api_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index d2b6eee21..7d154a3b5 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -117,9 +117,9 @@ def label_issues(token: str, repo: str, issues: List[str], labels: List[str]): base_url = "https://api.github.com/repos/{}/issues/{}/labels" for issue in issues: body = { - "labels": labels + "labels": str(labels) } - response = requests.post(base_url.format(repo, issue), headers=headers, json=json.dumps(body)) + response = requests.post(base_url.format(repo, issue), headers=headers, data=body) if not response: raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}, API response: " + response.text) else: From 703993bc81ecd884dae1343b79cb88b974f89021 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 20:15:33 -0800 Subject: [PATCH 39/64] update --- .github/scripts/build_assets/api_handler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index 7d154a3b5..16d75e856 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -117,9 +117,9 @@ def label_issues(token: str, repo: str, issues: List[str], labels: List[str]): base_url = "https://api.github.com/repos/{}/issues/{}/labels" for issue in issues: body = { - "labels": str(labels) + "labels": labels } - response = requests.post(base_url.format(repo, issue), headers=headers, data=body) + response = requests.post(base_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: @@ -141,7 +141,7 @@ def close_issues(token: str, issues: List[str]): "state": "closed" } for issue in issues: - response = requests.post(base_url.format(issue), headers=headers, data=body) + response = requests.post(base_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: @@ -168,7 +168,7 @@ def get_issues_by_labels(token: str, labels: List[str]): "per_page": 100, "page": page_num } - response = requests.post(url, headers=headers, data=body) + response = requests.post(url, headers=headers, json=body) if not response: raise Exception(f"Can't access API. Can't get issues for labels: {labels}, API response: " + response.text) else: From 58869d282f81c53369b6ecc127d542d3b2790cfe Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 20:21:06 -0800 Subject: [PATCH 40/64] update --- .github/workflows/in_develop_labeler.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index ad30b3d9c..22ce676ed 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -1,10 +1,12 @@ name: Label Issue In Develop -on: pull_request +on: + pull_request: + types: [closed] jobs: label: name: Label Issue In Develop runs-on: ubuntu-18.04 - # if: github.event.pull_request.merged == true + if: github.event.pull_request.merged == true steps: - uses: actions/checkout@v2 From 8819cdfdd341f307eeddbde432e2530054307dc1 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 20:42:58 -0800 Subject: [PATCH 41/64] Fixed build_icons.yml --- .github/workflows/build_icons.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_icons.yml b/.github/workflows/build_icons.yml index 2d1d68e62..4747bd0bc 100644 --- a/.github/workflows/build_icons.yml +++ b/.github/workflows/build_icons.yml @@ -23,7 +23,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: > python ./.github/scripts/icomoon_build.py - ./.github/scripts/build_assets/geckodriver-v0.29.1-win64/geckodriver.exe ./icomoon.json + ./.github/scripts/build_assets/geckodriver-v0.30.0-win64/geckodriver.exe ./icomoon.json ./devicon.json ./icons ./ %GITHUB_TOKEN% --headless - name: Upload geckodriver.log for debugging purposes From 851ae2ab7405e07d63acd09758d8c78b57f56b6b Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 22:34:01 -0800 Subject: [PATCH 42/64] update --- .github/scripts/build_assets/api_handler.py | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index 16d75e856..19587ec3a 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -2,9 +2,13 @@ import sys import re from typing import List -import json +# 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. @@ -40,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}" } @@ -52,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) @@ -102,11 +106,11 @@ def find_all_authors(pull_req_data, token): 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 repo: the owner and name of the repo. :param issues: the issue numbers (as str) that we are labelling. :param labels: the labels that we are labelling. """ @@ -114,12 +118,12 @@ def label_issues(token: str, repo: str, issues: List[str], labels: List[str]): "Authorization": f"token {token}", "accept": "application/vnd.github.v3+json" } - base_url = "https://api.github.com/repos/{}/issues/{}/labels" + url = base_url + "issues/{}/labels" for issue in issues: body = { "labels": labels } - response = requests.post(base_url.format(repo, issue), headers=headers, json=body) + 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: @@ -136,12 +140,12 @@ def close_issues(token: str, issues: List[str]): "Authorization": f"token {token}", "accept": "application/vnd.github.v3+json" } - base_url = "https://api.github.com/repos/devicons/devicon/issues/{0}" + url = base_url + "issues/{}" body = { "state": "closed" } for issue in issues: - response = requests.post(base_url.format(issue), headers=headers, json=body) + response = requests.post(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: @@ -154,7 +158,7 @@ def get_issues_by_labels(token: str, labels: List[str]): :param token: the GitHub API token. :param labels: the labels that we are labelling. """ - url = "https://api.github.com/repos/devicons/devicon/issues/" + url = base_url + "issues/" headers = { "Authorization": f"token {token}", "accept": "application/vnd.github.v3+json" From 61b57398745887a1a247d365b926130d8892e1c2 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 22:54:05 -0800 Subject: [PATCH 43/64] update --- .github/scripts/build_assets/api_handler.py | 11 +++-------- .github/scripts/in_develop_labeler.py | 3 ++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index 19587ec3a..cc9d06728 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -145,7 +145,7 @@ def close_issues(token: str, issues: List[str]): "state": "closed" } for issue in issues: - response = requests.post(url.format(issue), headers=headers, json=body) + 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: @@ -158,7 +158,7 @@ def get_issues_by_labels(token: str, labels: List[str]): :param token: the GitHub API token. :param labels: the labels that we are labelling. """ - url = base_url + "issues/" + url = base_url + "issues?per_page=100&labels={}&page={}" headers = { "Authorization": f"token {token}", "accept": "application/vnd.github.v3+json" @@ -167,12 +167,7 @@ def get_issues_by_labels(token: str, labels: List[str]): done = False page_num = 1 while not done: - body = { - "labels": ",".join(labels), - "per_page": 100, - "page": page_num - } - response = requests.post(url, headers=headers, json=body) + response = requests.post(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: diff --git a/.github/scripts/in_develop_labeler.py b/.github/scripts/in_develop_labeler.py index 5b68adad3..9d4917796 100644 --- a/.github/scripts/in_develop_labeler.py +++ b/.github/scripts/in_develop_labeler.py @@ -13,7 +13,8 @@ def main(): print("Labelling issues: " + str(issues_numbers)) api_handler.label_issues(args.token, args.repo, issues_numbers, ["in-develop"]) except IndexError: # if can't find the issue line - raise Exception("The PR body doesn't contain `**This PR closes` keywords") + print("The PR body doesn't contain `**This PR closes` keywords. Ending workflow.") + return if __name__ == "__main__": main() From 46b786b3f68601810c5de06cf18eee7a1083d57b Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 23:00:28 -0800 Subject: [PATCH 44/64] update --- .github/scripts/build_assets/api_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index cc9d06728..002221126 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -167,7 +167,7 @@ def get_issues_by_labels(token: str, labels: List[str]): done = False page_num = 1 while not done: - response = requests.post(url.format(",".join(labels), page_num), headers=headers) + 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: From 6b39426bd25dfd80a753c7a0d139ee1d87ac9525 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 23:10:00 -0800 Subject: [PATCH 45/64] update --- .github/scripts/icomoon_build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/scripts/icomoon_build.py b/.github/scripts/icomoon_build.py index 8a321dfee..f59f5414c 100644 --- a/.github/scripts/icomoon_build.py +++ b/.github/scripts/icomoon_build.py @@ -51,7 +51,8 @@ def main(): print("Closing the issues with the label of `in-develop`.") issues = api_handler.get_issues_by_labels(args.token, ["in-develop"]) - api_handler.close_issues(args.token, issues) + issue_nums = [issue_num["number"] for issue_num in issues] + api_handler.close_issues(args.token, issue_nums) print("Task completed.") except TimeoutException as e: From 0c44d7f79e0a7bd5a73a4d363b66422bf31df822 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 15:49:13 -0800 Subject: [PATCH 46/64] check-bot now check devicon object as well --- .github/scripts/build_assets/arg_getters.py | 19 +++--- .github/scripts/build_assets/filehandler.py | 15 +++-- .github/scripts/build_assets/util.py | 4 +- .../{check_svgs_on_pr.py => check_icon_pr.py} | 66 +++++++++++++++++-- ...check_svgs_on_pr.yml => check_icon_pr.yml} | 15 ++--- .github/workflows/peek_icons.yml | 2 +- .github/workflows/post_check_svgs_comment.yml | 4 +- 7 files changed, 89 insertions(+), 36 deletions(-) rename .github/scripts/{check_svgs_on_pr.py => check_icon_pr.py} (57%) rename .github/workflows/{check_svgs_on_pr.yml => check_icon_pr.yml} (67%) diff --git a/.github/scripts/build_assets/arg_getters.py b/.github/scripts/build_assets/arg_getters.py index 80b88d3c2..f670ef142 100644 --- a/.github/scripts/build_assets/arg_getters.py +++ b/.github/scripts/build_assets/arg_getters.py @@ -34,12 +34,11 @@ 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() @@ -49,13 +48,14 @@ def get_check_svgs_on_pr_args(): Get the commandline arguments for the check_svgs_on_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", - 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("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) + return parser.parse_args() @@ -65,6 +65,5 @@ def get_release_message_args(): """ 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.", - type=str) + help="The GitHub token to access the GitHub REST API.") return parser.parse_args() diff --git a/.github/scripts/build_assets/filehandler.py b/.github/scripts/build_assets/filehandler.py index 054431cd2..4c7d9acaa 100644 --- a/.github/scripts/build_assets/filehandler.py +++ b/.github/scripts/build_assets/filehandler.py @@ -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): """ @@ -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) diff --git a/.github/scripts/build_assets/util.py b/.github/scripts/build_assets/util.py index 2a11f8e11..55ebb3219 100644 --- a/.github/scripts/build_assets/util.py +++ b/.github/scripts/build_assets/util.py @@ -67,7 +67,7 @@ def find_object_added_in_pr(icons: List[dict], pr_title: str): raise Exception(message) -valid_filename_pattern = re.compile(r"-(original|plain|line)(-wordmark)?\.svg$") +valid_svg_filename_pattern = re.compile(r"-(original|plain|line)(-wordmark)?\.svg$") def is_svg_name_valid(filename: str): - return valid_filename_pattern.search(filename) is not None + return valid_svg_filename_pattern.search(filename) is not None diff --git a/.github/scripts/check_svgs_on_pr.py b/.github/scripts/check_icon_pr.py similarity index 57% rename from .github/scripts/check_svgs_on_pr.py rename to .github/scripts/check_icon_pr.py index 9815ad9ce..763f238de 100644 --- a/.github/scripts/check_svgs_on_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -2,7 +2,6 @@ from typing import List import xml.etree.ElementTree as et from pathlib import Path -import build_assets.util # pycharm complains that build_assets is an unresolved ref @@ -21,15 +20,20 @@ class SVG_STATUS_CODE(Enum): def main(): """ - Check the quality of the svgs. + Check the quality of the svgs IF this is an icon PR. Else, does nothing. If any svg error is found, create a json file called 'svg_err_messages.json' in the root folder that will contains the error messages. """ args = arg_getters.get_check_svgs_on_pr_args() try: + all_icons = filehandler.get_json_file_content(args.devicon_json_path) + + # 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) + # check the svgs - svgs = filehandler.get_added_modified_svgs(args.files_added_json_path, - args.files_modified_json_path) + svgs = filehandler.get_svgs_paths([filtered_icon], args.icons_folder_path) print("SVGs to check: ", *svgs, sep='\n') if len(svgs) == 0: @@ -41,9 +45,61 @@ def main(): filehandler.write_to_file("./svg_err_messages.txt", str(err_messages)) print("Task completed.") except Exception as e: + filehandler.write_to_file("./svg_err_messages.txt", str(e)) util.exit_with_err(e) +def check_devicon_object(icon: dict): + """ + Check that the devicon object added is up to standard. + :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 "" + + def check_svgs(svg_file_paths: List[Path]): """ Check the width, height, viewBox and style of each svgs passed in. @@ -62,7 +118,7 @@ def check_svgs(svg_file_paths: List[Path]): err_msg = [f"{svg_path}:"] # name check - if not is_svg_name_valid(svg_path.absolute()): + if not util.is_svg_name_valid(svg_path.name): err_msg.append("-SVG file name didn't match our pattern of `name-(original|plain|line)(-wordmark)?.svg`") # svg check diff --git a/.github/workflows/check_svgs_on_pr.yml b/.github/workflows/check_icon_pr.yml similarity index 67% rename from .github/workflows/check_svgs_on_pr.yml rename to .github/workflows/check_icon_pr.yml index ad93d9b00..ab97eb7f7 100644 --- a/.github/workflows/check_svgs_on_pr.yml +++ b/.github/workflows/check_icon_pr.yml @@ -1,9 +1,10 @@ -name: Check SVGs On PR +name: Check Icon PR on: pull_request jobs: check: - name: Check the SVGs' quality + name: Check the `devicon.json` and the SVGs' quality runs-on: ubuntu-18.04 + if: startsWith(github.event.pull_request.title, "new icon") # only checks icon PR steps: - uses: actions/checkout@v2 @@ -14,15 +15,11 @@ jobs: - name: Install dependencies run: python -m pip install --upgrade pip - - name: Get Changed Files and generate files_added.json & files_modified.json - uses: lots0logs/gh-action-get-changed-files@2.1.4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - # this is where we create the check_err_messages - name: Run the check_svg script + env: + PR_TITLE: ${{ github.event.pull_request.title }} run: > - python ./.github/scripts/check_svgs_on_pr.py $HOME/files_added.json $HOME/files_modified.json + python ./.github/scripts/check_icon_pr.py "$PR_TITLE" ./icons - name: Upload the err messages uses: actions/upload-artifact@v2 diff --git a/.github/workflows/peek_icons.yml b/.github/workflows/peek_icons.yml index 476c08df4..d0c1609ef 100644 --- a/.github/workflows/peek_icons.yml +++ b/.github/workflows/peek_icons.yml @@ -42,7 +42,7 @@ jobs: run: > python ./.github/scripts/icomoon_peek.py ./.github/scripts/build_assets/geckodriver-v0.29.1-win64/geckodriver.exe ./icomoon.json - ./devicon.json ./icons ./ --headless --pr_title "%PR_TITLE%" + ./devicon.json ./icons ./ "%PR_TITLE%" --headless - name: Upload the err messages (created by icomoon_peek.py) uses: actions/upload-artifact@v2 diff --git a/.github/workflows/post_check_svgs_comment.yml b/.github/workflows/post_check_svgs_comment.yml index 40da0e352..46780f1c6 100644 --- a/.github/workflows/post_check_svgs_comment.yml +++ b/.github/workflows/post_check_svgs_comment.yml @@ -1,7 +1,7 @@ name: Post the result of a SVG Check into its PR. on: workflow_run: - workflows: ['Check SVGs On PR'] + workflows: ['Check Icon PR'] types: - completed jobs: @@ -18,7 +18,7 @@ jobs: if: success() with: github_token: ${{ secrets.GITHUB_TOKEN }} - workflow: peek_icons.yml + workflow: check_icon_pr.yml run_id: ${{ github.event.workflow_run.id }} - name: Read the pr_num file From ebc871bc62ab475b6128899eb116c76d886941a0 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 16:20:12 -0800 Subject: [PATCH 47/64] Fixed minor bugs --- .github/scripts/build_assets/arg_getters.py | 8 ++++++-- .github/scripts/check_icon_pr.py | 15 +++++++-------- .github/scripts/icomoon_peek.py | 3 +-- .github/workflows/check_icon_pr.yml | 3 +-- .github/workflows/post_check_svgs_comment.yml | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/scripts/build_assets/arg_getters.py b/.github/scripts/build_assets/arg_getters.py index f670ef142..dbc27c165 100644 --- a/.github/scripts/build_assets/arg_getters.py +++ b/.github/scripts/build_assets/arg_getters.py @@ -43,9 +43,9 @@ def get_selenium_runner_args(peek_mode=False): 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") @@ -56,6 +56,10 @@ def get_check_svgs_on_pr_args(): help="The path to the icons folder", action=PathResolverAction) + parser.add_argument("devicon_json_path", + help="The path to the devicon.json", + action=PathResolverAction) + return parser.parse_args() diff --git a/.github/scripts/check_icon_pr.py b/.github/scripts/check_icon_pr.py index 763f238de..ba3767acf 100644 --- a/.github/scripts/check_icon_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -6,8 +6,7 @@ # pycharm complains that build_assets is an unresolved ref # don't worry about it, the script still runs -from build_assets import filehandler, arg_getters -from build_assets import util +from build_assets import filehandler, arg_getters, util class SVG_STATUS_CODE(Enum): @@ -24,13 +23,13 @@ def main(): If any svg error is found, create a json file called 'svg_err_messages.json' in the root folder that will contains the error messages. """ - args = arg_getters.get_check_svgs_on_pr_args() + args = arg_getters.get_check_icon_pr_args() try: all_icons = filehandler.get_json_file_content(args.devicon_json_path) # 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) + devicon_err_msg = check_devicon_object(filtered_icon) # check the svgs svgs = filehandler.get_svgs_paths([filtered_icon], args.icons_folder_path) @@ -38,11 +37,11 @@ def main(): if len(svgs) == 0: print("No SVGs to check, ending script.") - err_messages = SVG_STATUS_CODE.NO_SVG.value + err_messages = str(SVG_STATUS_CODE.NO_SVG.value) else: err_messages = check_svgs(svgs) - filehandler.write_to_file("./svg_err_messages.txt", str(err_messages)) + filehandler.write_to_file("./svg_err_messages.txt", devicon_err_msg + "\n\n" + err_messages) print("Task completed.") except Exception as e: filehandler.write_to_file("./svg_err_messages.txt", str(e)) @@ -96,7 +95,7 @@ def check_devicon_object(icon: dict): 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 message return "" @@ -145,7 +144,7 @@ def check_svgs(svg_file_paths: List[Path]): if len(err_msgs) > 0: return "\n\n".join(err_msgs) - return SVG_STATUS_CODE.SVG_OK.value + return str(SVG_STATUS_CODE.SVG_OK.value) if __name__ == "__main__": diff --git a/.github/scripts/icomoon_peek.py b/.github/scripts/icomoon_peek.py index 2dcc7143c..4c6e8ea5b 100644 --- a/.github/scripts/icomoon_peek.py +++ b/.github/scripts/icomoon_peek.py @@ -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(): diff --git a/.github/workflows/check_icon_pr.yml b/.github/workflows/check_icon_pr.yml index ab97eb7f7..eb8600c0c 100644 --- a/.github/workflows/check_icon_pr.yml +++ b/.github/workflows/check_icon_pr.yml @@ -18,8 +18,7 @@ jobs: - name: Run the check_svg script env: PR_TITLE: ${{ github.event.pull_request.title }} - run: > - python ./.github/scripts/check_icon_pr.py "$PR_TITLE" ./icons + run: python ./.github/scripts/check_icon_pr.py "$PR_TITLE" ./icons ./devicon.json - name: Upload the err messages uses: actions/upload-artifact@v2 diff --git a/.github/workflows/post_check_svgs_comment.yml b/.github/workflows/post_check_svgs_comment.yml index 46780f1c6..a4a635bac 100644 --- a/.github/workflows/post_check_svgs_comment.yml +++ b/.github/workflows/post_check_svgs_comment.yml @@ -42,7 +42,7 @@ jobs: MESSAGE: | Hi! - I'm the SVG-Checker Bot and we have some issues with your SVGs: + I'm the `check-bot` and we have some issues with your PR: ``` {0} From 6a0798546ad776fa288e0d1ab8dc46330437510d Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 20:30:43 -0800 Subject: [PATCH 48/64] Update --- .github/workflows/check_icon_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_icon_pr.yml b/.github/workflows/check_icon_pr.yml index eb8600c0c..4a37061fc 100644 --- a/.github/workflows/check_icon_pr.yml +++ b/.github/workflows/check_icon_pr.yml @@ -4,7 +4,7 @@ jobs: check: name: Check the `devicon.json` and the SVGs' quality runs-on: ubuntu-18.04 - if: startsWith(github.event.pull_request.title, "new icon") # only checks icon PR + if: startsWith(github.event.pull_request.title, 'new icon') # only checks icon PR steps: - uses: actions/checkout@v2 From fbecbb7c7925501c45f61a7ac880fa4bc8eec525 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 20:37:00 -0800 Subject: [PATCH 49/64] Update --- .github/scripts/check_icon_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/check_icon_pr.py b/.github/scripts/check_icon_pr.py index ba3767acf..8ac71fa07 100644 --- a/.github/scripts/check_icon_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -32,7 +32,7 @@ def main(): devicon_err_msg = check_devicon_object(filtered_icon) # check the svgs - svgs = filehandler.get_svgs_paths([filtered_icon], args.icons_folder_path) + svgs = filehandler.get_svgs_paths([filtered_icon], args.icons_folder_path, as_str=False) print("SVGs to check: ", *svgs, sep='\n') if len(svgs) == 0: From bec2bc1dfd0aae8693fc35d7267dac3a5599814f Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 21:33:47 -0800 Subject: [PATCH 50/64] change logging format --- .github/scripts/check_icon_pr.py | 29 +++---- .github/workflows/post_check_svgs_comment.yml | 80 ------------------- 2 files changed, 15 insertions(+), 94 deletions(-) delete mode 100644 .github/workflows/post_check_svgs_comment.yml diff --git a/.github/scripts/check_icon_pr.py b/.github/scripts/check_icon_pr.py index 8ac71fa07..2935c8143 100644 --- a/.github/scripts/check_icon_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -1,4 +1,3 @@ -from enum import Enum from typing import List import xml.etree.ElementTree as et from pathlib import Path @@ -9,14 +8,6 @@ from build_assets import filehandler, arg_getters, util -class SVG_STATUS_CODE(Enum): - """ - The status codes to check for in post_check_svgs_comment.yml - """ - NO_SVG = 0 # action: do nothing - SVG_OK = 1 # action: let user know their svgs are fine - - def main(): """ Check the quality of the svgs IF this is an icon PR. Else, does nothing. @@ -37,11 +28,21 @@ def main(): if len(svgs) == 0: print("No SVGs to check, ending script.") - err_messages = str(SVG_STATUS_CODE.NO_SVG.value) + svg_err_msg = None + else: + svg_err_msg = check_svgs(svgs) + + err_msg = "" + if devicon_err_msg is None and svg_err_msg is None: + pass # leave err_msg blank + elif devicon_err_msg is None: + err_msg = svg_err_msg + elif svg_err_msg is None: + err_msg = devicon_err_msg else: - err_messages = check_svgs(svgs) + err_msg = devicon_err_msg + "\n\n" + svg_err_msg - filehandler.write_to_file("./svg_err_messages.txt", devicon_err_msg + "\n\n" + err_messages) + filehandler.write_to_file("./svg_err_messages.txt", err_msg) print("Task completed.") except Exception as e: filehandler.write_to_file("./svg_err_messages.txt", str(e)) @@ -96,7 +97,7 @@ def check_devicon_object(icon: dict): if len(err_msgs) > 0: message = "Error found in 'devicon.json' for '{}' entry: \n{}".format(icon["name"], "\n".join(err_msgs)) return message - return "" + return None def check_svgs(svg_file_paths: List[Path]): @@ -144,7 +145,7 @@ def check_svgs(svg_file_paths: List[Path]): if len(err_msgs) > 0: return "\n\n".join(err_msgs) - return str(SVG_STATUS_CODE.SVG_OK.value) + return None if __name__ == "__main__": diff --git a/.github/workflows/post_check_svgs_comment.yml b/.github/workflows/post_check_svgs_comment.yml deleted file mode 100644 index a4a635bac..000000000 --- a/.github/workflows/post_check_svgs_comment.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Post the result of a SVG Check into its PR. -on: - workflow_run: - workflows: ['Check Icon PR'] - types: - - completed -jobs: - post_result_of_svg_check: - name: Post the result of the Check SVG Action - runs-on: ubuntu-18.04 - steps: - - name: Check if the trigger run worked. If it failed, fail the current run. - if: github.event.workflow_run.conclusion != 'success' - uses: cutenode/action-always-fail@v1.0.1 - - - name: Download workflow artifact - uses: dawidd6/action-download-artifact@v2.11.0 - if: success() - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - workflow: check_icon_pr.yml - run_id: ${{ github.event.workflow_run.id }} - - - name: Read the pr_num file - if: success() - id: pr_num_reader - uses: juliangruber/read-file-action@v1.0.0 - with: - path: ./pr_num/pr_num.txt - - - name: Read the err message file - if: success() - id: err_message_reader - uses: juliangruber/read-file-action@v1.0.0 - with: - path: ./svg_err_messages/svg_err_messages.txt - - - name: Comment on the PR about the result - SVG Error - uses: jungwinter/comment@v1 # let us comment on a specific PR - if: success() && (steps.err_message_reader.outputs.content != '0' && steps.err_message_reader.outputs.content != '1') - env: - MESSAGE: | - Hi! - - I'm the `check-bot` and we have some issues with your PR: - - ``` - {0} - ``` - - Check our [CONTRIBUTING guide](https://github.com/devicons/devicon/blob/develop/CONTRIBUTING.md#svgStandards) for more details regarding these errors. - - Please address these issues. When you update this PR, I will check your SVGs again. - - Thanks for your help, - SVG-Checker Bot :smile: - with: - type: create - issue_number: ${{ steps.pr_num_reader.outputs.content }} - token: ${{ secrets.GITHUB_TOKEN }} - body: ${{ format(env.MESSAGE, steps.err_message_reader.outputs.content) }} - - - name: Comment on the PR about the result - Failure - uses: jungwinter/comment@v1 # let us comment on a specific PR - if: failure() - env: - MESSAGE: | - Hi! - - I'm Devicons' SVG-Checker Bot and it seems we've ran into a problem. I'm supposed to check your svgs but I couldn't do my task due to an issue. - - Please let my maintainers know of the issues. They will take a look at my work and try to resolve the problem. Until then, please hang tight and sorry for the inconvenience. - - Cheers, - SVG-Checker Bot :smile: - with: - type: create - issue_number: ${{ steps.pr_num_reader.outputs.content }} - token: ${{ secrets.GITHUB_TOKEN }} - body: ${{ env.MESSAGE }} From a79f75935f05dc09a1f9c2b6f03d2fbb84a3fa8f Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:07:07 -0800 Subject: [PATCH 51/64] improve logging --- .github/scripts/build_assets/util.py | 21 ++++++++++-- .github/scripts/check_icon_pr.py | 51 ++++++++++++++++------------ 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/.github/scripts/build_assets/util.py b/.github/scripts/build_assets/util.py index 55ebb3219..f8fe55c11 100644 --- a/.github/scripts/build_assets/util.py +++ b/.github/scripts/build_assets/util.py @@ -5,6 +5,12 @@ 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): """ Exit the current step and display the err. @@ -67,7 +73,18 @@ def find_object_added_in_pr(icons: List[dict], pr_title: str): raise Exception(message) -valid_svg_filename_pattern = re.compile(r"-(original|plain|line)(-wordmark)?\.svg$") +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 - diff --git a/.github/scripts/check_icon_pr.py b/.github/scripts/check_icon_pr.py index 2935c8143..8b4b5ad87 100644 --- a/.github/scripts/check_icon_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -22,27 +22,28 @@ def main(): filtered_icon = util.find_object_added_in_pr(all_icons, args.pr_title) devicon_err_msg = check_devicon_object(filtered_icon) - # check the svgs - svgs = filehandler.get_svgs_paths([filtered_icon], args.icons_folder_path, as_str=False) - print("SVGs to check: ", *svgs, sep='\n') + # check the file names + filename_err_msg = "" + try: + svgs = filehandler.get_svgs_paths([filtered_icon], args.icons_folder_path, as_str=False) + print("SVGs to check: ", *svgs, sep='\n') + except ValueError as e: + filename_err_msg = "Error found regarding filenames:\n- " + e.args + # check the svgs if len(svgs) == 0: print("No SVGs to check, ending script.") - svg_err_msg = None + svg_err_msg = "Error checking SVGs: no SVGs to check." else: svg_err_msg = check_svgs(svgs) - err_msg = "" - if devicon_err_msg is None and svg_err_msg is None: - pass # leave err_msg blank - elif devicon_err_msg is None: - err_msg = svg_err_msg - elif svg_err_msg is None: - err_msg = devicon_err_msg - else: - err_msg = devicon_err_msg + "\n\n" + svg_err_msg + seperator = "\n\n" + if devicon_err_msg != "": + devicon_err_msg += seperator + elif filename_err_msg != "": + filename_err_msg += seperator - filehandler.write_to_file("./svg_err_messages.txt", err_msg) + filehandler.write_to_file("./svg_err_messages.txt", devicon_err_msg + filename_err_msg + svg_err_msg) print("Task completed.") except Exception as e: filehandler.write_to_file("./svg_err_messages.txt", str(e)) @@ -73,12 +74,20 @@ def check_devicon_object(icon: dict): 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.") + + for version in icon["versions"]["svg"]: + if not util.is_version_name_valid(version): + err_msgs.append("- Invalid version name in 'svg': {}. Must match regexp: (original|plain|line)(-wordmark)?") 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.") + + for version in icon["versions"]["font"]: + if not util.is_version_name_valid(version): + err_msgs.append("- Invalid version name in 'font': {}. Must match regexp: (original|plain|line)(-wordmark)?") except KeyError: err_msgs.append("- missing key: 'font' in 'versions'.") @@ -97,7 +106,7 @@ def check_devicon_object(icon: dict): if len(err_msgs) > 0: message = "Error found in 'devicon.json' for '{}' entry: \n{}".format(icon["name"], "\n".join(err_msgs)) return message - return None + return "" def check_svgs(svg_file_paths: List[Path]): @@ -115,11 +124,11 @@ def check_svgs(svg_file_paths: List[Path]): err_msgs = [] for svg_path in svg_file_paths: try: - err_msg = [f"{svg_path}:"] + err_msg = [f"Error in {svg_path}:"] # name check if not util.is_svg_name_valid(svg_path.name): - err_msg.append("-SVG file name didn't match our pattern of `name-(original|plain|line)(-wordmark)?.svg`") + err_msg.append("- SVG file name didn't match our pattern of `name-(original|plain|line)(-wordmark)?.svg`") # svg check tree = et.parse(svg_path) @@ -127,15 +136,15 @@ def check_svgs(svg_file_paths: List[Path]): namespace = "{http://www.w3.org/2000/svg}" if root.tag != f"{namespace}svg": - err_msg.append(f"-root is '{root.tag}'. Root must be an 'svg' element") + err_msg.append(f"- root is '{root.tag}'. Root must be an 'svg' element") if root.get("viewBox") != "0 0 128 128": - err_msg.append("-'viewBox' is not '0 0 128 128' -> Set it or scale the file using https://www.iloveimg.com/resize-image/resize-svg.") + err_msg.append("- 'viewBox' is not '0 0 128 128' -> Set it or scale the file using https://www.iloveimg.com/resize-image/resize-svg.") # goes through all elems and check for strokes for child in tree.iter(): if child.get("stroke") != None: - err_msg.append("-SVG contains `stroke` property. This will get ignored by Icomoon. Please convert them to fills.") + err_msg.append("- SVG contains `stroke` property. This will get ignored by Icomoon. Please convert them to fills.") break if len(err_msg) > 1: @@ -145,7 +154,7 @@ def check_svgs(svg_file_paths: List[Path]): if len(err_msgs) > 0: return "\n\n".join(err_msgs) - return None + return "" if __name__ == "__main__": From 55ff36670de9638d3a92533922434435da36af63 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:10:12 -0800 Subject: [PATCH 52/64] add post_check_icon_pr back --- .../workflows/post_check_icon_pr_comment.yml | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/post_check_icon_pr_comment.yml diff --git a/.github/workflows/post_check_icon_pr_comment.yml b/.github/workflows/post_check_icon_pr_comment.yml new file mode 100644 index 000000000..478f93a98 --- /dev/null +++ b/.github/workflows/post_check_icon_pr_comment.yml @@ -0,0 +1,80 @@ +name: Post the result of the check_icon_pr workflow into its PR. +on: + workflow_run: + workflows: ['Check Icon PR'] + types: + - completed +jobs: + post_result_of_svg_check: + name: Post the result of the Check SVG Action + runs-on: ubuntu-18.04 + steps: + - name: Check if the trigger run worked. If it failed, fail the current run. + if: github.event.workflow_run.conclusion != 'success' + uses: cutenode/action-always-fail@v1.0.1 + + - name: Download workflow artifact + uses: dawidd6/action-download-artifact@v2.11.0 + if: success() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + workflow: check_icon_pr.yml + run_id: ${{ github.event.workflow_run.id }} + + - name: Read the pr_num file + if: success() + id: pr_num_reader + uses: juliangruber/read-file-action@v1.0.0 + with: + path: ./pr_num/pr_num.txt + + - name: Read the err message file + if: success() + id: err_message_reader + uses: juliangruber/read-file-action@v1.0.0 + with: + path: ./svg_err_messages/svg_err_messages.txt + + - name: Comment on the PR about the result - SVG Error + uses: jungwinter/comment@v1 # let us comment on a specific PR + if: success() && (steps.err_message_reader.outputs.content != '0' && steps.err_message_reader.outputs.content != '1') + env: + MESSAGE: | + Hi! + + I'm the `check-bot` and we have some issues with your PR: + + ``` + {0} + ``` + + Check our [CONTRIBUTING guide](https://github.com/devicons/devicon/blob/develop/CONTRIBUTING.md#svgStandards) for more details regarding these errors. + + Please address these issues. When you update this PR, I will check your SVGs again. + + Thanks for your help, + SVG-Checker Bot :smile: + with: + type: create + issue_number: ${{ steps.pr_num_reader.outputs.content }} + token: ${{ secrets.GITHUB_TOKEN }} + body: ${{ format(env.MESSAGE, steps.err_message_reader.outputs.content) }} + + - name: Comment on the PR about the result - Failure + uses: jungwinter/comment@v1 # let us comment on a specific PR + if: failure() + env: + MESSAGE: | + Hi! + + I'm Devicons' SVG-Checker Bot and it seems we've ran into a problem. I'm supposed to check your svgs but I couldn't do my task due to an issue. + + Please let my maintainers know of the issues. They will take a look at my work and try to resolve the problem. Until then, please hang tight and sorry for the inconvenience. + + Cheers, + SVG-Checker Bot :smile: + with: + type: create + issue_number: ${{ steps.pr_num_reader.outputs.content }} + token: ${{ secrets.GITHUB_TOKEN }} + body: ${{ env.MESSAGE }} From 59fff68c5c9c5165a2559bea35dfaee3224890b3 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:12:20 -0800 Subject: [PATCH 53/64] fixed exception printing bug --- .github/scripts/check_icon_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/check_icon_pr.py b/.github/scripts/check_icon_pr.py index 8b4b5ad87..3f2f394be 100644 --- a/.github/scripts/check_icon_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -28,7 +28,7 @@ def main(): svgs = filehandler.get_svgs_paths([filtered_icon], args.icons_folder_path, as_str=False) print("SVGs to check: ", *svgs, sep='\n') except ValueError as e: - filename_err_msg = "Error found regarding filenames:\n- " + e.args + filename_err_msg = "Error found regarding filenames:\n- " + e.args[0] # check the svgs if len(svgs) == 0: From cea8c0501b885183a184899e5936db63b93d31a7 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:20:13 -0800 Subject: [PATCH 54/64] check svgs is none --- .github/scripts/check_icon_pr.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/scripts/check_icon_pr.py b/.github/scripts/check_icon_pr.py index 3f2f394be..70a0d135a 100644 --- a/.github/scripts/check_icon_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -24,6 +24,7 @@ def main(): # check the file names filename_err_msg = "" + svgs = None try: svgs = filehandler.get_svgs_paths([filtered_icon], args.icons_folder_path, as_str=False) print("SVGs to check: ", *svgs, sep='\n') @@ -31,9 +32,9 @@ def main(): filename_err_msg = "Error found regarding filenames:\n- " + e.args[0] # check the svgs - if len(svgs) == 0: + if svgs is None or len(svgs) == 0: print("No SVGs to check, ending script.") - svg_err_msg = "Error checking SVGs: no SVGs to check." + svg_err_msg = "Error checking SVGs: no SVGs to check. Might be caused by above issues." else: svg_err_msg = check_svgs(svgs) From a078a58cae2c81f8c47a7c63f5f9813c7b21df0b Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:30:47 -0800 Subject: [PATCH 55/64] rename err file --- .github/scripts/check_icon_pr.py | 4 ++-- .github/workflows/check_icon_pr.yml | 7 ++----- .github/workflows/post_check_icon_pr_comment.yml | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/scripts/check_icon_pr.py b/.github/scripts/check_icon_pr.py index 70a0d135a..5c48cde5e 100644 --- a/.github/scripts/check_icon_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -44,10 +44,10 @@ def main(): elif filename_err_msg != "": filename_err_msg += seperator - filehandler.write_to_file("./svg_err_messages.txt", devicon_err_msg + filename_err_msg + svg_err_msg) + filehandler.write_to_file("./err_messages.txt", devicon_err_msg + filename_err_msg + svg_err_msg) print("Task completed.") except Exception as e: - filehandler.write_to_file("./svg_err_messages.txt", str(e)) + filehandler.write_to_file("./err_messages.txt", str(e)) util.exit_with_err(e) diff --git a/.github/workflows/check_icon_pr.yml b/.github/workflows/check_icon_pr.yml index 4a37061fc..1247ed8ae 100644 --- a/.github/workflows/check_icon_pr.yml +++ b/.github/workflows/check_icon_pr.yml @@ -12,9 +12,6 @@ jobs: with: python-version: 3.8 - - name: Install dependencies - run: python -m pip install --upgrade pip - - name: Run the check_svg script env: PR_TITLE: ${{ github.event.pull_request.title }} @@ -24,8 +21,8 @@ jobs: uses: actions/upload-artifact@v2 if: success() with: - name: svg_err_messages - path: ./svg_err_messages.txt + name: err_messages + path: ./err_messages.txt - name: Save the pr num in an artifact shell: bash diff --git a/.github/workflows/post_check_icon_pr_comment.yml b/.github/workflows/post_check_icon_pr_comment.yml index 478f93a98..99321647c 100644 --- a/.github/workflows/post_check_icon_pr_comment.yml +++ b/.github/workflows/post_check_icon_pr_comment.yml @@ -33,7 +33,7 @@ jobs: id: err_message_reader uses: juliangruber/read-file-action@v1.0.0 with: - path: ./svg_err_messages/svg_err_messages.txt + path: ./err_messages/err_messages.txt - name: Comment on the PR about the result - SVG Error uses: jungwinter/comment@v1 # let us comment on a specific PR From ac5f98152afda508ba2f1217f6b8ca7ef7b6a4f2 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:37:33 -0800 Subject: [PATCH 56/64] update post workflow --- .github/workflows/post_check_icon_pr_comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/post_check_icon_pr_comment.yml b/.github/workflows/post_check_icon_pr_comment.yml index 99321647c..716ca752b 100644 --- a/.github/workflows/post_check_icon_pr_comment.yml +++ b/.github/workflows/post_check_icon_pr_comment.yml @@ -37,7 +37,7 @@ jobs: - name: Comment on the PR about the result - SVG Error uses: jungwinter/comment@v1 # let us comment on a specific PR - if: success() && (steps.err_message_reader.outputs.content != '0' && steps.err_message_reader.outputs.content != '1') + if: success() && (steps.err_message_reader.outputs.content != '') env: MESSAGE: | Hi! From 6efec79608fae664ab7592dea8172299a973ab0f Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Mon, 17 May 2021 16:36:33 -0700 Subject: [PATCH 57/64] Added testing files --- devicon.json | 20 ++++++++++++++++++++ icons/testingicon/testingicon-original.svg | 1 + icons/testingicon/testingicon-plain.svg | 1 + 3 files changed, 22 insertions(+) create mode 100644 icons/testingicon/testingicon-original.svg create mode 100644 icons/testingicon/testingicon-plain.svg diff --git a/devicon.json b/devicon.json index d9a40c776..ccd0fb913 100644 --- a/devicon.json +++ b/devicon.json @@ -92,6 +92,26 @@ "color": "#A4C439", "aliases": [] }, + { + "name": "testingicon", + "tags": [ + "architecture", + "programming", + "language", + "ARM" + ], + "versions": { + "svg": [ + "original", + "plain" + ], + "font": [ + "plain" + ] + }, + "color": "#16358C", + "aliases": [] + }, { "name": "aarch64", "tags": [ diff --git a/icons/testingicon/testingicon-original.svg b/icons/testingicon/testingicon-original.svg new file mode 100644 index 000000000..66009d4d3 --- /dev/null +++ b/icons/testingicon/testingicon-original.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/testingicon/testingicon-plain.svg b/icons/testingicon/testingicon-plain.svg new file mode 100644 index 000000000..10774d41a --- /dev/null +++ b/icons/testingicon/testingicon-plain.svg @@ -0,0 +1 @@ + \ No newline at end of file From a629db7a4d09f5e1ad2f64944880e888d494fef3 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:44:36 -0800 Subject: [PATCH 58/64] missing aliases --- devicon.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/devicon.json b/devicon.json index ccd0fb913..ac5673224 100644 --- a/devicon.json +++ b/devicon.json @@ -109,8 +109,7 @@ "plain" ] }, - "color": "#16358C", - "aliases": [] + "color": "#16358C" }, { "name": "aarch64", From e1abaec4cc2c5cdf3d17fd8584137e90c7accd9c Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:48:19 -0800 Subject: [PATCH 59/64] invalid version in devicon json and filename --- devicon.json | 2 +- .../{testingicon-original.svg => testingicon-origi.svg} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename icons/testingicon/{testingicon-original.svg => testingicon-origi.svg} (100%) diff --git a/devicon.json b/devicon.json index ac5673224..fe8b31dc7 100644 --- a/devicon.json +++ b/devicon.json @@ -102,7 +102,7 @@ ], "versions": { "svg": [ - "original", + "origi", "plain" ], "font": [ diff --git a/icons/testingicon/testingicon-original.svg b/icons/testingicon/testingicon-origi.svg similarity index 100% rename from icons/testingicon/testingicon-original.svg rename to icons/testingicon/testingicon-origi.svg From 86fcb30c7009a2e9afd85b564c90631b502edf90 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:49:45 -0800 Subject: [PATCH 60/64] improve logging --- .github/scripts/check_icon_pr.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/scripts/check_icon_pr.py b/.github/scripts/check_icon_pr.py index 5c48cde5e..0c64c4b3f 100644 --- a/.github/scripts/check_icon_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -38,13 +38,15 @@ def main(): else: svg_err_msg = check_svgs(svgs) - seperator = "\n\n" + err_msg = [] if devicon_err_msg != "": - devicon_err_msg += seperator + err_msg.append(devicon_err_msg) elif filename_err_msg != "": - filename_err_msg += seperator + err_msg.append(filename_err_msg) + elif svg_err_msg != "": + err_msg.append(svg_err_msg) - filehandler.write_to_file("./err_messages.txt", devicon_err_msg + filename_err_msg + svg_err_msg) + filehandler.write_to_file("./err_messages.txt", "\n\n".join(err_msg)) print("Task completed.") except Exception as e: filehandler.write_to_file("./err_messages.txt", str(e)) From 226f075d5e5f151394516ac3f962cfc15f44c220 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Mon, 17 May 2021 16:36:33 -0700 Subject: [PATCH 61/64] Added testing files --- devicon.json | 20 ++++++++++++++++++++ icons/testingicon/testingicon-original.svg | 1 + icons/testingicon/testingicon-plain.svg | 1 + 3 files changed, 22 insertions(+) create mode 100644 icons/testingicon/testingicon-original.svg create mode 100644 icons/testingicon/testingicon-plain.svg diff --git a/devicon.json b/devicon.json index d9a40c776..ccd0fb913 100644 --- a/devicon.json +++ b/devicon.json @@ -92,6 +92,26 @@ "color": "#A4C439", "aliases": [] }, + { + "name": "testingicon", + "tags": [ + "architecture", + "programming", + "language", + "ARM" + ], + "versions": { + "svg": [ + "original", + "plain" + ], + "font": [ + "plain" + ] + }, + "color": "#16358C", + "aliases": [] + }, { "name": "aarch64", "tags": [ diff --git a/icons/testingicon/testingicon-original.svg b/icons/testingicon/testingicon-original.svg new file mode 100644 index 000000000..66009d4d3 --- /dev/null +++ b/icons/testingicon/testingicon-original.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/testingicon/testingicon-plain.svg b/icons/testingicon/testingicon-plain.svg new file mode 100644 index 000000000..10774d41a --- /dev/null +++ b/icons/testingicon/testingicon-plain.svg @@ -0,0 +1 @@ + \ No newline at end of file From 7eaae46273e97bfdea0d9f10a401478e79d34c86 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:44:36 -0800 Subject: [PATCH 62/64] missing aliases --- devicon.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/devicon.json b/devicon.json index ccd0fb913..ac5673224 100644 --- a/devicon.json +++ b/devicon.json @@ -109,8 +109,7 @@ "plain" ] }, - "color": "#16358C", - "aliases": [] + "color": "#16358C" }, { "name": "aarch64", From f8ffc894bccd4732b4c3050ddbfe98e418c0f078 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sun, 26 Dec 2021 23:48:19 -0800 Subject: [PATCH 63/64] invalid version in devicon json and filename --- devicon.json | 2 +- .../{testingicon-original.svg => testingicon-origi.svg} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename icons/testingicon/{testingicon-original.svg => testingicon-origi.svg} (100%) diff --git a/devicon.json b/devicon.json index ac5673224..fe8b31dc7 100644 --- a/devicon.json +++ b/devicon.json @@ -102,7 +102,7 @@ ], "versions": { "svg": [ - "original", + "origi", "plain" ], "font": [ diff --git a/icons/testingicon/testingicon-original.svg b/icons/testingicon/testingicon-origi.svg similarity index 100% rename from icons/testingicon/testingicon-original.svg rename to icons/testingicon/testingicon-origi.svg From b96509a0e2164c10fc78ca70d4e1e20bb93f02df Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Mon, 27 Dec 2021 12:00:52 -0800 Subject: [PATCH 64/64] Added better logging --- .github/scripts/build_assets/filehandler.py | 6 +++--- .github/scripts/check_icon_pr.py | 15 ++++++++------- devicon.json | 5 +++-- err_messages.txt | 3 +++ ...ingicon-origi.svg => testingicon-original.svg} | 0 5 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 err_messages.txt rename icons/testingicon/{testingicon-origi.svg => testingicon-original.svg} (100%) diff --git a/.github/scripts/build_assets/filehandler.py b/.github/scripts/build_assets/filehandler.py index 4c7d9acaa..1e24045db 100644 --- a/.github/scripts/build_assets/filehandler.py +++ b/.github/scripts/build_assets/filehandler.py @@ -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) @@ -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, @@ -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]): diff --git a/.github/scripts/check_icon_pr.py b/.github/scripts/check_icon_pr.py index 0c64c4b3f..2c62f9ac7 100644 --- a/.github/scripts/check_icon_pr.py +++ b/.github/scripts/check_icon_pr.py @@ -41,9 +41,11 @@ def main(): err_msg = [] if devicon_err_msg != "": err_msg.append(devicon_err_msg) - elif filename_err_msg != "": + + if filename_err_msg != "": err_msg.append(filename_err_msg) - elif svg_err_msg != "": + + if svg_err_msg != "": err_msg.append(svg_err_msg) filehandler.write_to_file("./err_messages.txt", "\n\n".join(err_msg)) @@ -80,7 +82,7 @@ def check_devicon_object(icon: dict): for version in icon["versions"]["svg"]: if not util.is_version_name_valid(version): - err_msgs.append("- Invalid version name in 'svg': {}. Must match regexp: (original|plain|line)(-wordmark)?") + err_msgs.append(f"- Invalid version name in versions['svg']: '{version}'. Must match regexp: (original|plain|line)(-wordmark)?") except KeyError: err_msgs.append("- missing key: 'svg' in 'versions'.") @@ -90,7 +92,7 @@ def check_devicon_object(icon: dict): for version in icon["versions"]["font"]: if not util.is_version_name_valid(version): - err_msgs.append("- Invalid version name in 'font': {}. Must match regexp: (original|plain|line)(-wordmark)?") + err_msgs.append(f"- Invalid version name in versions['font']: '{version}'. Must match regexp: (original|plain|line)(-wordmark)?") except KeyError: err_msgs.append("- missing key: 'font' in 'versions'.") @@ -116,8 +118,7 @@ def check_svgs(svg_file_paths: List[Path]): """ Check the width, height, viewBox and style of each svgs passed in. The viewBox must be '0 0 128 128'. - If the svg has a width and height attr, ensure it's '128px'. - The style must not contain any 'fill' declarations. + The style must not contain any 'stroke' declarations. If any error is found, they will be thrown. :param: svg_file_paths, the file paths to the svg to check for. :return: None if there no errors. If there is, return a JSON.stringified @@ -127,7 +128,7 @@ def check_svgs(svg_file_paths: List[Path]): err_msgs = [] for svg_path in svg_file_paths: try: - err_msg = [f"Error in {svg_path}:"] + err_msg = [f"SVG Error in '{svg_path.name}':"] # name check if not util.is_svg_name_valid(svg_path.name): diff --git a/devicon.json b/devicon.json index fe8b31dc7..ccd0fb913 100644 --- a/devicon.json +++ b/devicon.json @@ -102,14 +102,15 @@ ], "versions": { "svg": [ - "origi", + "original", "plain" ], "font": [ "plain" ] }, - "color": "#16358C" + "color": "#16358C", + "aliases": [] }, { "name": "aarch64", diff --git a/err_messages.txt b/err_messages.txt new file mode 100644 index 000000000..b6c9c6986 --- /dev/null +++ b/err_messages.txt @@ -0,0 +1,3 @@ +SVG Error in 'testingicon-original.svg': +- 'viewBox' is not '0 0 128 128' -> Set it or scale the file using https://www.iloveimg.com/resize-image/resize-svg. +- SVG contains `stroke` property. This will get ignored by Icomoon. Please convert them to fills. \ No newline at end of file diff --git a/icons/testingicon/testingicon-origi.svg b/icons/testingicon/testingicon-original.svg similarity index 100% rename from icons/testingicon/testingicon-origi.svg rename to icons/testingicon/testingicon-original.svg