Skip to content

Commit 5fc6041

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into feature/306-jenkins
* upstream/develop: Fixed an error where last commit didn't have desired changes Remove the new_icons.png and update CONTRIBUTING.md Added a peek script Change the repo reference in the workflow Fix css color not including the aliases
2 parents e9c25c2 + d480883 commit 5fc6041

8 files changed

Lines changed: 127 additions & 13 deletions

File tree

.github/scripts/build_assets/SeleniumRunner.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,26 @@ class SeleniumRunner:
3636
"""
3737
ICOMOON_URL = "https://icomoon.io/app/#/select"
3838

39-
def __init__(self, icomoon_json_path: str, download_path: str,
40-
geckodriver_path: str, headless):
39+
def __init__(self, download_path: str,
40+
geckodriver_path: str, headless: bool):
4141
"""
4242
Create a SeleniumRunner object.
43-
:param icomoon_json_path: a path to the iconmoon.json.
4443
:param download_path: the location where you want to download
4544
the icomoon.zip to.
4645
:param geckodriver_path: the path to the firefox executable.
4746
:param headless: whether to run browser in headless (no UI) mode.
4847
"""
49-
self.icomoon_json_path = icomoon_json_path
50-
self.download_path = download_path
5148
self.driver = None
52-
self.set_options(geckodriver_path, headless)
49+
self.set_options(download_path, geckodriver_path, headless)
5350

54-
def set_options(self, geckodriver_path: str, headless: bool):
51+
def set_options(self, download_path: str, geckodriver_path: str,
52+
headless: bool):
5553
"""
5654
Build the WebDriver with Firefox Options allowing downloads and
5755
set download to download_path.
56+
:param download_path: the location where you want to download
5857
:param geckodriver_path: the path to the firefox executable.
58+
the icomoon.zip to.
5959
:param headless: whether to run browser in headless (no UI) mode.
6060
6161
:raises AssertionError: if the page title does not contain
@@ -69,16 +69,17 @@ def set_options(self, geckodriver_path: str, headless: bool):
6969

7070
# set the default download path to downloadPath
7171
options.set_preference("browser.download.folderList", 2)
72-
options.set_preference("browser.download.dir", self.download_path)
72+
options.set_preference("browser.download.dir", download_path)
7373
options.headless = headless
7474

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
7878

79-
def upload_icomoon(self):
79+
def upload_icomoon(self, icomoon_json_path: str):
8080
"""
8181
Upload the icomoon.json to icomoon.io.
82+
:param icomoon_json_path: a path to the iconmoon.json.
8283
:raises TimeoutException: happens when elements are not found.
8384
"""
8485
print("Uploading icomoon.json file...")
@@ -87,7 +88,7 @@ def upload_icomoon(self):
8788
import_btn = WebDriverWait(self.driver, SeleniumRunner.LONG_WAIT_IN_SEC).until(
8889
ec.presence_of_element_located((By.CSS_SELECTOR, "div#file input"))
8990
)
90-
import_btn.send_keys(self.icomoon_json_path)
91+
import_btn.send_keys(icomoon_json_path)
9192
except Exception as e:
9293
self.close()
9394
raise e

.github/scripts/icomoon_peek.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 peek. 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+
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
53+
runner.upload_svgs(svgs)
54+
runner.close()
55+
print("Task completed.")
56+
except TimeoutException as e:
57+
print(e)
58+
print(e.stacktrace)
59+
runner.close()
60+
61+
62+
if __name__ == "__main__":
63+
main()

.github/scripts/icomoon_upload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def main():
4747
print("List of new icons:")
4848
print(*new_icons, sep = "\n")
4949
try:
50-
runner = SeleniumRunner(args.icomoon_json_path, args.download_path,
50+
runner = SeleniumRunner(args.download_path,
5151
args.geckodriver_path, args.headless)
52-
runner.upload_icomoon()
52+
runner.upload_icomoon(args.icomoon_json_path)
5353
svgs = filehandler.get_svgs_paths(new_icons, args.icons_folder_path)
5454
runner.upload_svgs(svgs)
5555

.github/workflows/build_icons.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
- uses: actions/checkout@v2
1212
with:
1313
ref: ${{ github.head_ref }}
14+
repository: ${{ github.event.pull_request.head.repo.full_name}}
1415
- name: Setup Python v3.8
1516
uses: actions/setup-python@v2
1617
with:

.github/workflows/peek_icons.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Peek Icons
2+
on:
3+
pull_request:
4+
types: [labeled]
5+
jobs:
6+
build:
7+
name: Get Fonts From Icomoon
8+
if: contains(github.event.pull_request.labels.*.name, 'bot:peek')
9+
runs-on: windows-2019
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
ref: ${{ github.head_ref }}
14+
repository: ${{ github.event.pull_request.head.repo.full_name}}
15+
- name: Setup Python v3.8
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: 3.8
19+
- name: Install dependencies (python, pip, npm)
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r ./.github/scripts/requirements.txt
23+
npm install
24+
- 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
29+
- name: Upload geckodriver.log for debugging purposes
30+
uses: actions/upload-artifact@v2
31+
if: ${{failure()}}
32+
with:
33+
name: geckodriver-log
34+
path: ./geckodriver.log
35+
- name: Upload screenshot of the newly made icons
36+
uses: actions/upload-artifact@v2
37+
if: ${{success()}}
38+
with:
39+
name: new_icons
40+
path: ./new_icons.png

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Some icons are really simple (like the Apple one), so the original version can b
6363
<li>The <b>plain</b> and <b>line</b> versions (with or without wordmark) need to stay as simple as possible. They must have only one color and the paths are united before exporting to svg.
6464
</li>
6565
<li>Optimize/compress your SVGs. You can use a service like <a href="https://compressor.io/">compressor</a> or <a href="https://petercollingridge.appspot.com/svg-editor">SVG Editor</a>.</li>
66-
<li>
66+
<li>The icon's strokes and texts must be fills. We use Icomoon to make our icon, which has its<a href="https://icomoon.io/#docs/stroke-to-fill"> requirements</a></li>
6767
</ul>
6868

6969
<hr>

gulpfile.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,22 @@ function createColorsCSS(deviconJson) {
101101
font: fonts
102102
},
103103
color,
104+
aliases
104105
} = fontObj;
105106

106107
if (fonts.length === 0 || typeof(color) !== "string") {
107108
console.log(`This object doesn't have a font or a color: ${name}`);
108109
return "";
109110
}
111+
112+
// process the icons in the font attr
110113
let cssClasses = fonts.map(font => `.devicon-${name}-${font}.colored`);
114+
115+
// process the icons in the aliases attr
116+
aliases.forEach(aliasObj => {
117+
cssClasses.push(`.devicon-${name}-${aliasObj["alias"]}.colored`);
118+
});
119+
111120
return `${cssClasses.join(",")}{color: ${color}}`;
112121
}).join(" ");
113122

new_icons.png

-71.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)