Skip to content

Commit a173e10

Browse files
committed
bring up to pre-commit standards and add workflows
1 parent c77b0f3 commit a173e10

25 files changed

+242
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2021 Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
Thank you for contributing! Before you submit a pull request, please read the following.
6+
7+
Make sure any changes you're submitting are in line with the CircuitPython Design Guide, available here: https://docs.circuitpython.org/en/latest/docs/design_guide.html
8+
9+
If your changes are to documentation, please verify that the documentation builds locally by following the steps found here: https://adafru.it/build-docs
10+
11+
Before submitting the pull request, make sure you've run Pylint and Black locally on your code. You can do this manually or using pre-commit. Instructions are available here: https://adafru.it/check-your-code
12+
13+
Please remove all of this text before submitting. Include an explanation or list of changes included in your PR, as well as, if applicable, a link to any related issues.

.github/workflows/build.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Build CI
6+
7+
on: [pull_request, push]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Translate Repo Name For Build Tools filename_prefix
14+
id: repo-name
15+
run: |
16+
echo "repo-name=$(
17+
echo ${{ github.repository }} |
18+
awk -F '\/' '{ print tolower($2) }' |
19+
tr '_' '-'
20+
)" >> $GITHUB_OUTPUT
21+
- name: Set up Python 3.11
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.11"
25+
- name: Versions
26+
run: |
27+
python3 --version
28+
- uses: actions/checkout@v3
29+
with:
30+
submodules: true
31+
fetch-depth: 0
32+
- name: Install deps
33+
run: |
34+
sudo apt update
35+
sudo apt-get install gettext otf2bdf xfonts-utils
36+
pip install -r requirements.txt
37+
pip install pre-commit
38+
- name: Library version
39+
run: git describe --dirty --always --tags
40+
- name: Pre-commit hooks
41+
run: |
42+
pre-commit run --all-files
43+
- name: Build assets
44+
run: python build.py
45+
- uses: actions/upload-artifact@v3
46+
with:
47+
path: dist
48+
name: bundle
49+
- name: Setup problem matchers
50+
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2021 Scott Shawcroft for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Failure help text
6+
7+
on:
8+
workflow_run:
9+
workflows: ["Build CI"]
10+
types:
11+
- completed
12+
13+
jobs:
14+
post-help:
15+
runs-on: ubuntu-latest
16+
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' }}
17+
steps:
18+
- name: Post comment to help
19+
uses: adafruit/circuitpython-action-library-ci-failed@v1

.github/workflows/images.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Generate folder images
6+
7+
on:
8+
schedule:
9+
- cron: '0 10 * * *'
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: bundle-folder-images
14+
cancel-in-progress: true
15+
16+
jobs:
17+
update-images:
18+
if: github.repository_owner == 'adafruit'
19+
runs-on: ubuntu-20.04
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: checkout submodules
24+
run: git submodule update --init --jobs 16 --depth 1
25+
- name: Set up Python 3.11
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.11"
29+
30+
- name: Checkout screenshot maker
31+
run: git clone --depth=1 https://github.com/circuitpython/CircuitPython_Library_Screenshot_Maker
32+
33+
- name: Install dependencies
34+
run: pip install -r CircuitPython_Library_Screenshot_Maker/requirements.txt
35+
36+
- name: Generate images
37+
run: |
38+
find libraries -path "libraries/*/examples/*.py" -exec python3 CircuitPython_Library_Screenshot_Maker/create_requirement_images.py bundle {} +
39+
40+
- name: Commit updates
41+
run: |
42+
cd generated_images
43+
git config --global user.name "${GITHUB_ACTOR} (github actions cron)"
44+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
45+
git config --global init.defaultBranch main
46+
git init
47+
for i in *.png; do echo "<a href=\"$i\">$i</a><br>"; done > index.html
48+
git add *.png index.html
49+
git remote add origin https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
50+
if git commit -m"update images"; then git push -f origin HEAD:folder-images; fi

.github/workflows/release.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Release Actions
6+
7+
on:
8+
workflow_dispatch:
9+
release:
10+
types: [published]
11+
12+
jobs:
13+
upload-release-assets:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Translate Repo Name For Build Tools filename_prefix
17+
id: repo-name
18+
run: |
19+
echo "repo-name=$(
20+
echo ${{ github.repository }} |
21+
awk -F '\/' '{ print tolower($2) }' |
22+
tr '_' '-'
23+
)" >> $GITHUB_OUTPUT
24+
- name: Set up Python 3.11
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.11"
28+
- name: Versions
29+
run: |
30+
python3 --version
31+
- uses: actions/checkout@v3
32+
with:
33+
submodules: true
34+
fetch-depth: 0
35+
- name: Install deps
36+
run: |
37+
sudo apt update
38+
sudo apt-get install gettext otf2bdf xfonts-utils
39+
pip install -r requirements.txt
40+
- name: Build assets
41+
run: python build.py
42+
- name: Upload Release Assets
43+
uses: shogo82148/actions-upload-release-asset@v1
44+
with:
45+
asset_path: "dist/*"
46+
github_token: ${{ secrets.GITHUB_TOKEN }}
47+
upload_url: ${{ github.event.release.upload_url }}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# SPDX-FileCopyrightText: 2023 Jeff Epler for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
14
/build-*
25
/build_deps
36
/dist

