Skip to content

Commit ca887b2

Browse files
authored
Merge pull request #386 from devicons/develop
Release master with fixed build process
2 parents 0e56598 + dcd0861 commit ca887b2

10 files changed

Lines changed: 158 additions & 187 deletions

File tree

.github/scripts/build_assets/SeleniumRunner.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ 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-
7978
# wait until the whole web page is loaded by testing the hamburger input
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"))
79+
WebDriverWait(self.driver, self.LONG_WAIT_IN_SEC).until(
80+
ec.element_to_be_clickable((By.XPATH, "(//i[@class='icon-menu'])[2]"))
8381
)
84-
hamburger_input.click()
8582
print("Accessed icomoon.io")
83+
8684

8785
def upload_icomoon(self, icomoon_json_path: str):
8886
"""
@@ -92,11 +90,16 @@ def upload_icomoon(self, icomoon_json_path: str):
9290
"""
9391
print("Uploading icomoon.json file...")
9492
try:
93+
self.click_hamburger_input()
94+
9595
# find the file input and enter the file path
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-
)
96+
import_btn = self.driver.find_element(By.XPATH, "(//li[@class='file'])[1]//input")
9997
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
100103
except Exception as e:
101104
self.close()
102105
raise e
@@ -159,8 +162,8 @@ def click_hamburger_input(self):
159162
:return: None.
160163
"""
161164
try:
162-
hamburger_input = self.driver.find_element_by_css_selector(
163-
"button.btn5.lh-def.transparent i.icon-menu"
165+
hamburger_input = self.driver.find_element_by_xpath(
166+
"(//i[@class='icon-menu'])[2]"
164167
)
165168

166169
menu_appear_callback = ec.element_to_be_clickable(
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from pathlib import Path
2+
from argparse import ArgumentParser
3+
from build_assets.PathResolverAction import PathResolverAction
4+
5+
def get_commandline_args():
6+
parser = ArgumentParser(description="Upload svgs to Icomoon to create icon files.")
7+
8+
parser.add_argument("--headless",
9+
help="Whether to run the browser in headless/no UI mode",
10+
action="store_true")
11+
12+
parser.add_argument("geckodriver_path",
13+
help="The path to the firefox executable file",
14+
action=PathResolverAction)
15+
16+
parser.add_argument("icomoon_json_path",
17+
help="The path to the icomoon.json aka the selection.json created by Icomoon",
18+
action=PathResolverAction)
19+
20+
parser.add_argument("devicon_json_path",
21+
help="The path to the devicon.json",
22+
action=PathResolverAction)
23+
24+
parser.add_argument("icons_folder_path",
25+
help="The path to the icons folder",
26+
action=PathResolverAction)
27+
28+
parser.add_argument("download_path",
29+
help="The path where you'd like to download the Icomoon files to",
30+
action=PathResolverAction)
31+
32+
33+
return parser.parse_args()

.github/scripts/icomoon_build.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from pathlib import Path
2+
from selenium.common.exceptions import TimeoutException
3+
4+
# pycharm complains that build_assets is an unresolved ref
5+
# don't worry about it, the script still runs
6+
from build_assets.SeleniumRunner import SeleniumRunner
7+
from build_assets import filehandler, util
8+
9+
10+
def main():
11+
args = util.get_commandline_args()
12+
new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path)
13+
if len(new_icons) == 0:
14+
print("No files need to be uploaded. Ending script...")
15+
return
16+
17+
# print list of new icons
18+
print("List of new icons:", *new_icons, sep = "\n")
19+
20+
runner = None
21+
try:
22+
runner = SeleniumRunner(args.download_path,
23+
args.geckodriver_path, args.headless)
24+
runner.upload_icomoon(args.icomoon_json_path)
25+
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
26+
runner.upload_svgs(svgs)
27+
28+
zip_name = "devicon-v1.0.zip"
29+
zip_path = Path(args.download_path, zip_name)
30+
runner.download_icomoon_fonts(zip_path)
31+
filehandler.extract_files(str(zip_path), args.download_path)
32+
filehandler.rename_extracted_files(args.download_path)
33+
print("Task completed.")
34+
except TimeoutException as e:
35+
print(e)
36+
print(e.stacktrace)
37+
finally:
38+
runner.close()
39+
40+
41+
if __name__ == "__main__":
42+
main()

.github/scripts/icomoon_peek.py

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

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

118

129
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-
10+
args = util.get_commandline_args()
4111
new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path)
4212
if len(new_icons) == 0:
43-
print("No files need to be peek. Ending script...")
13+
print("No files need to be uploaded. Ending script...")
4414
return
4515

46-
# print list of new icons, separated by comma
47-
print("List of new icons:")
48-
print(*new_icons, sep = "\n")
16+
# print list of new icons
17+
print("List of new icons:", *new_icons, sep = "\n")
18+
19+
runner = None
4920
try:
50-
runner = SeleniumRunner(args.download_path,
51-
args.geckodriver_path, args.headless)
21+
runner = SeleniumRunner(args.download_path, args.geckodriver_path, args.headless)
5222
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
5323
runner.upload_svgs(svgs)
54-
runner.close()
5524
print("Task completed.")
5625
except TimeoutException as e:
5726
print(e)
5827
print(e.stacktrace)
28+
finally:
5929
runner.close()
6030

6131

.github/scripts/icomoon_upload.py

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

.github/workflows/build_icons.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ jobs:
1818
python -m pip install --upgrade pip
1919
pip install -r ./.github/scripts/requirements.txt
2020
npm install
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
21+
- name: Executing build and create fonts via icomoon
22+
run: npm run build
2623
- name: Upload geckodriver.log for debugging purposes
2724
uses: actions/upload-artifact@v2
2825
if: ${{failure()}}
@@ -35,7 +32,7 @@ jobs:
3532
with:
3633
name: new_icons
3734
path: ./new_icons.png
38-
- name: Running npm task for building devicon.min.css
35+
- name: Build devicon.min.css
3936
if: ${{ success() }}
4037
run: npm run build-css
4138
- name: Create Pull Request

.github/workflows/peek_icons.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@ jobs:
1616
uses: actions/setup-python@v2
1717
with:
1818
python-version: 3.8
19-
- name: Install dependencies (python, pip, npm)
19+
- name: Install dependencies (python, pip)
2020
run: |
2121
python -m pip install --upgrade pip
2222
pip install -r ./.github/scripts/requirements.txt
23-
npm install
2423
- name: Run icomoon_peek.py
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
24+
run: npm run peek
2925
- name: Upload geckodriver.log for debugging purposes
3026
uses: actions/upload-artifact@v2
3127
if: ${{failure()}}

0 commit comments

Comments
 (0)