Skip to content

Commit 460cdf5

Browse files
authored
Revert "Fix a couple issues found in the build script"
1 parent 0ca4e3b commit 460cdf5

10 files changed

Lines changed: 187 additions & 158 deletions

File tree

.github/scripts/build_assets/SeleniumRunner.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ def set_options(self, download_path: str, geckodriver_path: str,
7575
self.driver = WebDriver(options=options, executable_path=geckodriver_path)
7676
self.driver.get(self.ICOMOON_URL)
7777
assert "IcoMoon App" in self.driver.title
78+
7879
# wait until the whole web page is loaded by testing the hamburger input
79-
WebDriverWait(self.driver, self.LONG_WAIT_IN_SEC).until(
80-
ec.element_to_be_clickable((By.XPATH, "(//i[@class='icon-menu'])[2]"))
80+
hamburger_input = WebDriverWait(self.driver, SeleniumRunner.LONG_WAIT_IN_SEC).until(
81+
ec.element_to_be_clickable((By.CSS_SELECTOR,
82+
"button.btn5.lh-def.transparent i.icon-menu"))
8183
)
84+
hamburger_input.click()
8285
print("Accessed icomoon.io")
83-
8486

8587
def upload_icomoon(self, icomoon_json_path: str):
8688
"""
@@ -90,16 +92,11 @@ def upload_icomoon(self, icomoon_json_path: str):
9092
"""
9193
print("Uploading icomoon.json file...")
9294
try:
93-
self.click_hamburger_input()
94-
9595
# find the file input and enter the file path
96-
import_btn = self.driver.find_element(By.XPATH, "(//li[@class='file'])[1]//input")
96+
import_btn = WebDriverWait(self.driver, SeleniumRunner.LONG_WAIT_IN_SEC).until(
97+
ec.element_to_be_clickable((By.CSS_SELECTOR, "div#file input"))
98+
)
9799
import_btn.send_keys(icomoon_json_path)
98-
except SeleniumTimeoutException as e:
99-
print(e.stacktrace)
100-
print("Selenium timed out. Couldn't find import button.")
101-
self.close()
102-
raise e
103100
except Exception as e:
104101
self.close()
105102
raise e
@@ -162,8 +159,8 @@ def click_hamburger_input(self):
162159
:return: None.
163160
"""
164161
try:
165-
hamburger_input = self.driver.find_element_by_xpath(
166-
"(//i[@class='icon-menu'])[2]"
162+
hamburger_input = self.driver.find_element_by_css_selector(
163+
"button.btn5.lh-def.transparent i.icon-menu"
167164
)
168165

169166
menu_appear_callback = ec.element_to_be_clickable(

.github/scripts/build_assets/util.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/scripts/icomoon_build.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/scripts/icomoon_peek.py

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,61 @@
1+
from pathlib import Path
2+
from argparse import ArgumentParser
13
from selenium.common.exceptions import TimeoutException
24

35
# pycharm complains that build_assets is an unresolved ref
46
# don't worry about it, the script still runs
57
from build_assets.SeleniumRunner import SeleniumRunner
6-
from build_assets import filehandler, util
8+
from build_assets import filehandler
9+
from build_assets.PathResolverAction import PathResolverAction
710

811

912
def main():
10-
args = util.get_commandline_args()
13+
parser = ArgumentParser(description="Upload svgs to Icomoon to create icon files.")
14+
15+
parser.add_argument("--headless",
16+
help="Whether to run the browser in headless/no UI mode",
17+
action="store_true")
18+
19+
parser.add_argument("geckodriver_path",
20+
help="The path to the firefox executable file",
21+
action=PathResolverAction)
22+
23+
parser.add_argument("icomoon_json_path",
24+
help="The path to the icomoon.json aka the selection.json created by Icomoon",
25+
action=PathResolverAction)
26+
27+
parser.add_argument("devicon_json_path",
28+
help="The path to the devicon.json",
29+
action=PathResolverAction)
30+
31+
parser.add_argument("icons_folder_path",
32+
help="The path to the icons folder",
33+
action=PathResolverAction)
34+
35+
parser.add_argument("download_path",
36+
help="The path where you'd like to download the Icomoon files to",
37+
action=PathResolverAction)
38+
39+
args = parser.parse_args()
40+
1141
new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path)
1242
if len(new_icons) == 0:
13-
print("No files need to be uploaded. Ending script...")
43+
print("No files need to be peek. Ending script...")
1444
return
1545

16-
# print list of new icons
17-
print("List of new icons:", *new_icons, sep = "\n")
18-
19-
runner = None
46+
# print list of new icons, separated by comma
47+
print("List of new icons:")
48+
print(*new_icons, sep = "\n")
2049
try:
21-
runner = SeleniumRunner(args.download_path, args.geckodriver_path, args.headless)
50+
runner = SeleniumRunner(args.download_path,
51+
args.geckodriver_path, args.headless)
2252
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
2353
runner.upload_svgs(svgs)
54+
runner.close()
2455
print("Task completed.")
2556
except TimeoutException as e:
2657
print(e)
2758
print(e.stacktrace)
28-
finally:
2959
runner.close()
3060

3161

.github/scripts/icomoon_upload.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from pathlib import Path
2+
from argparse import ArgumentParser
3+
from selenium.common.exceptions import TimeoutException
4+
5+
# pycharm complains that build_assets is an unresolved ref
6+
# don't worry about it, the script still runs
7+
from build_assets.SeleniumRunner import SeleniumRunner
8+
from build_assets import filehandler
9+
from build_assets.PathResolverAction import PathResolverAction
10+
11+
12+
def main():
13+
parser = ArgumentParser(description="Upload svgs to Icomoon to create icon files.")
14+
15+
parser.add_argument("--headless",
16+
help="Whether to run the browser in headless/no UI mode",
17+
action="store_true")
18+
19+
parser.add_argument("geckodriver_path",
20+
help="The path to the firefox executable file",
21+
action=PathResolverAction)
22+
23+
parser.add_argument("icomoon_json_path",
24+
help="The path to the icomoon.json aka the selection.json created by Icomoon",
25+
action=PathResolverAction)
26+
27+
parser.add_argument("devicon_json_path",
28+
help="The path to the devicon.json",
29+
action=PathResolverAction)
30+
31+
parser.add_argument("icons_folder_path",
32+
help="The path to the icons folder",
33+
action=PathResolverAction)
34+
35+
parser.add_argument("download_path",
36+
help="The path where you'd like to download the Icomoon files to",
37+
action=PathResolverAction)
38+
39+
args = parser.parse_args()
40+
41+
new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path)
42+
if len(new_icons) == 0:
43+
print("No files need to be uploaded. Ending script...")
44+
return
45+
46+
# print list of new icons, separated by comma
47+
print("List of new icons:")
48+
print(*new_icons, sep = "\n")
49+
try:
50+
runner = SeleniumRunner(args.download_path,
51+
args.geckodriver_path, args.headless)
52+
runner.upload_icomoon(args.icomoon_json_path)
53+
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
54+
runner.upload_svgs(svgs)
55+
56+
57+
zip_name = "devicon-v1.0.zip"
58+
zip_path = Path(args.download_path, zip_name)
59+
runner.download_icomoon_fonts(zip_path)
60+
filehandler.extract_files(str(zip_path), args.download_path)
61+
filehandler.rename_extracted_files(args.download_path)
62+
runner.close()
63+
print("Task completed.")
64+
except TimeoutException as e:
65+
print(e)
66+
print(e.stacktrace)
67+
runner.close()
68+
69+
70+
if __name__ == "__main__":
71+
main()

.github/workflows/build_icons.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ jobs:
1818
python -m pip install --upgrade pip
1919
pip install -r ./.github/scripts/requirements.txt
2020
npm install
21-
- name: Executing build and create fonts via icomoon
22-
run: npm run build
21+
- name: Run icomoon_upload.py
22+
run: >
23+
python ./.github/scripts/icomoon_upload.py
24+
./.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe
25+
./icomoon.json ./devicon.json ./icons ./ --headless
2326
- name: Upload geckodriver.log for debugging purposes
2427
uses: actions/upload-artifact@v2
2528
if: ${{failure()}}
@@ -32,7 +35,7 @@ jobs:
3235
with:
3336
name: new_icons
3437
path: ./new_icons.png
35-
- name: Build devicon.min.css
38+
- name: Running npm task for building devicon.min.css
3639
if: ${{ success() }}
3740
run: npm run build-css
3841
- name: Create Pull Request

.github/workflows/peek_icons.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ jobs:
1616
uses: actions/setup-python@v2
1717
with:
1818
python-version: 3.8
19-
- name: Install dependencies (python, pip)
19+
- name: Install dependencies (python, pip, npm)
2020
run: |
2121
python -m pip install --upgrade pip
2222
pip install -r ./.github/scripts/requirements.txt
23+
npm install
2324
- name: Run icomoon_peek.py
24-
run: npm run peek
25+
run: >
26+
python ./.github/scripts/icomoon_peek.py
27+
./.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe
28+
./icomoon.json ./devicon.json ./icons ./ --headless
2529
- name: Upload geckodriver.log for debugging purposes
2630
uses: actions/upload-artifact@v2
2731
if: ${{failure()}}

0 commit comments

Comments
 (0)