From 886dcf917409e4c6e98871377f33bf454bc70969 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Fri, 24 Dec 2021 22:56:37 -0800 Subject: [PATCH 1/8] 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 2/8] 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 3/8] 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 4/8] 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 426e73503944e2c3dee339e70a09ee6af0d2d047 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 20:38:36 -0800 Subject: [PATCH 5/8] Fixed errors in labeler_bot --- .github/scripts/build_assets/api_handler.py | 17 +++++++++-------- .github/scripts/build_assets/arg_getters.py | 4 ++++ .github/scripts/in_develop_labeler.py | 4 +++- .github/workflows/in_develop_labeler.yml | 15 +++++++++++---- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index 730ed561e..652c89bee 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,14 +113,14 @@ 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, body=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}.") + raise Exception(f"Can't label the Issue provided. Issue: {issue}, labels: {labels}, API response: " + response.text) else: print(f"Successfully labelled issue {issue}") @@ -139,9 +140,9 @@ 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, json=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}") @@ -166,9 +167,9 @@ 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, json=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: 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 827a2a443..5b68adad3 100644 --- a/.github/scripts/in_develop_labeler.py +++ b/.github/scripts/in_develop_labeler.py @@ -7,9 +7,11 @@ 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) - api_handler.label_issues(args.token, issues_numbers, ["in-develop"]) + 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") diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 6ae9edb4a..22ce676ed 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -4,17 +4,24 @@ 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 + 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: 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 }} TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: python in_develop_labeler.py $TOKEN $BODY + BODY: ${{ github.event.pull_request.body }} + run: python ./.github/scripts/in_develop_labeler.py $TOKEN "$BODY" $GITHUB_REPOSITORY From 68fdd191b4e0391a6dd25accaace4d237b5a4fe8 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Sat, 25 Dec 2021 23:28:03 -0800 Subject: [PATCH 6/8] Update build-bot --- .github/scripts/build_assets/api_handler.py | 30 ++++++------- .github/scripts/build_assets/arg_getters.py | 4 -- .github/scripts/icomoon_build.py | 47 +++++++++++---------- .github/scripts/in_develop_labeler.py | 5 ++- .github/workflows/build_icons.yml | 2 +- .github/workflows/in_develop_labeler.yml | 2 +- 6 files changed, 44 insertions(+), 46 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index 652c89bee..f7d665137 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -4,6 +4,11 @@ from typing import List +# our base url which leads to devicon +base_url = "https://api.github.com/repos/devicons/devicon/" +# testing url +# base_url = "https://api.github.com/repos/Thomas-Boi/devicon/" + def get_merged_pull_reqs_since_last_release(token): """ Get all the merged pull requests since the last release. @@ -39,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}" } @@ -51,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) @@ -101,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]): + +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 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. """ @@ -113,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(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: @@ -135,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.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: @@ -153,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?per_page=100&labels={}&page={}" headers = { "Authorization": f"token {token}", "accept": "application/vnd.github.v3+json" @@ -162,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.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: diff --git a/.github/scripts/build_assets/arg_getters.py b/.github/scripts/build_assets/arg_getters.py index e8499bb2d..71f7d16b8 100644 --- a/.github/scripts/build_assets/arg_getters.py +++ b/.github/scripts/build_assets/arg_getters.py @@ -82,8 +82,4 @@ 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/icomoon_build.py b/.github/scripts/icomoon_build.py index 8a321dfee..5b2906715 100644 --- a/.github/scripts/icomoon_build.py +++ b/.github/scripts/icomoon_build.py @@ -20,38 +20,39 @@ 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...") + 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(f"There are {len(new_icons)} icons to be build. Here are they:", *new_icons, sep = "\n") - # print("Begin optimizing files...") - # optimize_svgs(new_icons, args.icons_folder_path) + print("Begin optimizing files...") + optimize_svgs(new_icons, args.icons_folder_path) - # print("Updating the icomoon json...") - # update_icomoon_json(new_icons, args.icomoon_json_path) + print("Updating the icomoon json...") + update_icomoon_json(new_icons, args.icomoon_json_path) - # 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) + 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) + 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("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) + 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: diff --git a/.github/scripts/in_develop_labeler.py b/.github/scripts/in_develop_labeler.py index 5b68adad3..c065b9667 100644 --- a/.github/scripts/in_develop_labeler.py +++ b/.github/scripts/in_develop_labeler.py @@ -11,9 +11,10 @@ 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, args.repo, issues_numbers, ["in-develop"]) + 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") + print("The PR body doesn't contain `**This PR closes` keywords. Ending workflow.") + return if __name__ == "__main__": main() 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 diff --git a/.github/workflows/in_develop_labeler.yml b/.github/workflows/in_develop_labeler.yml index 22ce676ed..61b7b4335 100644 --- a/.github/workflows/in_develop_labeler.yml +++ b/.github/workflows/in_develop_labeler.yml @@ -24,4 +24,4 @@ jobs: env: TOKEN: ${{ secrets.GITHUB_TOKEN }} BODY: ${{ github.event.pull_request.body }} - run: python ./.github/scripts/in_develop_labeler.py $TOKEN "$BODY" $GITHUB_REPOSITORY + run: python ./.github/scripts/in_develop_labeler.py $TOKEN "$BODY" From 39070daf2320c3f74d2422a1c56e2d1844620fd0 Mon Sep 17 00:00:00 2001 From: Thomas Bui <43018778+Thomas-Boi@users.noreply.github.com> Date: Sun, 26 Dec 2021 20:25:49 -0800 Subject: [PATCH 7/8] Update .github/scripts/icomoon_build.py Co-authored-by: David Leal --- .github/scripts/icomoon_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/icomoon_build.py b/.github/scripts/icomoon_build.py index 5b2906715..ab45b33c4 100644 --- a/.github/scripts/icomoon_build.py +++ b/.github/scripts/icomoon_build.py @@ -49,7 +49,7 @@ 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`.") + print("Closing issues with the `in-develop` label.") issues = api_handler.get_issues_by_labels(args.token, ["in-develop"]) issue_nums = [issue_num["number"] for issue_num in issues] api_handler.close_issues(args.token, issue_nums) From 21f3bd74505c253820da57e87cbe399d6185a3c4 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Fri, 28 Jan 2022 10:12:08 -0800 Subject: [PATCH 8/8] Remove test url --- .github/scripts/build_assets/api_handler.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/scripts/build_assets/api_handler.py b/.github/scripts/build_assets/api_handler.py index f7d665137..fef1db575 100644 --- a/.github/scripts/build_assets/api_handler.py +++ b/.github/scripts/build_assets/api_handler.py @@ -6,8 +6,6 @@ # 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): """