LICENSES/Special-Font-Exception.txt renamed to LICENSES/LicenseRef-Special-Font-Exception.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ the GNU FreeFont software before embedding it. This is true even though
3535
portions of the software become part of the document.
3636

3737
Therefore users of fonts released with this exception need not concern
38-
themselves with the license terms to:
38+
themselves with the license terms to:
3939

4040
Create a printable file using the fonts.
4141
- Publish such a file.

LICENSES/MIT.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) <year> <copyright holders>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
I'm a little README
1+
Build a suite of importable bitmap fonts for CircuitPython
2+
3+
# SPDX-FileCopyrightText: 2023 Jeff Epler for Adafruit Industries
4+
# SPDX-License-Identifier: MIT

build.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
with open("config.toml", "rb") as f:
1414
config = tomllib.load(f)
1515

16+
1617
def build(src, dest, size, variant):
1718
src = Path("fonts") / src
1819
font_license = src.with_suffix(src.suffix + ".license")
19-
uvariant= variant.replace('-', '_')
20-
destdir = Path(f"libraries/circuitpython-font-{dest.replace('_', '-')}-{size}{variant}")
20+
uvariant = variant.replace("-", "_")
21+
destdir = Path(
22+
f"libraries/circuitpython-font-{dest.replace('_', '-')}-{size}{variant}"
23+
)
2124
print(destdir)
2225

2326
package = f"circuitpython_font_{dest}_{size}{uvariant}"
@@ -43,8 +46,10 @@ def build(src, dest, size, variant):
4346
# SPDX-License-Identifier: Unlicense
4447
4548
CircuitPython font generated from {src} @{size}{variant}
46-
"""))
47-
convert(src, packagedir / "font.pcf", size, '32_126' if variant else None)
49+
"""
50+
)
51+
)
52+
convert(src, packagedir / "font.pcf", size, "32_126" if variant else None)
4853

4954
dest_font_license = packagedir / "font.pcf.license"
5055
dest_font_license.write_text(font_license.read_text())
@@ -73,16 +78,24 @@ def build(src, dest, size, variant):
7378
7479
from {package} import FONT
7580
print(FONT.get_bounding_box())
76-
"""))
81+
"""
82+
)
83+
)
7784

78-
if __name__ == '__main__':
79-
targets = [(src, dest, size, variant)
85+
86+
if __name__ == "__main__":
87+
targets = [
88+
(src, dest, size, variant)
8089
for dest, src in config["FONTS"].items()
81-
for size in config["SIZES"]
82-
for variant in ("", "-ascii")]
90+
for size in config["SIZES"]
91+
for variant in ("", "-ascii")
92+
]
8393

8494
with Pool() as pool:
8595
# This construct causes all the individual calls to finish, discarding the results
8696
deque(pool.starmap(build, targets), 0)
8797

88-
check_call("circuitpython-build-bundles --output_directory dist --filename_prefix circuitpython-font --library_location libraries/ --library_depth 1", shell=True)
98+
check_call(
99+
"circuitpython-build-bundles --output_directory dist --filename_prefix circuitpython-font --library_location libraries/ --library_depth 1",
100+
shell=True,
101+
)

config.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
1+
# SPDX-FileCopyrightText: 2023 Jeff Epler for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
23

34
SIZES = [6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 60, 72]
45

convert.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env python3
2+
# SPDX-FileCopyrightText: 2023 Jeff Epler for Adafruit Industries
3+
# SPDX-License-Identifier: MIT
4+
25
from pathlib import Path
36
from subprocess import run, check_call, DEVNULL, PIPE
47

@@ -8,10 +11,9 @@
811
def convert(src: Path, dest: Path, size: int, subset=None) -> None:
912
otf_command = ["otf2bdf", "-p", f"{size}", "-r", "72", f"{src}"]
1013
if subset:
11-
otf_command.extend(['-l', subset])
14+
otf_command.extend(["-l", subset])
1215

13-
otf_process = run(otf_command, stdin=DEVNULL, stdout=PIPE
14-
)
16+
otf_process = run(otf_command, stdin=DEVNULL, stdout=PIPE)
1517
bdf_content = otf_process.stdout
1618
if otf_process.returncode != 8:
1719
print(f"Note: End of bdf_content: {bdf_content[-32:]!r}")

fonts/FreeMono.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeMonoBold.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeMonoBoldOblique.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeMonoOblique.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeSans.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeSansBold.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeSansBoldOblique.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeSansOblique.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeSerif.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeSerifBold.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeSerifBoldItalic.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

fonts/FreeSerifItalic.ttf.license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
SPDX-FileCopyrightText: 2002-2012 GNU Freefont contributors
22

3-
SPDX-License-Identifier: GPL-3.0-or-later WITH Special-Font-Exception
3+
SPDX-License-Identifier: GPL-3.0-or-later WITH LicenseRef-Special-Font-Exception

requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-FileCopyrightText: 2023 Jeff Epler for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
circuitpython-build-tools

0 commit comments

Comments
 (0)